Search code examples
c++openglvoxel

OpenGL voxel engine slow


I'm making a voxel engine in C++ and OpenGL (à la Minecraft) and can't get decent fps on my 3GHz with ATI X1600... I'm all out of ideas.

When I have about 12000 cubes on the screen it falls to under 20fps - pathetic.

So far the optimizations I have are: frustum culling, back face culling (via OpenGL's glEnable(GL_CULL_FACE)), the engine draws only the visible faces (except the culled ones of course) and they're in an octree.

I've tried VBO's, I don't like them and they do not significantly increase the fps.

How can Minecraft's engine be so fast... I struggle with a 10000 cubes, whereas Minecraft can easily draw much more at higher fps.

Any ideas?


Solution

  • You should profile your code to find out if the bottleneck in your application is on the CPU or GPU. For instance it might be that your culling/octtree algorithms are slow and in that case it is not an OpenGL-problem at all.

    I would also keep count of the number of cubes you draw on each frame and display that on screen. Just so you know your culling routines work as expected.

    Finally you don't mention if your cubes are textured. Try using smaller textures or disable textures and see how much the framerate increases.

    gDEBugger is a great tool that will help you find bottlenecks with OpenGL.