[SDL] Speeding up glClear?

Gabriel mystml at adinet.com.uy
Thu Jan 6 10:52:39 PST 2005


> My second thought is that in my projection matrix, the near z plane is 
> too close to the camera - it's at a distance of 0.2.  I've encountered
> other problems with the near plane being too close to the camera, but 
> those were all with rendering errors, not with slow performance, but 
> I'm wondering if perhaps the depth clearing will be faster if the near
> z plane is at least a distance of 1.0 from the camera.  Call it
> intuition.

Probably not. Clearing the depth buffer involves writing 0s to every
pixel, so what's on the pixel before doesn't matter.

What you can do though, if you don't need a lot of depth buffer
precission, is to use the range 0 - 0.5 in one frame, and then 0.5 - 1
in the next, then 0-0.5 and so on, thus removing the neccessity to
clear. I don't remember the specifics but there was a way to do that.


> Third thought is to throw in a skybox of some kind, which will in
> theory remove the need to clear the color buffer with each frame. 

This one is correct, and in fact, widely used. If you played Doom or
Duke Nukem 3D, and used one of the clip hacks, stepping out of the map
caused the background to become dirty. That's because the games assumed
the map was closed, and therefore didn't clear the color buffer at all.

        --Gabriel







More information about the SDL mailing list