The Tutorials on this site are really damn well done. short and to the point usually.
I am currently studying VBOs VAOs. I decided to use Cubes like minecraft, to study with.
After I create a VBO.
I understand how to Display the first object but,
How do I display new copies of the object on screen multipul times?
while retaining the ability to modify those objects later.
thats what I can not find.
((EDITED TO SIMPLY THE QUESTION))
After I create a VBO.
How do I display new copies of the object on screen multiple times?
while retaining the ability to modify those new copy objects later.
Can someone list a few functions i need to study about.
I know how to draw the first VBO to screen.
but I dont know how to effeciently make a second, third forth, fifth object on screen.
Does it have something to do with
vboVertexHandle = glGenBuffers(); ?
then if I create many handles, ?
What is an object? You are not drawing the buffer object, its simply a container for data that happen to be in a format that OpenGL can use. If you mean you want to render more than one cube, then ask yourself. How did you render that one cube? You put its vertices into a FloatBuffer. So logically you would put more vertices into that FloatBuffer correct?
Its very easy to render small scene looking like minecraft.
You just slap all the vertices into 1 vbo and render it…
The tough part would be making infinite terrain like minecraft to render properly.
Imagine you’ve got your VBO, and you’ve put the data in that VBO to render, say, a single cube, at 0,0,0.
You can draw that VBO over and over again by calling glDrawElements, but of course, they’ll all be in the same place, and look exactly the same.
To position the cube in different places, you want to then call glTranslate:
glPushMatrix();
glTranslatef(x, y, z);
glDrawElements(...);
glPopMatrix();
This is not really the fast way of doing things, as each call to gl tends to slow things down for various reasons I won’t go into here.
The next most sensible thing to do is actually to write the data for each cube into the VBO. You don’t just have 1 cube in the VBO that you want to render in 16 places; you actually need to write 16 cubes’ worth of data, each with different coordinates.
And finally one day when you’re all clued up you can probably try something called “instancing” but that involves modern OpenGL techniques and shaders, and I’d tell you all about it if I had actually used it myself yet, but because my world is made of sprites, I’ve not come across the need…