I am using OpenGL 1.2 with an STB nVidia TNT card. I setup a double buffered GLUT window with a depth buffer by calling:
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
I then enable Depth testing by calling:
glEnable( GL_DEPTH_TEST );
And the first thing I do for each display callback is clear the depth buffer:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
But all I get is a blank screen. If I disable depth testing, then my polygons are displayed by the reverse order in which they were drawn. It doesn’t even seem to work properly on a machine with a Creative Labs TNT2 Ultra. Is this possibly a card/driver problem?
Yes. I’m using gluPerspective and have specified the near and far planes with that. I can verify that that part works correctly if I disable DEPTH_TEST and then move around.
If one is not specified, it defaults to using GL_LESS. But I have tried calling glDepthFunc with all 8 variants - GL_LESS, GL_GREATER, etc. GL_NEVER appropriately gives a blank screen and GL_ALWAYS is the same as having no depth test.
Using GL_GREATER actually seems to work appropriately. It gives a blank screen if I set glClearDepth( 1.0 ) and does proper drawing if I set glClearDepth( 0.0 ). But GL_LESS just gives a blank screen with either glClearDepth setting or if I don’t specify one - which I believe defaults to 1.0. And, of course, GL_LESS is the one that I need to have working.
First off, let me thank AndersO and Humus for trying to help and all those that read this thread with the intent of helping.
Second, I found my problem. A lesson learned the hard way for me is to not set your near clipping plane to 0. Bad and unexpected things can happen. So I set it to .1 and things work as they should.
I am using OpenGL 1.2 with an STB nVidia TNT card. I setup a double buffered GLUT window with a depth buffer by calling:
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
I then enable Depth testing by calling:
glEnable( GL_DEPTH_TEST );
And the first thing I do for each display callback is clear the depth buffer:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
But all I get is a blank screen. If I disable depth testing, then my polygons are displayed by the reverse order in which they were drawn. It doesn’t even seem to work properly on a machine with a Creative Labs TNT2 Ultra. Is this possibly a card/driver problem?