rotation smoothness

Hey all,

I’ve had this problem for sometime and now I’m hitting it again to see if I can fix it this time.

Does anyone know how glutWireTeapot() is drawn? Does it use vertex arrays or display lists? It rotates so incredibly smooth in my canvas, yet when I draw and rotate my model, it’s just sort of slow, not stuttering, but it’s like watching a very old 1930’s hollywood movie that had like 5 frames a second. A consistant jerkiness to it.

I am no longer updating any components outside of my GLCanvas like JLabels used to mark x & y coords and I can’t use display list because as I understand, they are for static content and I have selection going on in my model where I highlight elements that my mouse hovers over.

One thing I’m wondering about is that everytime display() is called (which is every time I drag my mouse, and that can be a lot for each mouseMove()), I loop through a HashMap of several thousand elements (usually triangles). Below is a simplified code snippet of what would happen for each display (mouseMove). Node that myList is usually 4000 in size. Also, display() is called not just once for each mouseMove, but twice, the second time is for doing selection.

Ex. drawing my model by a call from display()


vBuffer = BufferUtils.newFloatBuffer(3 * 3);

Iterator eKeyIter = myList.keySet().iterator();
while (eKeyIter.hasNext()) {
   idx = 0;

   Edge currentEdge = (Edge) myList.get(eKeyIter.next());
   ...
   Edge nextEdge = (Edge) myList.get(nId);

   for (int i = 0; i < 3; i++) {
      switch (i) {
      case 0:
         point = (MyPoint) nodes.get(currentEdge.getStartVertexId());
         break;

      case 1:
         point = (MyPoint) nodes.get(currentEdge.getEndVertexId());
         break;

      case 2:
         point = (MyPoint) nodes.get(nextEdge.getEndVertexId());
         break;
      }

      vBuffer.put(idx++, (float) point.getX());
      vBuffer.put(idx++, (float) point.getY());
      vBuffer.put(idx++, (float) point.getZ());
   }

   gl.glVertexPointer(3, GL.GL_FLOAT, 0, vBuffer);

   gl.glBegin(GL.GL_TRIANGLES);
   gl.glDrawArrays(GL.GL_TRIANGLES, 0, 8);
   gl.glEnd();
}

Any help much appreciated.

It is rendered with patches via the use of evaluators. See src/classes/com/sun/opengl/utils/GLUT.java.

Have you tried simplifying your rendering loop (i.e., removing the selection code and just sending down the geometry into a vertex array) to see where the bottleneck is?

What are you doing in your mouse callbacks? You can’t perform OpenGL rendering from them directly (unless you manually make the context current and release it from within your callback, not recommended), but must instead set up state and call display() or repaint() which will cause the component to be redrawn.