Jump to content
  • Advertisement
Sign in to follow this  
GosuDrew

SwapBuffers()

This topic is 4749 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

Suppose you create an OpenGL program where you can drag some 2D objects around on the screen. If you use SwapBuffers(), the entire front surface will be redrawn. So, if your just dragging one object around, wouldn't this be inefficient? Is there anyway to specify which parts of the screen you want to be redrawn?

Share this post


Link to post
Share on other sites
Advertisement
You could use one buffer only, but with double buffers you have some advantages, such as no tearing.
And no, with double buffers you can't just swap them partially. You SWAP the BUFFERS, not update them.

Share this post


Link to post
Share on other sites
In your case it may be more efficient to only update the region that has changed. That is a common technique in 2D. For example, in Win32, this is handled by InvalidateRect(). There is no equivalent functionality provided in OpenGL, but you could implement it yourself.

Share this post


Link to post
Share on other sites
Yeah, my win32 chess game only bitblts what needs to be updated when some piece is being dragged, but I don't use InvalidateRect() to trigger the redraw. However, how could I implement this in OpenGL? I don't have a back buffer device context and if I did wouldn't I have to use BitBlt() to do the updates which is slow?

Share this post


Link to post
Share on other sites
What exactly is wrong with SwapBuffers()? It's not really that slow, and if you draw only a small part of the screen the speed shouldn't be an issue anyway.

Share this post


Link to post
Share on other sites
My computer is so bad that I can't even run some of NeHe's earlier tutorials(lesson 11 for one). So, I figured this would speed things up a little. Thanks for the link, Hobitz. I'll try that function out.

Share this post


Link to post
Share on other sites
error LNK2001: unresolved external symbol _glAddSwapHintRectWIN@16

Anyone know what .lib file I need to include?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!