[SDL] SDL_UpdatesRects - how to use it right

Sik the hedgehog sik.the.hedgehog at gmail.com
Fri Mar 15 17:16:52 PDT 2013


Pixel-level collision detection is something for which you'd want to
keep SDL out of it anyway (leave SDL to do the rendering and handle
collision without relying on it). I imagine the collision is done by
looking up the data in the surface?

In any case what I'd do is keep two separate bitmaps: the one used to
render in SDL and the one used for collision (which can be even
optimized for the algorithm!). Yeah, there's some waste of space, but
seems like the easiest way to handle it.

2013/3/15, Nathaniel J Fries <nfries88 at yahoo.com>:
> Pixel-level collision detection might be less simple in SDL 2.0; but aside
> for that it should be a fairly straightforward switch.
>
> However, my recommendation with regards to optimizing SDL_UpdateRects would
> be to check for intersections with other rects each time you add a rect to
> be updated; and then replace that rect with the union of the two rects. Some
> extra pixels might get updated, but far less than the union of all the
> rects.
>
> ------------------------
> Nate Fries
>
>
>
>
>



More information about the SDL mailing list