JOGL 2.0 doesn't give me GL3

I can not get GL3 on my ATI 4800 series card in Linux using the proprietary ATI Catalyst 9.8 drivers released on the 17th August 2009.

Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Not a GL3 implementation
	at com.sun.opengl.impl.gl2.GL2Impl.getGL3(GL2Impl.java:24139)
	at rasterizer.Rasterizer.init(Rasterizer.java:52)
	...

Where Rasterizer.java:52 is final GL3 gl = drawable.getGL().getGL3(); in public void init(GLAutoDrawable drawable)

public abstract class Rasterizer extends GLCanvas implements GLEventListener {
	public Rasterizer() {
	}
	/**
	 * Initialization of the OpenGL state machine, 
	 * is done once when the GLAutoDrawable is created.
	 * 
	 * @param drawable The OpenGL context.
	 */
	@Override
	public void init(GLAutoDrawable drawable) {
		final GL3 gl = drawable.getGL().getGL3();
		
		//Set clear color to opaque black
		gl.glClearColor(0.0f,0.0f,0.0f, 0.0f);
		//Enable OpenGL state machine with z-buffer
		gl.glEnable(GL3.GL_DEPTH_TEST);
		gl.glEnable(GL3.GL_CULL_FACE);
	}
	...

I am using:
jogl.all.jar
jogl.awt.jar
jogl.cg.jar
jogl.core.jar
jogl.gl2.x11.jar
jogl.gl2es12.x11.jar
nativewindow.all.jar
nativewindow.awt.jar
nativewindow.core.jar
nativewindow.x11.jar

libjogl_cg.so
libjogl_gl2.so
libjogl_gl2es12.so
libnativewindow_awt.so
libnativewindow_jvm.so
libnativewindow_x11.so

Which I simply add to a Frame object. It works perfectly fine for GL2, is there anything I am missing or any additional routines I need to call before I can use GL3?

put this into your Rasterizer() constructor:

super(new GLCapabilities(GLProfile.get(GLProfile.GL3)));

(or better pass the capabilities as param through the constructor to be more flexible)

regardsing the jars… you only need the following to have a complete JOGL distribution (you have some redundancies):

jogl.all.jar
nativewindow.all.jar
newt.all.jar
gluegen-rt.jar

and this are the natives:

libgluegen-rt.so
libjogl_cg.so
libjogl_gl2.so
libnativewindow_awt.so
libnativewindow_jvm.so
libnativewindow_x11.so
libnewt.so

Thank you for your help, it is greatly appreciated.
Now it works excellently. I am however wondering, why would I want to pass the capabilities like public Rasterizer(GLCapabilities), when I do drawable.getGL().getGL3(); I am bound to have GL3 capabilities anyway and all the OpenGL code would be in OpenGL 3.1+ and incompatible with previous versions anyway, right…?

just thought you would like to enable anti aliasing or something like that in future.

I had no idea you had to do something with GLCapabilities in order to enable anti-aliasing.
Does there exists any documantation over the JOGL specifics and howto use JOGL other than the API Specifications.
I and probably many other people along with me have no idea how to enable anti-aliasing and probably many other settings that can be useful.

I looked in the demos though they are rather old and the API but can not find anything about anti-aliasing.

The demos have been all ported to JOGL2 and most of them work already with the beta. If you are using NetBeans give the OpenGL plugin a try which provides all jogl demos and NEHE tutorials as ready to run projects. (javadoc everything is automatically set up for you)

Just search for “multisample” in the jogl demos.

Setting up jogl isn’t very difficult, once you have seen a sample it is usually everything you need to get started.


package org.yourorghere;

import com.sun.opengl.util.Animator;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL2;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.media.opengl.glu.GLU;


/**
 * @author Brian Paul
 * converted to Java by Ron Cemer and Sven Goethel, ported to JOGL2 by Michael Bien
 *
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */
public class SimpleJOGL2 implements GLEventListener {

    public static void main(String[] args) {

        Frame frame = new Frame("Simple JOGL Application");

        // OpenGL 2.x
        GLCapabilities capabilities = new GLCapabilities(GLProfile.get(GLProfile.GL2));
        GLCanvas canvas = new GLCanvas(capabilities);

        canvas.addGLEventListener(new SimpleJOGL2());
        frame.add(canvas);
        frame.setSize(640, 480);

        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                // Run this on another thread than the AWT event queue to
                // make sure the call to Animator.stop() completes before
                // exiting
                new Thread(new Runnable() {

                    public void run() {
                        animator.stop();
                        System.exit(0);
                    }
                }).start();
            }
        });

        // Center frame, open and start rendering
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }

    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
//        drawable.setGL(new DebugGL2(drawable.getGL().getGL2()));

        GL2 gl = drawable.getGL().getGL2();
        System.err.println("INIT GL2 IS: " + gl.getClass().getName());

        // Enable VSync
        gl.setSwapInterval(1);

        // Setup the drawing area and shading mode
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL2.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL2 gl = drawable.getGL().getGL2();
        GLU glu = new GLU();

        // avoid a divide by zero error!
        if (height <= 0)
            height = 1;

        final float h = (float) width / (float) height;
        gl.glViewport(0, 0, width, height);
        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();

        glu.gluPerspective(45.0f, h, 1.0, 20.0);
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();
    }

    public void display(GLAutoDrawable drawable) {
        GL2 gl = drawable.getGL().getGL2();

        // Clear the drawing area
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
        // Reset the current matrix to the "identity"
        gl.glLoadIdentity();

        // Move the "drawing cursor" around
        gl.glTranslatef(-1.5f, 0.0f, -6.0f);

        // Drawing Using Triangles
        gl.glBegin(GL2.GL_TRIANGLES);
            gl.glColor3f(1.0f, 0.0f, 0.0f);    // Set the current drawing color to red
            gl.glVertex3f(0.0f, 1.0f, 0.0f);   // Top
            gl.glColor3f(0.0f, 1.0f, 0.0f);    // Set the current drawing color to green
            gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
            gl.glColor3f(0.0f, 0.0f, 1.0f);    // Set the current drawing color to blue
            gl.glVertex3f(1.0f, -1.0f, 0.0f);  // Bottom Right
        // Finished Drawing The Triangle
        gl.glEnd();

        // Move the "drawing cursor" to another position
        gl.glTranslatef(3.0f, 0.0f, 0.0f);
        // Draw A Quad
        gl.glBegin(GL2.GL_QUADS);
            gl.glColor3f(0.5f, 0.5f, 1.0f);    // Set the current drawing color to light blue
            gl.glVertex3f(-1.0f, 1.0f, 0.0f);  // Top Left
            gl.glVertex3f(1.0f, 1.0f, 0.0f);   // Top Right
            gl.glVertex3f(1.0f, -1.0f, 0.0f);  // Bottom Right
            gl.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
        // Done Drawing The Quad
        gl.glEnd();

    }

    public void dispose(GLAutoDrawable arg0) {
    }

}