[SDL] Re: Scaleing, SDL_DOUBLEBUF, SetVidMode, etc.....

Randi J. Relander relander at geocities.com
Fri Apr 14 07:45:33 PDT 2000


Sam Lantinga wote:

> If you request SDL_SWSURFACE, then you get a video
> buffer allocated in system memory, and you must call
> SDL_UpdateRects() or SDL_Flip() to update the screen.
> SDL_Flip() calls SDL_UpdateRects(the-whole-screen) in
> this case.  All allocated surfaces will be in system memory
> for blit speed.

[ snip ]

> If you request SDL_HWSURFACE, you may also request
> double-buffering by adding the SDL_DOUBLEBUF flag.
>  If possible, SDL will set up two buffers in video memory for
> double-buffered page flipping.  If this is successfully set up,
> then you will be writing to the non-visible back-buffer, and
> when you call SDL_Flip(), SDL will queue up a page flip for
> the next vertical retrace, so that the current video surface
> will then be displayed, and the front and back video buffers
> will be swapped.  The next display surface lock will block
> until the flip has completed.

Does it make sense to have SDL_SWSURFACE | SDL_DOUBLEBUF support? If
something is written that makes use of the fact that the back buffer should
contain the contents of frame(n-2), it will fall apart if it can't get both
hardware surfaces and double buffering. I guess this would require two
software surfaces where SDL_Flip() dumps the active one to the physical
screen and then alternates between the two.

This may be a moot point anyway. Are there any double buffered dirty
rectangle algorithms out there? Double buffering works great but I hate
starting from a blank slate after each flip. I would also hate to special
case a complicated dirty rectangle system depending on the available
hardware or the state of SDL_FULLSCREEN.

On a related note, has anyone come across the need for triple buffering
(SDL_TRIPLEBUF?) where you have frame(n-2) on the screen, frame(n-1) waiting
for the vertical retrace, and frame(n) being created (based on the contents
of frame(n-3) <ack>)? Some applications actually use quadruple buffering but
I have not seen any benchmarks on quad versus triple buffering and have seen
relatively little on the "real" advantages of going from double to triple
buffering.

- Randi

Regimental Command
Generic Armored Combat System
http://www-users.cs.umn.edu/~relander/regcom/index.html






More information about the SDL mailing list