Using VBO

Started by Skatty, June 15, 2013, 16:08:15

Previous topic - Next topic

Skatty

Hello

Can somebody help me figure out VBO idea. How it work? I wanna do something like minecraft clone. So i have to define 1 VBO for each block(built from triangles and using texture) or just 1 VBO for them all and only change somehow texture?

quew8

Minecraft divides the world into chunks, each occupying an 128 * 128 * worldDepth volume. This makes it easier to do the dynamic world loading (loading the area you walk into, unloading the area you walk out of) and is a good size to make a vbo. Use one vbo per chunk. As for the texture, you have two options that are really sort of the same.

1) Use a texture sheet. This is one 2D texture divided up into areas with each area containing one image. Use texture coords to get the right image.

2) Use a texture array (OpenGL 3.0+ only). Which is "like" an array of textures. I have never used them but I believe the idea is that you use the 3rd texture coord to specify which texture in the array to use. Generally the above is easier and requires smaller VBOs (only 2 tex coords). Only use this method if you are using very high resolution images and it would exceed the max texture size to put several of them together. 

quew8

Also this wiki book http://en.wikibooks.org/wiki/OpenGL_Programming contains a section talking you through creating "GlesCraft" which is a Minecraft clone. It is a tutorial aimed at beginners so you might want to check it out.

Again, I haven't read it so I don't even know if it uses VBOs or not but other items there that I have read seem very good.