Login  Register

Re: GLException "Unable to create temp OpenGL context for device context" thrown when GLContext.makeCurrent() called

Posted by Sven Gothel on Sep 10, 2012; 5:20pm
URL: https://forum.jogamp.org/GLException-Unable-to-create-temp-OpenGL-context-for-device-context-thrown-when-GLContext-makeCurrend-tp4026068p4026069.html

On 09/10/2012 05:26 PM, stepasite [via jogamp] wrote:

> Hi,
>
> I am migrating from JOGL to JOGL2, but my code does not work with JOGL2.
>
> I use my own class for rendering, it is descendant of GLCanvas. Here is the
> code which produces GLException:
>
> public void addNotify()
> {
>   super.addNotify();
>   GLContext context = getContext();
>   context.makeCurrent(); // GLException is thrown
> }
>
The lifecycle has changed dramatically.
JOGL2's GLAutoDrawable implementations (incl. GLCanvas)
use lazy initialization at the latest possible time
_and_ only when the native object is actually ready to be displayed.
The latter requires a valid size for example ..

Pls read the source ..

Deriving from a heavily specialized class like GLCanvas
is not advised and your mileage may vary (impl. changes).

A new proper way to impl. your own GLAutoDrawable
is to derive from GLAutoDrawableBase or to use GLAutoDrawableDelegate.
(GLWindow uses this approach for example)

There are unit tests demonstrating the above.

I am almost done w/ my 2-3 weeks rework to natively support
FBO drawable and auto-drawable, incl the offscreen layer mode for OSX.
When this work is pushed, you may like to look at the new unit tests.

~Sven



signature.asc (907 bytes) Download Attachment