Sign in to follow this  

SwapBuffers()

This topic is 4555 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
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
The function you mentioned is part of an OpenGL extension. Look here.

BTW, this function will most likely do you no good if you are in fullscreen mode.

Share this post


Link to post
Share on other sites
I've included these .lib files but the error will not go away.
glu32.lib opengl32.lib glaux.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Also, why wouldn't this function do any good for fullscreen mode?

Share this post


Link to post
Share on other sites
Quote:
Original post by GosuDrew
I've included these .lib files but the error will not go away.
glu32.lib opengl32.lib glaux.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

Ahem. LOOK HERE.

Quote:
Also, why wouldn't this function do any good for fullscreen mode?

Because to swap buffers in fullscreen mode is usually as simple as changing which buffer the DAC reads from. In contrast, in windowed mode data is actually copied from one buffer to the other.

Share this post


Link to post
Share on other sites

This topic is 4555 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this