I'm working on a small 2D voxel engine with chunks and each chunk has a VBO to render. I ran into an issue where I could specify texture coordinates, but I didn't know how to tell the VBO what texture to use for specific parts of the VBO. Is this possible, and if so, what would be the best way to accomplish this?
1 Answers
0
votes
In your case, it seems like the best thing you can do is imitate the system used by Minecraft. You can have a single texture that contains all your sub-textures (http://www.jimmyn.com/tutorials/tut1/minecrafttextures.bmp). Just write a function that calculates texture coordinates based on an index in the grid.
If you really do need to do multi-texturing, you'll have to use shaders. The LWJGL website has a tutorial on this, as well as an introduction to writing shaders: http://lwjgl.org/wiki/index.php?title=Main_Page
A third solution, of course, is just to make one VBO for each texture in a chunk. So a chunk that has two block types would have 2 VBOs, and you can change the texture in between drawing them.