fortikur
2005.04.12, 04:09 PM
I just tried out to draw using glOrtho. According to the RedBook, the help, forums, etc. glOrtho's Near and Far values only define two clipping planes, which means, if I set Near to 0 and far to 100, everything that is between 0 and 100 will be drawn. Things that are closer (behind) or further won't be drawn. Is this correct?
If it is, can somebody pls tell me, why I cannot see anything on the screen, if the quad's z coordinate is at 99?
Suprisingly, if i set it to -99 (!) it becomes visible. But wait! Near and far are 0 and 100, and z is -99...
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glOrtho(0,800,600,0, 0, 100);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, backgr);
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2f(0, 1);
glVertex3d(50, 50, 99);
glTexCoord2f(0, 0);
glVertex3d(150, 50, 99);
glTexCoord2f(1, 0);
glVertex3d( 150, 150, 99);
glTexCoord2f(1, 1);
glVertex3d( 50, 150, 99);
glEnd();
glEnable(GL_LIGHTING);
glDisable(GL_BLEND);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
SwapBuffers(DCvalue);
Just one thing: I need depth test, so pls. don't ask me to try it out without depth test. By the way, using or disabling it give the same result.
Can pls. someone tell me why this code isn't correct?
Thx in advance
If it is, can somebody pls tell me, why I cannot see anything on the screen, if the quad's z coordinate is at 99?
Suprisingly, if i set it to -99 (!) it becomes visible. But wait! Near and far are 0 and 100, and z is -99...
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glOrtho(0,800,600,0, 0, 100);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, backgr);
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2f(0, 1);
glVertex3d(50, 50, 99);
glTexCoord2f(0, 0);
glVertex3d(150, 50, 99);
glTexCoord2f(1, 0);
glVertex3d( 150, 150, 99);
glTexCoord2f(1, 1);
glVertex3d( 50, 150, 99);
glEnd();
glEnable(GL_LIGHTING);
glDisable(GL_BLEND);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
SwapBuffers(DCvalue);
Just one thing: I need depth test, so pls. don't ask me to try it out without depth test. By the way, using or disabling it give the same result.
Can pls. someone tell me why this code isn't correct?
Thx in advance