I am developing a tilemapping game engine and I have a CPU handled lighting like minecraft not smooth lightning (on the left):
I need to change the color of each tile when light updates or when light is updated. Right now, I am using this to to color and translate the vbo:
GL.BindTexture(TextureTarget.Texture2D, tile.states[tile.animationstate]);
GL.PushMatrix();
GL.Translate(position.X, position.Y, 0);
GL.Color3(col);
GL.EnableClientState(ArrayCap.VertexArray);
GL.EnableClientState(ArrayCap.TextureCoordArray);
GL.BindBuffer(BufferTarget.ArrayBuffer, tile.vbo);
GL.VertexPointer(2, VertexPointerType.Float, Vertex.SizeInBytes, 0);
GL.TexCoordPointer(2, TexCoordPointerType.Float, Vertex.SizeInBytes, Vector2.SizeInBytes);
GL.DrawArrays(PrimitiveType.Quads, 0, 4);
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.PopMatrix();
GL.Color3
(equivalent to glColor3f
) and the game performance is getting from 1000 fps to 830 fps. How can I change the color of the tiles dynamically?
There isn't a vbo for each tile of the map. Each tile image has it's vbo and texture and the map is an int[,]. The value of the map in the location is used in a array of tiles:
Render(map.tiles[map.level[x, y]]);
I already tried using GL.SubBufferData
but doing it 4 times each drawcall for rendering a tile decreased the fps to 74. I would not like to use GL.ColorPointer
because there isn't a vbo for each tile being drawn.