Ok, here’s the deal. There’s something about perspective that I’m obviously not understanding. The following code draws a rectangle just fine:
void drawRect(void)
{
glPushMatrix();
glColor3f(1.0,0.1,1.0);
glTranslatef(0.0, 0.0, -150.0);
glRectf(-10.0, -10.0, 10.0, 10.0);
glPopMatrix();
}
But, if I change the glRectf call with the following:
glEnable(GL_QUADS);
glVertex3f(-10.0, -10.0, 0.0);
glVertex3f(-10.0, 10.0, 0.0);
glVertex3f(10.0, 10.0, 0.0);
glVertex3f(10.0, -10.0, 0.0);
glEnd();
Then nothing displays! Here is my drawScene code if it might be helpful
void drawScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0, 1.0, 1.0, 500.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(-cam.roll, 0, 0, 1);
glRotatef(-cam.pitch, 1, 0, 0);
glRotatef(-cam.head, 0, 1, 0);
glTranslatef(-cam.x, -cam.y, -cam.z);
drawRect();
glFlush();
glutSwapBuffers();
}
I hate to post a thread that says basically ‘help me fix my code’, but it’s more the understanding I’m worried about. Why would the Quad not display, but the rectangle shows up fine?
Cheers.