Harry wrote:
What exactly is a texture atlas? Is it just an image/spritesheet of lots of images? Why do you begin/end with it?
That is exactly what it is.
The begin/end stuff is needed due to the way openGL works, normally you need to tell it when to start a task and when to end it, these operations is a bit expensive and a waste if you are drawing the same image many times, such as when drawing the sub-Images of a texture atlas, where you draw the parts of an image.
When you draw your image with the normal draw method, it tells openGL to start and end the task of drawing the image every time its drawn.
drawEmbedded doesn't call the begin and end methods, so when you beginUse/drawEmbedded/endUse you control yourself when to tell openGL to start and end the task.
Here's an example of what happens.
This code:
Code:
image.draw(x, y);
image.draw(x, y);
image.draw(x, y);
Is the same as this:
Code:
image.beginUse()
image.drawEmbedded(x, y)
image.endUse()
image.beginUse()
image.drawEmbedded(x, y)
image.endUse()
image.beginUse()
image.drawEmbedded(x, y)
image.endUse()
But if you control it yourself, it could look like this:
Code:
image.beginUse()
image.drawEmbedded(x, y)
image.drawEmbedded(x, y)
image.drawEmbedded(x, y)
image.endUse()
This way is faster, especially if you are drawing the image alot of times.