Posted by
Sven Gothel on
Sep 21, 2011; 11:21am
URL: https://forum.jogamp.org/JOGL-2-support-for-Ardor3D-JMonkeyEngine-3-jzy3d-and-NiftyGUI-tp1706747p3355133.html
On Wednesday, September 21, 2011 12:54:15 PM Sven Gothel wrote:
>
> You can see the following dependency (same in GLCanvas):
>
> GLContext -> GLDrawable -> NativeWindow -> GLCapabilities
>
> This is the common denominator of creating the resource chain.
>
> - setVisible(true) is kicks off the native Window creation
> which provides the proper chosen GLCapabilities.
>
> - then GLDrawable wraps around the NativeSurface (NativeWindow)
>
> - GLDrawable setRealized(true)
>
> Our goal was to allow lazy initialization of the native components,
> where we only kick off creation and initialization when required.
>
> This allows users to create instances of a GLCanvas or GLWindow
> and add them in their structures etc w/o holding native resources.
>
> I see, it's kind of broken in this path .. just reviewing the code
> and sequence of creation/lifecycle here ..
>
> At a first glance, it is possible to create the non initialized
> GLDrawable and it's GLContext right away.
The problem here would be the dependencies to the NativeSurface/NativeWindow
configuration while creating the proper GLDrawable via the GLDrawableFactory.
Actually this dependency makes it hard for the GLCanvas only,
where we need to fetch the AWTGraphicsConfiguration,
which is only valid when visible (addNotify()).
We might be able to defer the native configuration setting at
GLDrawable.setRealize() while passing the new native configuration,
but this would imply a view side effects I am afraid and will consume time to do properly.
>
> However this would allow users to use the non-initialized objects
> being bound to some other data structures.
Also, the GLAutoDrawable spec currently claims that GLContext is not
persistent, ie don' rely on it's identity.
This actually hinders one from storing GLAutoDrawable GLContext's
but would need to query it before using.
I see, it's quite complicated, sorry about that.
Maybe best would be to reference the GLAutoDrawable (GLCanvas, GLWindow) itself,
and always query the GLContext there if needed .. and only act if valid.
Can you send a link to the source code online, so I can see the problems in detail ?
~Sven