I've finally decided to stop using glBegin/glEnd and start using modern opengl. Right now I'm trying to implement VBOs but I've run into some problems, mainly because I don't understand how to use them correctly. Most tutorials only show how draw a single polygon with them which is definitly not enough for my program.
Here's how I use them right now. I initialize the vbo at startup by calling glGenBuffers(). I can't render my whole world at once because it's too big, so I made a method called addData() which stores vertex, color, normal and texcoord data in a list. Then I've another method, render(), which copies all the data from the list into a FloatBuffer and then clears the list. Finally I upload the data in the float buffer to the vbo and render it by calling glDrawArrays().
Is this a good way to do it? Either way I did something wrong. I tried rendering a simple triangle with this method, and it worked. However something is definitly wrong, because the frame rate is about 8000, which is fine I guess, but I get a few lagspikes every second. The times between each frame looks something like this:
0.1 ms
0.1 ms
0.1 ms
25 ms
0.1 ms
0.1 ms
200 ms
0.1 ms
...
and so on. Any idea what could be causing this?
Another question I have is about transformations. Right now I'm using alot of glPushMatrix(), glTranslate(), glRotate(), glPopMatrix(), etc,
and this works because I use immediate mode rendering. But when I switch to VBO, I won't render inbetween the glPushMatrix and glPopMatrix, only store the vertex data etc, in a list. This will cause everything to be incorrectly transformed when I finally render everything at once. Is it possible to manually multiply the vertices by the current transform matrix before storing the data?
That's all I want for now. Sorry for the huge post. Any help would be greatly appreciated.
