[SDL] Persistent surfaces

David Olofson david at olofson.net
Tue Nov 22 09:33:59 PST 2005

On Tuesday 22 November 2005 17.39, Jeremy Kronuz wrote:
> However, I was thinking, shortly after my first message, what about
> double or triple buffered?

This affects only the display surface.

> will I still get the same content (if no surface is  
> lost) even when the memory has switched from the back buffer to the
> display?

Yes, as long as you're dealing with other surfaces than the display 

Now, the display surface OTOH, is problematic! Basically, what happens 
with the display surface buffer when you Flip() depends on a lot of 
stuff, such as OS, hardware, driver, video mode and possibly other 

What's even worse is that you cannot reliably tell what kind of setup 
you have, since some APIs are basically ignoring the problem and just 
have the drivers do it any way they like.

Unless you're building turn-key systems, the best you can do is ask 
the user (ie set up a double buffered display with potentially out of 
sync buffers, flip some and ask "Do you see any flickering on the 
screen right now? [Yes/No]"). The easiest way is to work around the 
problem by assuming that the behavior is undefined and always repaint 
the whole screen before flipping.

> or how does it work, I'm not sure how all this works, and it's vital
> for my project to be 100% sure the content in the surface won't be
> lost (or when exactly is going to be lost)

If it's vital that you know in *advance* when it may happen, I think 
you're in some serious trouble... It's beyond your control, and all 
you can do is deal with it when you discover that SDL_BlitSurface() 
fails. It doesn't necessarily happen as a result of something the 
application does, but can happen when the user switches to another 
application, for example.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
|  Free/Open Source audio engine for games and multimedia.  |
| MIDI, modular synthesis, real time effects, scripting,... |
`-----------------------------------> http://audiality.org -'
   --- http://olofson.net --- http://www.reologica.se ---

More information about the SDL mailing list