Trouble with depth test thingy. help :(
Right Ive got this program which draws a large triangle and some lines in a grid 0.1f above it. When I turn on the depth buffer though, it all flickers and stuff. The lines flicker, and some frames either the lines or the triangle aren''t drawn. Ive remembereed to do the following:
glClear depthbuffer.
glEnable DEPTH_TEST
glFlush (not sure if this is neccesary but anyway...)
SwapBuffers
glDepthFunc (just to make sure)
Soooo.... any help?
please?
Ill pay you... with thingys.
Thanks for the help which you *will* give me...
Tim.
Hmmm
September 30, 2001 02:39 PM
i have no idea if this will help, but when you clear the depth buffer clear the colour buffer alswell, if your not already doing so
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
September 30, 2001 03:14 PM
I think the problem is that your depth buffer doesn''t have enough precision to differentiate between 0.1 units with your current settings. Try moving the near clipping plane out a few units and moving the far clipping plane in closer.
Also make sure you actually have a depth buffer. Calling glEnable(GL_DEPTH_TEST) is not enough. You must create it explicitely when you create your rendering context. Do you use NeHe''s code to initialise your window ?
why are you using glflush right away? doesn't it go after you've rendered everything? In NeHe's tuts he puts it at the end of DrawGLScene.
Oops nevermind i just realized you're probably not showing those in the order they are in your code.
Edited by - element2001 on October 1, 2001 11:28:55 AM
Oops nevermind i just realized you're probably not showing those in the order they are in your code.
Edited by - element2001 on October 1, 2001 11:28:55 AM
Erm, Yes it is created with a depth buffer (16 bit depth), you may be rigth though seing as the far clipping plane is 1000.0f and the near is 0.1f Forgot about that . Thanks
Yep glFlush is after drawing code...
Thanks.. Ill just try it.
Yep glFlush is after drawing code...
Thanks.. Ill just try it.
Hmmm
Ow. Doesn''t work.
changed to 32 bit depth buffer and far clip distance to 100.0f
I dont think it is actually the depth buffer, just something that happens when you turn it on. I just drew one trianle and that doesn''t draw in some frames.
EXE is at interphere.port5.com/flick.exe If you want to see for yourself. Thanks for any help.
changed to 32 bit depth buffer and far clip distance to 100.0f
I dont think it is actually the depth buffer, just something that happens when you turn it on. I just drew one trianle and that doesn''t draw in some frames.
EXE is at interphere.port5.com/flick.exe If you want to see for yourself. Thanks for any help.
Hmmm
I think this is an example would glPolygonOffset would work booty-fully.
I don''t completely understand the math behind the function, but basically, you can use glPolygonOffset to offset your primitives by a very small fraction, which can satisfy things like rendering twice over the same area, shadows, lightmaps, and your example. Any good OpenGL book or website should talk about it.
One thing I don''t understand about your example is how the triangle can sometimes not draw at all when just a grid of lines is above it? Maybe I''d have to see a picture to get it.
Hope this helps
Mark Grocki
Lead Developer
2Real Entertainment
http://www.2realentertainment.com
I don''t completely understand the math behind the function, but basically, you can use glPolygonOffset to offset your primitives by a very small fraction, which can satisfy things like rendering twice over the same area, shadows, lightmaps, and your example. Any good OpenGL book or website should talk about it.
One thing I don''t understand about your example is how the triangle can sometimes not draw at all when just a grid of lines is above it? Maybe I''d have to see a picture to get it.
Hope this helps

Mark Grocki
Lead Developer
2Real Entertainment
http://www.2realentertainment.com
Mark Grocki
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement