Dear all, I have a simple piece of OpenGL code without any elaborate transformations or projections as below. Given the projection matrix is set to identity, and the modelview matrix is also set to identity before drawing the 3 triangles, I would expect the Z axis to be the default Z- axis pointing into the screen. However, upon rendering this code, it shows as if the Z+ axis is pointing into the screen (see rendering screenshot). Please advise, do I misunderstand something? Is the code actually consistent with the rendering screenshot? Thank you!
void initializeGL()
{
glEnable(GL_CULL_FACE);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void resizeGL(int w, int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0.0, 0.0, 1.0, 1.0); //blue background
//test
glBegin(GL_TRIANGLES);
glColor4f(1.0f, 0.0f, 0.0f, 1.0f); //red
glVertex3f(-1.0f, -1.0f, 0.2f);
glVertex3f(1.0f, -1.0f, 0.2f);
glVertex3f(0.0f, 1.0f, 0.2f);
glColor4f(0.0f, 1.0f, 0.0f, 1.0f); //green
glVertex3f(-1.0f, -1.0f, 0.5f);
glVertex3f(1.0f, -1.0f, 0.5f);
glVertex3f(0.0f, 1.0f, 0.5f);
glColor4f(1.0f, 1.0f, 0.0f, 1.0f); //yellow
glVertex3f(-1.0f, -1.0f, 0.1f);
glVertex3f(1.0f, -1.0f, 0.1f);
glVertex3f(0.0f, 1.0f, 0.3f);
glEnd();
}
[ATTACH=CONFIG]1210[/ATTACH]