Re: Is the way Love handles sprites inefficient?
Posted: Mon May 08, 2017 12:22 pm
In other words, before attacking something, make sure you have at least basic understanding of it.
So does that mean that every time I apply an operation to a sprite (in another API, such as a rotation), I'm not actually modifying that sprite, but just changing the way it is drawn? Is that change computed every frame? Again, I just don't understand why having to compute that 60 times a second is more efficient than just saving a copy and computing that one time.Images aren't immutable, just as GL textures aren't, but you try to not really modify them because then you'd have to send the whole texture again.
Yes.
Yes.
Again, it's about tradeoffs. Think about how many different angles you could orient a sprite; if you don't have any restrictions, like the angles needing to be multiples of something (0°, 90°, 180°, 270° for example), then basically, you would need to do, for each angle:
Currently, you should store each value separately, then either use them as parameters for love.graphics.draw (state won't be retained), or if you need to, use the above functions to set the matrix via them (state will be retained until the next frame); there's also love.graphics.origin to reset the whole matrix.
Using the draw function seems not useful either but seems that there is documentation about what i need in:zorg wrote: ↑Mon May 08, 2017 8:28 pm Currently, you should store each value separately, then either use them as parameters for love.graphics.draw (state won't be retained), or if you need to, use the above functions to set the matrix via them (state will be retained until the next frame); there's also love.graphics.origin to reset the whole matrix.
So even if I only have two configurations for a sprite that I ever use (such as a sprite pointing left and right), it's still more efficient to only use one texture, and then just flip it over the x-axis?
Code: Select all
-- instead of
batch:add(quad, x, y, 0, 0, -1)
love.graphics.draw(tex, quad, x, y, 0, 0, -1)
-- do
batch:add(flipX(quad, x, y))
love.graphics.draw(tex, flipX(quad, x, y))