PDA

View Full Version : Rendering problem



tabor25
07-06-2007, 05:11 AM
After rendering my scene i need to draw a coordinate system - also when other objects lying nearer to the eye position. I tried glDisable(GL_DEPTH_TEST). But this is the wrong way because the coordinate system has to be drawn by comparing the z values to be rendered correctly. What other alternatives there are? I hope this question is worth to be under 'advanced'!

Best regards,
Tabor25

Relic
07-06-2007, 07:58 AM
If it's after you rendered your other scene and you don't need the depth buffer anymore and don't want to depth test against the other geometry, just do glClear(GL_DEPTH_BUFFER_BIT) before rendering your coordinate system.
If it's that simple, then no, that's not advanced. ;)

tabor25
07-07-2007, 01:10 AM
When i am right, using glClear() is an expensive operation. So i don't want to use it more than once per frame. Is there another alternative?

ZbuffeR
07-07-2007, 01:53 AM
glClear() is an expensive operationHum, not really. calling it once or twice would not matter much. just try.

tabor25
07-07-2007, 09:42 AM
I tried it and it is like you said. Thank you!

zed
07-07-2007, 02:45 PM
im not really understanding why glDisable(GL_DEPTH_TEST) doesnt work but anyways

apart from clearing the depthbuffer
u could try

glDepthTest( GL_ALWAYS ); // i think thats the syntax

or

glDepthRange(0,0);

knackered
07-08-2007, 01:21 PM
I think he's talking about drawing an axis triplet in a kind of HUD layer. In which case you'll need depth testing to draw the axis correctly, but the depth values from the scene-draw will mess it up, so glClear'ing the depth buffer is the way to go. But you don't have to clear the whole framebuffer (if you're running at a high resolution this will be a significant fill cost), use glScissor to only clear the screen rectangle the axis will use.

Humus
07-08-2007, 03:55 PM
You could avoid the clear entirely by partitioning the depth buffer. That should be the fastest. For instance draw the scene in [0.1 .. 1.0] range, and use [0, 0.1] for HUD items that needs depth testing.

Brolingstanz
07-08-2007, 11:11 PM
... or you could render your HUD into a separate framebuffer and composite it with the background. This might not be optimal in terms of performance, but it might simplify things and add some flexibility to boot.

remdul
07-09-2007, 11:03 AM
Check out glDepthMask() and glDepthRange(), they may be useful.

knackered
07-09-2007, 03:59 PM
how? do share...

Michael Gold
07-10-2007, 06:24 AM
I'm not sure how DepthMask helps but DepthRange is a good suggestion; Humus describes it correctly.

If you cannot afford to lose depth precision then a scissored depth clear is the way to go.

Or, if its a simple enough coordinate system, disable DEPTH_TEST and use a painter's algorithm.

zed
07-10-2007, 04:08 PM
Or, if its a simple enough coordinate system, disable DEPTH_TEST and use a painter's algorithm.that will work as theres not gonna be any polygon intersection.
just draw from back to front the 3 axises based on distance to camera the axises end points.