Drawing Pool table Pockets using OPENGL GLUT
As the title says really, I have drawn the rest of the table just having trouble drawing the pockets..
#pragma region Table Drawing Code
void drawTable()
{
glBegin(GL_QUADS); // RIGHT
glNormal3f(0,0,1);
glColor3d(0.5,0.35,0.05);
glVertex3f(m_TableX, 0.0f, m_TableWidth); //bottom left
glVertex3f(m_TableLength, 0.0f, m_TableWidth);//bottom right
glVertex3f(m_TableLength, 0.0f, m_TableWidth);//top right
glVertex3f(m_TableX, 0.0f, m_TableWidth); //top left
glEnd();
glBegin(GL_QUADS); //BACK
glNormal3f(1,0,0);
glColor3d(0.5,0.35,0.05);开发者_Go百科
glVertex3f(m_TableLength, 0.0f, m_TableWidth);
glVertex3f(m_TableLength, 0.0f, m_TableZ);
glVertex3f(m_TableLength, 0.0f, m_TableZ);
glVertex3f(m_TableLength, 0.0f, m_TableWidth);
glEnd();
glBegin(GL_QUADS); //FRONT
glNormal3f(-1,0,0);
glColor3d(0.5,0.35,0.05);
glVertex3f(m_TableX, 0.0f, m_TableZ);
glVertex3f(m_TableX, 0.0f, m_TableWidth);
glVertex3f(m_TableX, 0.0f, m_TableWidth);
glVertex3f(m_TableX, 0.0f, m_TableZ);
glEnd();
glBegin(GL_QUADS); //lEFT
glNormal3f(0,0,-1);
glColor3d(0.5,0.35,0.05);
glVertex3f(m_TableX, 0.0f, m_TableZ);
glVertex3f(m_TableLength, 0.0f, m_TableZ);
glVertex3f(m_TableX, 0.0f, m_TableZ);
glVertex3f(m_TableLength, 0.0f, m_TableZ);
glEnd();
glBegin(GL_QUADS); //BOTTOM
glNormal3f(0,-1,0);
glColor3d(0.5,0.35,0.05);
glVertex3f(m_TableX, -0.001f, m_TableWidth);
glVertex3f(m_TableLength, -0.001f, m_TableWidth);
glVertex3f(m_TableLength, -0.001f, m_TableZ);
glVertex3f(m_TableX, -0.001f, m_TableZ);
glEnd();
}
#pragma endregion
I am new to OpenGL so I'm not sure what to use to get the curve that is connected to the cushions and the hole in the table for the ball to drop.
try using gluPartialDisk to draw a "C" shape for the corner of the pocket for example
void disk() {
gluPartialDisk(gluNewQuadric(),1, 1.2, 10, 1, 0.0, -180); }
then declare disk(); in your draw method
精彩评论