creating a GL3 object in QtJambi

I’m having some difficulty getting a GL3 context now that I’ve
switched to QtJambi. When casting my gl object to GL using getGL3, it
throws the error “javax.media.opengl.GLException: Not a GL3
implementation”.

This is my original code when I was using swing…
GLProfile profile = GLProfile.get(GLProfile.GL3)
GLCapabilities glCaps = new GLCapabilities(profile)
glCaps.setPBuffer(true)
GLPBuffer pbuffer =
GLDrawableFactory.getFactory(profile).createGLPbuffer(glCaps,

  new DefaultGLCapabilitiesChooser(),

  1, 1, null)

canvas = new GLCanvas(glCaps, new DefaultGLCapabilitiesChooser(),
PanelGL.pbuffer.getContext(), null)

Switch to QtJambi, I have the following code:

GLProfile profile = GLProfile.get(GLProfile::GL3)
GLCapabilities glCaps = GLCapabilities.new(profile)
glCaps.setPBuffer(true)
factory = GLDrawableFactory.getFactory(profile)
ctx = factory.createExternalGLContext
gl = ctx.getGL.getGL3

This last line throws an error. I’ve seen this page
(http://www.java-gaming.org/index.php?action=printpage;topic=21064.0),
which solves the issue, but it’s passing something to a GLCanvas
constructor, which is swing. Is there an equivalent setup in QtJambi
to get me a GL3 object?

Hi!

Don’t cast your object, rather call GLContext.getCurrentGL().getGL3() (as you already do). DefaultGLCapabilitiesChooser does not depend on Swing:

package javax.media.opengl;

import javax.media.nativewindow.Capabilities;
import javax.media.nativewindow.NativeWindowException;
import com.jogamp.opengl.impl.Debug;

Which build of JOGL 2 beta do you use?

So you’re saying GLContext.getCurrentGL().getGL3() provides different functionality than ctx.getGL.getGL3()? Should I not be using an external context then? I was hoping to eventually have the OpenGL context shared across multiple windows like I did with swing, but was trying to keep this simple for now. Are there any QtJambi examples out there that use a GL3 implementation?

I believe I’m using the latest nightly JOGL build. Here are the jars I’m using…
http://code.google.com/p/sunshine/source/browse/#hg/lib/jogl-2.0-linux-i586

Adding GLContext.getCurrentGL().getGL3() at the end of my initializeGL function returns an error saying there’s not context current

Exception in thread "main" javax/media/opengl/GLContext.java:159:in `getCurrentGL': javax.media.opengl.GLException: No OpenGL context current on this thread (NativeException)

  public void initializeGL() {
    profile = GLProfile.get(GLProfile.GL3)
    glCaps = GLCapabilities.new(profile)
    glCaps.setPBuffer(true)
    factory = GLDrawableFactory.getFactory(profile)
    ctx = factory.createExternalGLContext()
    gl = GLContext.getCurrentGL().getGL3()
    //gl = ctx.getGL.getGL3
}

No, JOGL 2 is rather there:
http://jogamp.org/deployment/autobuilds/
I have no example of use with both JOGL 2 and QtJambi. Personally I use JOGL 2 with Ardor3D and/or Eclipse RCP/SWT, I have found a good tutorial about it:

initializeGL() seems to be called when the OpenGL context is not current, it should be called in the init method of GLEventListener.

I’m not using a GLEventListener. I’m using a QGLWidget. I ended up having to call makeCurrent in the objects initializeGL call, which seemed to resolve the siutation. I added notes of how to do it (in JRuby) in a blog post (http://strattonbrazil.blogspot.com/2010/10/incorporating-scala-java-sbt-jogl-qt.html).

Thank you very much for this tip ;D