Alternative to clearing bits?

Started by elias4444, August 20, 2006, 17:41:20

Previous topic - Next topic

elias4444

I've noticed that something I've done in my engine isn't exactly optimal. There are times when I need to layer things, so I clear the DEPTH_BUFFER_BIT before starting each layer. Well, apparently, that's kind of intensive because it causes a pretty solid drop in my framerate. Is there a quicker way to reset the depth buffer than using glClear?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

Fool Running

To my knowledge, there is no faster way to clear it than with the DEPTH_BUFFER_BIT flag. However, if you are also clearing the color/stencil/ect. bits, make sure you do them in the same call to glClear().
i.e. do:
glClear(GL_STENCIL_BUFFER_BIT | GL_SCISSOR_BIT | DEPTH_BUFFER_BIT);

instead of
glClear(GL_STENCIL_BUFFER_BIT);
glClear(GL_SCISSOR_BIT);
glClear(DEPTH_BUFFER_BIT);
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

elias4444

Yeah, on each frame I run the full clear command with all the bits I use... the trick comes into doing layers of complex geometry.

Would it work if I switched to an orthogonal view just to render the objects on a higher z-plane (but make it not look like), or would that just look weird to do on top of a perspective view?
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com