Jump to content
  • Advertisement
Sign in to follow this  
jsloan

SDL_Flip()

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

HI there, Does anybody know how exactly the SDL_Flip() fucntion works? I read the doumentation but it was a bit unclear. If i blit to my back buffer 'pBack' would i call SDL_Flip(pBack) or SDL_Flip(pPrimary) for the primary surface? And if not how does SDL_Flip know which surface is what without the nifty surface descriptor stuff from directdraw?

Share this post


Link to post
Share on other sites
Advertisement
With SDL double buffering, there's no need to create a separate back buffer. SDL does all that internally.

When you created the surface for the actual screen, I'm assuming you used the function call SDL_SetVideoMode(width, height, bpp, flags). If you pass SDL_DOUBLEBUF as the third parameter, SDL will allocate a back buffer for it.

Then when you draw to the screen, you blit to the surface as usual. You will actually be blitting to the back buffer, but SDL takes care of this. Then call SDL_Flip on the same surface, and it'll swap the back buffer with the surface you're updating.

A better explanation of using SetVideoMode and double buffering.

Share this post


Link to post
Share on other sites
The only screen surface you need to concern yourself with is the one returned by SDL_SetVideoMode(), SDL will handle the details of the back buffer internally.

So if you have:


SDL_Surface *Screen = SDL_SetVideoMode(blah);

//some drawing code here

SDL_Flip(Screen);


That's all you need, of course if you want to get really dirty you could look at the implementation of SDL_Flip() in the source code.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!