[SDL] UpdateRects sketchy

Kylotan kylotan at kylotan.eidosnet.co.uk
Sun Sep 15 05:50:01 PDT 2002

Nick Whitelegg wrote:
> Is this always the best solution though? I haven't got round to
> experimenting, but say you had a 2D game where there were a number of
> moving sprites plus various (occasionally only updated) status info
> like score and lives. What I tend to do (e.g. for my ZXLIB C++ game
> library) - and, like I said,
> I haven't tested this yet - is use UpdateRects() for the sprites (as
> they move each time) but, for the scores, just blit them and update
> them as needed as they are only occasionally updated. Otherwise (I'm
> using the STL vector container to store my update rects) I'd have to
> add in the score update rectangle to the list of update rectangles
> each time I want to update it, do the updating with UpdateRects(),
> then remove the score update rectangle from the list of "dirty"
> rects. At a guess, this seems slower but I may be wrong?

I doubt there's going to be a speed bottleneck in the collecting up of
the rectangles, and I expect most people change the list of dirty rects
each frame anyway. Compared to the actual updating, changing the list
around is trivial. I expect that on some platforms you might incur some
sort of penalty for calling UpdateRects twice per frame rather than
once, although I can't be sure of this. And if you're keeping the sprite
rectangles constant (in number, at least) then pushing and popping the
scores on the end of the std::vector on occasion is a very cheap


More information about the SDL mailing list