Anyone knows how to properly render a 2d tile map using VBO?
For example, I have a 16x12 tiled map. There are 4 different tiles. Each tiles has it's own color handle or color buffer.
When I want to render with specific color, all I do is point opengl to my color handle and everything is fine.
The problem comes when I need to point openGL to vertices. How do I do that? With immidiate mode that's pretty simple: tell openGl where vertices are where you want and it renders it.
But how do I do it with VBO? When I start my program, I create a vertex buffer with these coordinates:
This gives me a square of 50x50 pixels and it is rendered at top left of the screen. (I setup my display to be like java2d.)
But how do I tell opengl I want to render that square to somekind of an offset? I can translatef, but that takes away 1000fps when rendering a 16x12 map! What if had 40x30 for example? My fps would go down to 500 or less IDK.
So how do I tell opengl to render at an offset? Or do I need to change my rendering pipeline? Like store whole map into a single VBO and render that single vbo?
I have another idea: I recently took a basic look at shaders and now I have a question: Would I be able to change position of every vertex that goes into opengl by a value I send to shaders? For example I tell opengl to render a square at basic coordinates I have written in the post, and with shaders to add some kind of offset to all the vertices?