howto smooth model rotation?

I have a model (wire mesh, lots of triangles) that when I rotate it … it just doesn’t rotate smoothly. What I thought needed to be done is make the angle to the glRotatef func smaller as well as the axis value smaller. I thought this would make it move smoother, so it sort of does, but it just slows the rotation down way to much.

My glRotatef commands have values like …

glRotatef(2.0, 1.0, 0.0, 0.0);
glRotatef(2.0, 0.0, 1.0, 0.0);
glRotatef(2.0, 0.0, 0.0, 1.0);

And if I make the angel or values smaller (thinking the model won’t jump as much when it rotates), then it just moves way too slow and I need it to move faster, yet smooth.

I’ve seen this same wire model rotate in an app that is written in C and it moves so smooth and fast, not jerky.

Any ideas how to fix this?

Using smaller values for the components of your axis won’t have a significant effect; it is only a hint to OpenGL of the direction of rotation and is probably normalized behind the scenes. Decreasing the angle value should change the rate of rotation. Are you seeing stuttering every now and then, or simply slow rendering performance? Are you using vertex arrays or display lists to render the model, or are you making lots of immediate-mode calls like glVertex3f? Immediate-mode calls are inefficient. Do you have any other widgets in your component hierarchy aside from your GLCanvas? If you do and you’re updating those widgets, they can cause repainting by the AWT which can interfere with the performance of your OpenGL rendering.

No, it’s not the occasional stuttering every now and then. It’s slow rendering performance that I’m seeing. I’m using vertex arrays to render as I iterate through a HashMap of objects that hold x, y, z values (my triangles). And I have lots of other widgets to the sides of my GLCanvas that do not get updated with the exception of two JLabels that show the X and Y coordinates of the mouse on the canvas. Is that a big problem?

Try not updating the JLabels. Does that improve performance?

Another JOGL user found that updating JLabels alongside a GLCanvas (at least in earlier versions of the JRE; not sure about current versions) was causing re-layout of all of the components in the frame, which was very expensive. Also, if you’re on Windows, are you running with -Dsun.java2d.noddraw=true?