[SDL] Speeding up glClear?

Steve Smith onecrane at gmail.com
Thu Jan 6 09:40:51 PST 2005


I get the sense that this is kind of an eternal question, but it's
been driving me a bit batty.  I've been running some timing on a very
simple 3D maze program to try to figure out why my framerates are so
low on older machines - for instance, my P2 550 runs it at about 4
frames per second.  The timing indicates that the call each frame of:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

takes over 250 ms to complete at 800x600 fullscreen resolution.

I've come up with a few hypotheses for how to speed this up, but I'm
hoping the expertise out here will be able to give me ideas I haven't
thought of or information I don't know.

My first thought is to lower the resolution to 640x480 for instance,
but this should conceptually only be about a 25% speed increase - 5
fps instead of 4 fps isn't quite the tradeoff I'm looking for.

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.

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. 
Currently, a lot of the cleared background is visible over the tops of
the walls of the maze, and there's no floor to the maze, so that area
has to be cleared as well.

Can anyone tell me if I'm on the right track with these ideas, or give
guidance if there's something I've missed?

Thanks,
Steve




More information about the SDL mailing list