Updating spritebatches
Posted: Mon Feb 25, 2013 6:57 am
So I've been implementing sprite batches in my engine in various places, and they're all beautiful and super optimized.
Except when I need to move something in the batch, and strangely enough, binding and unbinding the batch to memory seems to make the update slower. Although I haven't done any extensive tests.
Sprite batches seem to work wonderfully for a lot of cases, but it seems like a really bad choice if most or all your batch items are moving every frame.
So my question is, is there a way to sort of, bind a texture to memory, and draw it over and over wherever I want? Something like:
Because I remember when I was first starting with C++, and drawing a hundred instances of the same image would lag horribly, then I switched to binding the texture once, then drawing thousands of times and it was completely lag free.
It was a pretty simple change. Is something like this already happening under the hood? Thoughts?
Thanks!
Except when I need to move something in the batch, and strangely enough, binding and unbinding the batch to memory seems to make the update slower. Although I haven't done any extensive tests.
Sprite batches seem to work wonderfully for a lot of cases, but it seems like a really bad choice if most or all your batch items are moving every frame.
So my question is, is there a way to sort of, bind a texture to memory, and draw it over and over wherever I want? Something like:
Code: Select all
Image:bind()
draw(x,y,angle)
draw(x2,y2,angle)
...
Image:unbind()
It was a pretty simple change. Is something like this already happening under the hood? Thoughts?
Thanks!