package gl4bug; import java.awt.*; import java.awt.event.*; import javax.media.opengl.*; import javax.media.opengl.awt.*; /** * Shows a bug (?) with the combination GLProfile.get(GLProfile.GL4) / GL4 gl = drawable.getGL().getGL4(); In that case the stacktrace starts like: [java] Exception in thread "AWT-EventQueue-0" javax.media.opengl.GLException: Not a GL4 implementation [java] at jogamp.opengl.gl4.GL4bcImpl.getGL4(GL4bcImpl.java:32456) [java] at firstopengl.GL4Bug.init(GL4Bug.java:31) [java] at jogamp.opengl.GLDrawableHelper.init(GLDrawableHelper.java:132) In all other cases everything looks ok, and for instance GL4 gl = (GL4) drawable.getGL(); works, and correctly reports an OpenGL version 4.1.0. Similar code but with GLProfile.get(GLProfile.GL3) / GL3 gl = drawable.getGL().getGL3() shows version 3.3.0 and works ok. Tested with NVidia GTX 460 and GTX 560, driver version 275.33, on Windows 7 64-bit/32-bit Java 1.6.0_26 Jogl versions: jogl-2.0-b23-20110303-windows-i586.7z and jogl-2.0-b417-20110802-windows-i586.7z */ public class GL4Bug implements GLEventListener { public GL4Bug() { //GLProfile glp = GLProfile.getDefault(); // This works ok, and reports OGL version 4.1.0 later on //GLProfile glp = GLProfile.get(GLProfile.GL3); // This works ok, but will report OGL version 3.3.0 later on GLProfile glp = GLProfile.get(GLProfile.GL4); // ===> This will fail later on, but ONLY with the getGL4() call, not with (GL4) drawable.getGL() GLCapabilities caps = new GLCapabilities(glp); GLCanvas canvas = new GLCanvas(caps); canvas.addGLEventListener(this); Frame frame = new Frame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setSize(256, 128); frame.setLocation(256, 256); frame.add(canvas); frame.setVisible(true); } public void init(GLAutoDrawable drawable) { GL4 gl = drawable.getGL().getGL4(); // this fails for GLProfile.get(GLProfile.GL4), but works ok for GLProfile.getDefault() //GL4 gl = (GL4) drawable.getGL(); // This always works ok, next line will print correct version 4.1.0 (or 3.3.0 for GLProfile.GL3) System.out.println("GLVERSION: " + gl.glGetString(GL.GL_VERSION)); } public void dispose(GLAutoDrawable drawable) { } public void reshape(GLAutoDrawable gl, int x, int y, int width, int height) { } public void display(GLAutoDrawable drawable) { } public static void main(String[] arg) { GLProfile.initSingleton(false); new GL4Bug(); } }