LWJGL Forum

Programming => OpenGL => Topic started by: elias4444 on August 20, 2006, 17:41:20

Title: Alternative to clearing bits?
Post by: elias4444 on August 20, 2006, 17:41:20
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?
Title: hmmmmmmmm....
Post by: Fool Running on August 21, 2006, 13:35:32
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);
Title: Alternative to clearing bits?
Post by: elias4444 on August 21, 2006, 14:30:19
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?