GLDrawable vs GLAutoDrawable (jogl-JSR-231 beta 01)

I have noticed that jogl has a jsr-231 beta 01 build, and I have
some questions:

  1. In the previous version, my program like this:
    public class Demo extends Frame implements GLEventListener {
    public void init(GLDrawable drawable) {
    GL gl = drawable.getGL();
    gl.glShadeModel(GL.GL_SMOOTH);
    gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    gl.glClearDepth(1.0);
    gl.glEnable(GL.GL_DEPTH_TEST);
    }
    public void reshape(GLDrawable drawable, int x, int y, int width, int height) {
    GL gl = drawable.getGL();
    float h = (float)height / (float)width;
    gl.glViewport(0, 0, width, height);
    gl.glMatrixMode(GL.GL_PROJECTION);
    gl.glLoadIdentity();
    gl.glFrustum(-1.0f, 1.0f, -h, h, 2.0f, 60.0f);
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();
    }
    public void display(GLDrawable drawable) {
    GL gl = drawable.getGL();
    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glFlush();
    }

    public void displayChanged(GLDrawable drawable, boolean modeChanged,
    boolean deviceChanged) {}
    }

In the jsr-231 version, there is a GLAutoDrawable class which extends GLDrawable, what is the difference between them? Should I use GLAutoDrawable instead of GLDrawable?

  1. It seems that GLAutoDrawable only has a getGL() method, but
    hasn’t a getGLU() method, how can I get the GLU object?

Thanks!

Basically when transitioning from the previous JOGL (1.1.1) to the current JSR-231 APIs you should replace all references to GLDrawable with GLAutoDrawable. In the JSR-231 API, GLDrawable is a lower-level concept, and GLAutoDrawable is the interface which supports the high-level GLEventListener callback mechanism. This will be documented better in the future.

In the new APIs you simply call “new GLU()” at any point in your program. You can invoke any of the methods on this object which actually call down to OpenGL at any point where an OpenGL context is current (for example, when your GLEventListener’s callback methods are active on the stack). It isn’t guaranteed that the GLU implementation is thread-safe so you should create a new instance for (for example) each of your GLEventListeners.