Jump to content
  • Advertisement
Sign in to follow this  
Capoeirista

OpenGL Depth Testing

This topic is 4996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, I'm trying to get depth testing for a very simple OpenGL program working (it simply draws a figure on the window using cubes of different colours). The code works fine without the z-buffer enabled (the figure is drawn correctly), but as soon as I call glEnable(GL_DEPTH_TEST) I simply get a black screen. I've set up my pixel format (i'm using the standard windows api to create my window) so that it has 32bits for the depth buffer : PIXELFORMATDESCRIPTOR pfd = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_TYPE_RGBA, 32, 0,0,0,0,0,0, 0, 0, 0, 0,0,0,0, 32, 0, 0, PFD_MAIN_PLANE, 0, 0,0,0}; And every time my rendering function executes, I call glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); To clear the screen and the depth buffer. Any idea why I would be getting the black screen when I enable depth testing (which I want to enable so that I can animate my figure). The orientation of the polygons shouldn't matter, should it?

Share this post


Link to post
Share on other sites
Advertisement
You can change whether the orientation matters or not. you could try glDisable-ing GL_CULL_FACE. You can change the winding mode by calling glCullFace with GL_FRONT, GL_BACK or GL_FRONT_AND_BACK as a parameter.

Did you call glDepthFunc(GL_LEQUAL)?

If you set up a stencil buffer try clearing the stencil buffer as well and check the stencil test function (glStencilFunc).

... did any of those do it?

EDIT: I don't think you've set up the stencil buffer, after looking at the pixel format part, so you can just ignore what I said about that. You might also want to check if your far clipping plane isn't too close.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!