[SDL] UpdateRects sketchy

pchans at wm.edu pchans at wm.edu
Sat Sep 14 14:12:00 PDT 2002


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.

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?

Thanks for the help

p





More information about the SDL mailing list