Re: GLJPanel for LibGDX JOGL backend
Posted by adam_law on Jul 01, 2015; 11:05pm
URL: https://forum.jogamp.org/GLJPanel-for-LibGDX-JOGL-backend-tp4034741p4034790.html
Ah, I see. Well, I've been researching online and came across something on GLWindow and it says that a GLContext is automatically created when GLWindow is created, and I'm sure that it's the same for GLJPanel. But when I do tracing, the context is null for both when I do, and I can find no way to set it using setContext() so I can do makeCurrent().
Edit: I was able to break through using GLContext.getCurrentGL().getContext(). I had to use LibGDX Gdx.app.postRunnable(), but I've read somewhere that there's Threading.invokeOnOpenGLThread(), but I can't seem to load it from what's available on this libgdx + jogamp backend checkout.
Now that the context is set, the LibGDX processes are kicking in and passes through to JOGL, which brings me to the next error. When creating a SpriteBatch it errors out with this:
com.jogamp.opengl.GLException: AWT-EventQueue-0: No OpenGL context current on this thread
at com.jogamp.opengl.GLContext.getCurrentGL(GLContext.java:509)
at com.badlogic.gdx.backends.jogamp.JoglGL20.glCreateShader(JoglGL20.java:173)
at com.badlogic.gdx.graphics.glutils.ShaderProgram.loadShader(ShaderProgram.java:194)
at com.badlogic.gdx.graphics.glutils.ShaderProgram.compileShaders(ShaderProgram.java:173)
at com.badlogic.gdx.graphics.glutils.ShaderProgram.<init>(ShaderProgram.java:156)
at com.badlogic.gdx.graphics.g2d.SpriteBatch.createDefaultShader(SpriteBatch.java:156)
Wrapping the creation process of my renderer in this part with another postRunnable gets it to pass, but it also makes the rest of the startup process out of sync, throwing NPEs, unless I also pass these parts as a postRunnable to the OpenGL thread, which is not how I want to do it, of course.
I'm puzzled, I'm in the OpenGL context of LibGDX (else I'd have gotten this error without using the jogamp backend), so why isn't this recognized in the jogamp backend?