2

SDL_RenderCopy only accepts a single input rectangle and a single output rectangle. But if I have a lot of images that I want to be filled, my knowledge of opengl tells me that a bulk operation that draws all images at once can be much faster than one draw call per sprite. SDL_FillRects is already there with a count parameter. But I cant find anything suitable for drawing a lot of sprites.

Is there some function in SDL2 that I am still missing, because I doubt that this optimization can be done automatically.

Arne
  • 7,921
  • 9
  • 48
  • 66
  • It wouldn't make any benefits because OpenGL (which SDL2 uses as hardware acceleration backend) can't perform this operations at once (unless your textures are atlased - which is really hard to perform in full-automatic mode. – keltar Dec 05 '13 at 15:32
  • It is not that hard, just take my array of src rectangles as the texture atlas, or else if the src rectangles are null, draw the entire source surface several times. I don't think that it would be hard. – Arne Dec 05 '13 at 15:40
  • Atlas is single huge image. It is too costly to re-create it on each possible draw. Or are you talking about drawing the same texture many times on different places? – keltar Dec 05 '13 at 15:50
  • 1
    There's work in progress being done to support something like this, it'll probably look like the SDL_RenderGeometry function that you can see here: https://bitbucket.org/gabomdq/sdl-1.3-experimental/src/c2840e388946968b55b3987d3594d9ff5e9a3a80?at=RenderGeometry – gabomdq Dec 05 '13 at 16:47
  • @gabomdq thank you very much. I've looked up the source of SDL_FillRects so far, and even that isn't implemented as I hoped it would be. But luckily there is still some work in progress. – Arne Dec 05 '13 at 18:43
  • @keltar I can't imagine how you came on the idea that I want it recreate every frame. Just one source and one target texture and a lot of pairs with src Rect and dst Rect – Arne Dec 05 '13 at 18:47

0 Answers0