Archived

This topic is now archived and is closed to further replies.

Landsknecht

Problem with glClear...

Recommended Posts

Landsknecht    234
I am reading the Prima book now and am having a heck of a difficulty. I am working on the first example that uses OGL. All it does is put a rotating triangle on the screen. I am using asserts sprinkled around the code to test stuff. Ecerything works just fine except the frame rate is avout 1 frame every 2-3 seconds... When I profiled the code - it seems the bottleneck is the glClear call... glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Why would that call take up SO much time? I mean, this call is made at least once per frame, right? Landsknecht

Share this post


Link to post
Share on other sites
Myopic Rhino    2317
glClear isn''t exactly free, but it shouldn''t cause that kind of slowdown unless something else is wrong. What video card do you have? Have you modified any of the pixel format code?

Share this post


Link to post
Share on other sites
bschwagg    122
It does kill some time. Only solutions I can think of would be to turn your pixel bits down, or not use the depth-buffer and draw your objects from the farthest back to the closest.
If you are drawing to the entire screen/window then you actually don''t need to clear the color buffer.
ah yes, a simpler solution is a new video card or computer hehe

Share this post


Link to post
Share on other sites
Landsknecht    234
Nope - aint the hardware...

1.1gHz Thunderbird
GeForce2MX 32mb

I am leaning toward it being a typo in the book. Got the red book and am comparing notes. Thanks for the ideas though.

Landsknecht

Share this post


Link to post
Share on other sites
Landsknecht    234
GOT IT!!! Well, this was kinda silly. I was trying to pull the OGL code out into a class... While doing this I didn''t realize that you actually create a second DC for your window. Ending up with one DC that CreateWindowEx returns and another DC that is tweaked by the WGL functions.

I had compacted the 2 DC''s into a single. The bug didn''t rear its head until the code hit the glClear function... I guess it was trying to clear a buffer that did not exist. I changed my code so that I used the DC''s like I was supposed to and it suddenly worked!

Thanks for the response guys!

Landsknecht

Share this post


Link to post
Share on other sites