Hey guys,
I'm working on a little 2D framework (I usually do 3D stuff so I'm not too sure how some things should be handled in 2D). My question is how to handle animation of tiles (eg. Water) which are stored in a vertex buffer with the rest of the grass (terrain) tiles. Basically I have a map which can be represented like so in a text file:
1 1 1 1
1 1 2 1
1 1 2 1
1 1 1 1
Each number represents a different type of tile, and a tile is basically a texture coordinate (bottom left) for the location of the tile in the texture atlas and a number representing the size of a tile (eg 1.0f / 16.0f, because my atlas is 2048x2048 and I have 16 tiles in a row).
struct Tile
{
float m_tileSize;
glm::vec2 m_texCoord;
};
My vertex buffer is constructed by iterating through two for loops (one for width and height of map) and constructing the vertices for each quad, and using the texture coordinates of the corresponding tile in that position.
I want to expand my tile class so it can contain animation information, and because i'm using a texture atlas (and not drawing each tile separately) I cant just swap the texture for animation, I must update the texture coords. I'm not sure if it is a good idea to update this VBO each frame, to modify texture coordinates for animated tiles. This sounds like premature optimisation to me, even if so, i'd like some advice on how other people handle animation like this?
Thanks guys






