[SDL] What does update rects really do???

Rafael R. Sevilla 94-22131 rsevilla at eee.upd.edu.ph
Mon Aug 23 13:44:03 PDT 1999


On Fri, 20 Aug 1999, Daniel Tabuenca wrote:

> 	Just curious as to what update rectangles function really does? If I 
> do writes to the screen buffer (or any other buffer) do these not really get
> written to the buffer until I call SDL_UpdateRect?? If not what really goes on?
> Are they being cached somewhere so that it can all be done at one time (kind
> of like doing a bunch of gl calls and doing gl_Flush() ?? Can I rely on this?
> If I write to the buffer  can I rely on it  not being displayed until I call
> SDL_UpdateRect??? 
> 

Yes, in general.  Rectangle updates are cached because in some systems
updating a large part of the screen in one go is faster than updating
small areas over and over.  This is especially true in X Windows because
of the overhead inherent in the X protocol, and may just as true for
non-DirectX versions of SDL for Win32.  Of course, this function call is
superfluous in systems that allow direct access to the frame buffer, so
any buffer writes are automatically displayed.  But not all systems allow
direct access to the screen, so if you don't SDL_UpdateRect some people
won't see output from your program at all.  I don't think it does harm
when direct access is available, so it's a good thing to do in any case. 
There's also an art of knowing where to place these calls so as to
optimize your display...

------------------------------------------------------------------------
| Rafael R. Sevilla                            rsevilla at eee.upd.edu.ph |
|           Instrumentation, Robotics, and Control Laboratory          |
|    College of Engineering, University of the Philippines, Diliman    |
------------------------------------------------------------------------





More information about the SDL mailing list