Does anyone know why this code works the same way when bProjectionNotModeview == TRUE or FALSE:
glClearColor(0.0, 0.0, 0.0, 1.0);
glClearDepth(1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 640.0 / 480.0, 1.0, 1000.0);
if ((m_bMoveCameraForward == true) && (m_bMoveCameraBackward == false))
{
m_f32CameraPositionZ += 0.1F;
}
else if ((m_bMoveCameraForward == false) && (m_bMoveCameraBackward == true))
{
m_f32CameraPositionZ -= 0.1F;
}
if ((m_bMoveCameraLeft == true) && (m_bMoveCameraRight == false))
{
m_f32CameraPositionX += 0.1F;
}
else if ((m_bMoveCameraLeft == false) && (m_bMoveCameraRight == true))
{
m_f32CameraPositionX -= 0.1F;
}
// !!! HERE BEGINS THE PROBLEM !!!
if (bProjectionNotModeview == true)
{
glMatrixMode(GL_PROJECTION);
glTranslatef(m_f32CameraPositionX, 0.0F, m_f32CameraPositionZ);
glRotatef(m_f32CameraAngleY, 0.0F, 1.0F, 0.0F);
glRotatef(m_f32CameraAngleX, 1.0F, 0.0F, 0.0F);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
else
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(m_f32CameraPositionX, 0.0F, m_f32CameraPositionZ);
glRotatef(m_f32CameraAngleY, 0.0F, 1.0F, 0.0F);
glRotatef(m_f32CameraAngleX, 1.0F, 0.0F, 0.0F);
}
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glBegin(GL_QUADS);
glColor3ub(255, 0, 0);
glVertex3f( 10.0F, 10.0F, 10.0F);
glColor3ub( 0, 255, 0);
glVertex3f(-10.0F, 10.0F, 10.0F);
glColor3ub( 0, 0, 255);
glVertex3f(-10.0F, -10.0F, 10.0F);
glColor3ub(255, 255, 0);
glVertex3f( 10.0F, -10.0F, 10.0F);
glColor3ub(255, 0, 0);
glVertex3f( 10.0F, 10.0F, -10.0F);
glColor3ub(255, 0, 0);
glVertex3f( 10.0F, 10.0F, 10.0F);
glColor3ub(255, 255, 0);
glVertex3f( 10.0F, -10.0F, 10.0F);
glColor3ub(255, 255, 0);
glVertex3f( 10.0F, -10.0F, -10.0F);
glColor3ub( 0, 255, 0);
glVertex3f(-10.0F, 10.0F, 10.0F);
glColor3ub( 0, 255, 0);
glVertex3f(-10.0F, 10.0F, -10.0F);
glColor3ub( 0, 0, 255);
glVertex3f(-10.0F, -10.0F, -10.0F);
glColor3ub( 0, 0, 255);
glVertex3f(-10.0F, -10.0F, 10.0F);
glColor3ub( 0, 255, 0);
glVertex3f(-10.0F, 10.0F, -10.0F);
glColor3ub(255, 0, 0);
glVertex3f( 10.0F, 10.0F, -10.0F);
glColor3ub(255, 255, 0);
glVertex3f( 10.0F, -10.0F, -10.0F);
glColor3ub( 0, 0, 255);
glVertex3f(-10.0F, -10.0F, -10.0F);
glEnd();