I have a world made of many cubes (like in Minecraft), they have only color (not texture). I am rendering them using OpenGL 3.3 core profile (GLFW3, GLAD, GLM). I am already have done some optimizations:
- using one VBO for all cubes
- not rendering internal faces
- not rendering faces that can't be visible from camera
- rendering faces using
GL_TRIANGLESand indexing
But it's still slower than Minecraft with Optifine, but Minecraft is in Java and blocks have textures, there is bigger world (there are entities etc. too)! How can I optimize my program further? I want to make it playable on sloooow machines too :).
Edit:
I think I might do some work with threading, but I don't know what should different threads do.
Edit 2:
It may be something with pre-computing too. Player rarely change the world (only small part of ticks).
Edit 3:
Maybe geometry shader can help?
Edit 4:
I am filtering faces with this code:
// for every block if (blocks[x][y][z] != nullptr) { // nullptr means that block is air bool drawSides[6]; if (camera.pos.z > blocks[x][y][z]->pos.z * BLOCK_SIZE || world.GetBlockAt(BlockPos(x, y, z - 1)) != nullptr) drawSides[0] = false; // don't draw that side else drawSides[0] = true; // draw that side // other 5 sides blocks[x][y][z].draw(sides); }