Huge lag in voxel engine using lwjgl

ok so what I would do for this is , store all data for the cubes in one big VBO. When you add to the VBO you also have to add your texture coordinates. They are added to the texture buffer in the same position. Im not sure that GL_TRIANGLE_STRIPS would work though.

Wouldn’t instancing be a much better thing to do in this case?
Since all the geometry seems to have the same vertices. With only the texture and position being different.

Instanced cubes will always be slower than precomputed chunks with per-face culling.

Create a level renderer class. When a cube is changed in your level, set flag ‘update’ in your renderer class to true. When it is time to render your level, call renderer.render() method. In render method, do something like this:


if(update) { updateVBO(); update=false; }
renderVBO();

This code will update the VBO when cubes are changed.

updateVBO() method should either make new buffer, or clear existing buffer and upload all the cubes you have in your level. You might also not want to put cubes that don’t make contact with air blocks (empty blocks) into your buffer.