Context sharing between offscreen drawable and external GL context
I have a problem with GL context sharing, of which I'm not sure if it's in my code, in JOGL or in the driver.
My setup is as follows. I have a Java library which renders into an offscreen drawable. This library needs to be integrated into a native host application (C++, C#, ...). To do so, the Java code renders into a texture, which I then want to make available to a GL context created by the native code.
I set this up as follows:
The native code creates a GL context and makes it current
The Java code creates an external GL context (corresponding to the native one)
On a different thread, the Java code then creates an offscreen drawable which shares with the external GL context
For various reasons, it would be convenient if the "different thread" above could be the EDT. However, on Windows systems with NVidia GPUs, that doesn't work. After the offscreen drawable is created, the first call to display() results in an exception:
com.jogamp.opengl.GLException: AWT-EventQueue-0: createImpl ctx !ARB but ARB is used, profile > GL2 requested (OpenGL >= 3.1). Requested: GLProfile[GL4bc/GL4bc.hw], current: 4.5 (Compat profile, compat[ES2, ES3, ES31], FBO, hardware) - 4.5.0 NVIDIA 347.52
When I use a dedicated (non-EDT) thread, this error does not occur. On an AMD GPU, either approach works fine.
I've narrowed this whole scenario down to a unit test: ShareWithExternalContextTest.java
The test covers both the EDT and non-EDT case (the latter uses a single-threaded ExecutorService). I used a second offscreen drawable as a stub for the native GL context.
Any idea what causes this error or how I could work around it (while continuing to use the EDT)? Should I file this as a JOGL bug?
<p/> I've narrowed this whole scenario down to a unit test: ShareWithExternalContextTest.java <p/> The test covers both the EDT and non-EDT case (the latter uses a single-threaded ExecutorService). I used a second offscreen drawable as a stub for the native GL context.
<p/> Any idea what causes this error or how I could work around it (while continuing to use the EDT)? Should I file this as a JOGL bug?
Thank you for creating a unit test!
Do you mind cloning our jogl git and adding your unit test to
send a pull request and file a bug in our bugzilla.
This will allow us to run the test on all platforms that we support.