Page 1 of 1

What is a spritebatch?

Posted: Thu Sep 22, 2011 7:44 pm
by iamwil
What is a SpriteBatch? From the reference API, I don't quite get what it is. Googling didn't seem to quite help either. Can anyone explain to me what a SpriteBatch is?

Re: What is a spritebatch?

Posted: Thu Sep 22, 2011 9:00 pm
by miko
iamwil wrote:What is a SpriteBatch? From the reference API, I don't quite get what it is. Googling didn't seem to quite help either. Can anyone explain to me what a SpriteBatch is?
http://love2d.org/wiki/Tutorial:Efficie ... _Scrolling

Re: What is a spritebatch?

Posted: Thu Sep 22, 2011 9:32 pm
by slime
The regular way to draw things onto the screen (using love.graphics.draw) is to send the image and position to the GPU every time you draw anything, even if you're using the same image multiple times in a row. Sending information to the GPU can become a huge bottleneck, especially if that information doesn't actually need to be sent. Spritebatches help with this problem by specifying an image to draw and then saving all the locations you want to draw it at to the GPU's VRAM for use at a later time. Then it only has to send the image once and tell the GPU to use the locations it saved.
This can have huge performance benefits if, for example, you have an image of background tiles, because then you can just make a spritebatch with the image, add the locations of the tile quads, and then draw the entire thing in one go at a later time, using the saved position data, instead of re-sending the image and related data over and over and over.

Re: What is a spritebatch?

Posted: Fri Sep 23, 2011 6:15 am
by iamwil
Ahh, thanks for the explanation. I didn't know it was related to Tile scrolling as well.

Wil