So, for last couple of days I have started on getting some experience with OpenGL 3D programming. I am using LWJGL for Java. I have created a 3d camera class with fps-movement. I also created a cube with VBO’s. I can render this without any problems.
Now, how can I draw this same VBO on another position? Now my cube is on (0, 0, 0), and goes to (5, 5, 5). What if I want to draw this same cube at (10, 10, 10) to (15, 15, 15)?
Thanks!
Pass the cube’s position vector as an
uniform vec3variable to the vertex shader. There, add it to each vertex’s position.If you want to draw hundreds of those, you can save some performance using instancing. Set up one per-vertex attribute for vertex position, and one per-instance attribute (via
glVertexAttribDivisor= 1) for each instance’s translation. See this wiki entry for details.