[SDL] UpdateRects sketchy

Darrell Walisser walisser at mac.com
Sun Sep 15 09:34:02 PDT 2002

On Saturday, September 14, 2002, at 05:07 PM, pchans at wm.edu wrote:

> On Saturday, September 14, 2002, at 03:43 PM, Darrell Walisser wrote:
>> You shouldn't be using SDL_UpdateRect() to do multiple dirty rects 
>> per frame, as the cost of SDL_UpdateRect() is very - dare I say 
>> *extremely* - high. The reason is that each time you call 
>> UpdateRect() or UpdateRects() or Flip(), the window server copies the 
>> region you specified to the display, in sync with the retrace of the 
>> monitor (VBL), and possibly involving compositing if the window is 
>> occluded. Even if there is no compositing required, just the sync 
>> with the VBL causes a huge hit while the CPU is idle waiting for the 
>> CRT beam to go by.
> Yes, I am planning on using UpdateRects down the road, but I am still 
> perplexed by why UpdateRect does not work.  My test program catches 
> mouse events and blits a sprite at the click position.  I'm not 
> interested in efficiency -- I just want the picture to draw, and it 
> doesn't do so every time I click.

This would appear to be an error in your program. Try using the 
QuartzDebug application in /Developer/Applications to see visually what 
rectangles you are passing to UpdateRect().

> Is UpdateRect(screen, 0, 0, 0, 0) optimized so it will be faster than 
> updating a rectangle covering the majority of the screen?  That is, 
> will it buy me any efficiency beyond a good algorithm for joining 
> overlapping dirty rectangles?

Yes. If you are going to update the entire screen (or almost the entire 
screen), the advantage of managing dirty rectangles usually becomes 

More information about the SDL mailing list