I have been having a strange degrading performance issue rendering a simple scene containing two "chunks" of 4x4x4 cubes each.
Video of problem
This is a screen capture showing my console output, look specifically at the FPS dropping (which is the issue).
Details about problem
My machine (a mid-2009 mbp 15") is on average using something like 10% cpu, but the machine is getting very hot to touch so I believe the graphics card is working very hard.
Someone else tested this code on another machine and experienced 100% cpu usage on a quad-core AMD cpu (on one core) and the same kind of performance problem.
I can't quite figure out what's going on, multiple people have looked at this and we are not getting any smarter.
Currently there is no frustum culling or any other sort of culling. I do not think that is the problem, I should be able to render a much much higher number of vertices without experiencing problems.
I have a list of chunks (ArrayList) that is created on start, not within the render loop, that generates a vbo and all that.
In my renderer I loop through the list of chunks and for each one I bind the vbo, setup some uniform variables and such before calling glDrawArrays().
I have a version of this where I only have one vbo (but then also only one cube per vbo/glDrawArrays call, very inefficient) where everything is working fine.
Thoughts and ideas
I believe the problem is something related to either VRAM filling up or me doing something incredibly wrong.
I've tried looking at my project with OSX's OpenGL profiler application, which has given me two different results:
First I was just using glBufferData each frame to pass the data, which resulted in 90% of the gl time spent being spent on CGLFlushDrawable().
After some advice from someone on #opengl on Freenode, it was suggested I should setup the vbo once with glBufferData, and then call glMapBuffer to pass the data after that.
This results in the same performance problem but 99% of the gl time being spent on glMapBuffer().
I was hoping someone had some advice for me, I would really like to just be able to continue learning opengl instead of being stuck debugging this performance issue for weeks.
Code on GitHub
The code is available at https://github.com/flexd/Game/tree/chunkrenderer (specifically the chunkrenderer branch!, you can see that the lighting2 branch works without the same performance issue).
The main game class is Game.java which contains the main method and it's also where I setup OpenGL.
Chunk.java, Cube.java, Renderable.java and ChunkRenderer.java are also of interest. Shader.java is where the shader class lives, but I doubt that has anything to do with the issues, it's basically the same shader as before.
Thanks in advance, I hope to be able to find the issue soon :)
Looking forward to being able to learn more of this.
PS: Let me know if I am posting this in the wrong place, I don't know if there's a opengl category that's better suited for this.