a question about performance

Hello, first of all, to make things clear, I’m using GNU/Linux, with hardware acceleration (nvidia geforce 7300), and allegro-gl to make the setting up of opengl more simple. I’m learning opengl and already know a few things, but I stumbled upon a problem, which stops me from continuing my learning process. The problem is perfomance. Take a look at this piece of code, which is my displaying function:

while(1){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-20.0f);
glRotatef(anglex,0.0f,1.0f,0.0f);
glRotatef(angley,1.0f,0.0f,0.0f);
glCallList(whoa);
allegro_gl_flip();
glFinish();
if(key[KEY_ESC]) quit();
anglex++;
angley++;
}

I have a model loaded into a call list, as I’ve read that’s the best way to speed things up. Sadly, the model is rotating pretty slow, let alone having 5 rotating models. So I’d like to ask you, what’s the best approach for a drawing function, as I find the clear, add vertexes, add faces, add textures, etc. approach pretty slow. Isn’t there a way that I have the model loaded up, and modify (rotate for example) the model IN the memory of the graphics card?

From your post it is hard to know if the ‘slow’ refer to framerate or rotation speed. If your really have hardware acceleration, your graphic card should handle anything but the most complex models.

If framerate is good, but not your rotation speed :
Increment faster your angles.
even at 60fps it currently needs 6 seconds to do a full turn.
Such calculations should be done independently of the framerate, ie. measure time elapsed since previous frame (dt), and update values accordingly :

double degresPerSecond = 90.0;
angle += dt * degresPerSecond;

Isn’t there a way that I have the model loaded up, and modify (rotate for example) the model IN the memory of the graphics card?

That is done by gl display lists. You don’t rebuld the display list each frame right ?
A modern approach is to use VBO (vertex buffer object) but it may be too complex for you.

Well, with one object the animation is smooth, but when I add 5 objects and rotate them separately, it isn’t so smooth. And should this consume 100% of the CPU? As that’s what’s happening :stuck_out_tongue:

You have a while-loop, that eats up all the processing time, it can get. So, YES, it will consume 100% of your CPU time, as long as you don’t restrict it by yourself (e.g. using a “Sleep” or what else that is on Linux).

Jan.

But well, even though it’s using 100% of the cpu, the drawing of 5 models is WAY slower than 1 model, I’d just like to know what’s the most efficient aproach.

My god, I found out what was wrong with the code… it’s a bit hard to explain, but thank you for all your replies.