I am working on a game which has a board of falling down blocks, similar to Tetris. Each block is represented with for vertices and two triangles, each vertex consisting out of its location and texture coordinations. I am using glDrawElements
to render the blocks.
I would like to interpolate the location data when blocks fall down. I am wondering, what is the most efficient, elegant and easy way to interpolate such vertex data in OpenGL?
I obviously need two location states (x0 y0)
and (x1 y1)
and a time step t
(0 < t < 1
), then I can lerp in my vertex shader. How do I pass this information to the shader? For the timestep, uniforms came into my mind. But what about the locations?
- Pass both locations to my VBO at any time. This would work, but requires my VBO to be twice as big as it includes both location states, even if they are equal (= the block hasn't moved)! Blocks will move at times, but most of the time, they are static - wouldn't this approach be a wast of memory?
- Keep
(x0 y0)
in the VBO, transmit(x1 y1)
via uniforms if necessary (= if the block has moved). This would save memory, but completely destroy my rendering pipeline. - Anything else? Both of the approaches above seem silly to me. How do other games do this?
Thanks!