SwapBuffers()

Started by
12 comments, last by GosuDrew 18 years, 9 months ago
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?
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.
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.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
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?
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.
Quote:There is no equivalent functionality provided in OpenGL, but you could implement it yourself.


How about glAddSwapHintRectWIN()?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc01_16zy.asp
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.
Quote:Original post by Hobitz
How about glAddSwapHintRectWIN()?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/glfunc01_16zy.asp


You learn something new every day.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
error LNK2001: unresolved external symbol _glAddSwapHintRectWIN@16

Anyone know what .lib file I need to include?
Do a binary search in all your libs.

This topic is closed to new replies.

Advertisement