Tip when you initialize the video in SDL (SDL_SetVideoMode()):
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. If you request SDL_HWSURFACE, then if possible SDL will give you access to the actual video memory being displayed to the screen. If this is successful, the returned surface will have the SDL_HWSURFACE flag set, and you will be able to allocate other surfaces in video memory, which presumably can be blitted very fast. The disadvantage is that video memory tends to be much slower than system memory, so you don't want to write directly to it in most cases. In this case, SDL_UpdateRects() and SDL_Flip() are inexpensive noops, as you are writing to memory automatically being displayed. 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. |
Copyright © 1999-2003 Anders Lindström
Last updated 030808