Double Buffered Surfaces

Hi everyone,
Sorry if this is a beginner’s question but I would really be grateful to
any reply regarding this matter. As with most applications written with SDL,
there’s a single display surface at a time and any other required number of
surfaces, I construct the image to be displayed on one of these surfaces and
when it’s done, it’s finally blitted onto the display surface. Now, would a
double buffered surface let me do this in a different (easier) way? And is
there any difference in the structure of a double buffered SDL_Surface and a
normal one?

Thanks in advance,
Mahmoud Al Gammal

If you pass the SDL_DOUBLEBUF flag to SDL_SetVideoMode, it will try to
use double buffering. You don’t have to change anything into your code
(you still use the same SDL_Surfaces) excepted that you have to call
SDL_Flip instead of SDL_UpdateRect(s) in order to refresh your display
surface. Note that SDL_Flip is also valid when in non-double buffered
mode, it will simply refresh the entire screen surface. Double buffering
is only possible with a few drivers (it doesn’t work with X - you should
be able to do it with most “fullscreen” driver, like fbcon or DirectX).
If you pass the SDL_DOUBLEBUF flag to SDL_SetVideoMode and double
buffering isn’t possible, it won’t be used, but your program will still
work.

More details available in the SDL documentation.

Alex.On 06 Sep 2001 03:47:47 +0300, Mahmoud Al Gammal wrote:

Hi everyone,
Sorry if this is a beginner’s question but I would really be grateful to
any reply regarding this matter. As with most applications written with SDL,
there’s a single display surface at a time and any other required number of
surfaces, I construct the image to be displayed on one of these surfaces and
when it’s done, it’s finally blitted onto the display surface. Now, would a
double buffered surface let me do this in a different (easier) way? And is
there any difference in the structure of a double buffered SDL_Surface and a
normal one?

“Mahmoud Al Gammal” writes:

Hi everyone,
Sorry if this is a beginner’s question but I would really be grateful to
any reply regarding this matter. As with most applications written with SDL,
there’s a single display surface at a time and any other required number of
surfaces, I construct the image to be displayed on one of these surfaces and
when it’s done, it’s finally blitted onto the display surface. Now, would a
double buffered surface let me do this in a different (easier) way? And is
there any difference in the structure of a double buffered SDL_Surface and a
normal one?
AFAK double buffering works the exact same way, actually, you don’t
need to blit to an off-screen surface, and then finally blit to the
screen surface before display - SDL handles all that for you. Don’t
you just love the world without DirectX ;-)–
Best Regards / Venlig Hilsen
Rasmus Toftdahl Olesen
halfdan at halfdan.dyndns.org
http://halfdan.dyndns.org