Best way to drawn a partially occluded Sprite


Hello, new dev learning the ways of version 2 here. :slight_smile:

I’m drawing a texture into a renderer using SDL_Rect as the destination parameter of SDL_RenderCopy, after which SDL_RenderPresent is used to plot everything to the screen. (which I guess makes it double buffered)

Suppose however that the left corner of that texture is outside the renderer boudary but its length goes into it, making its right side required to draw. I don’t think making SDL_Rect.x negative would work, so I see 2 possible solutions:

  1. trim it manually (add to .x to get to the first visible pixel), which would require checking each and every sprite in this situation;

  2. compose the entire scene in a slightly larger renderer(or texture? surface?) then use the source parameter to trim to the size of the screen. Which should be able to be done with double buffering but my concern is that under the hood it would actually be a “triple buffer”, making it inefficient.

Please advise.



no need, use signed int and let the positions go negative


True… I ended up trying it and it did work.