Jump to content
  • Advertisement

Archived

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

Landsknecht

Problem with glClear...

This topic is 5979 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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
You can set up your WNDCLASS structure with the CS_OWNDC flag, so then your window will keep the same DC always.

- Pete

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!