Login  Register

[JOGL1.1.1->JOGL2] Sharing context, drawable member of GLCanvas is null in createContext()

Posted by Djak on Nov 05, 2010; 10:05pm
URL: https://forum.jogamp.org/JOGL1-1-1-JOGL2-Sharing-context-drawable-member-of-GLCanvas-is-null-in-createContext-tp1851054.html

Hi,
it's me, again :)
I'm trying to share context within 2 GLCanvas and I got a problem.
Here is my old code working in 1.1.1 :
_____________________________________________________________________
GLCanvas canvas = new GLCanvas();
GLContext sharedContext = canvas.createContext(this.getGEngine().getContext());
_____________________________________________________________________

this.getGEngine().getContext() // return a GLContext from another GLCanvas

But this code doesn't work in JOGL2 because drawable member of class GLCanvas is null in :

_____________________________________________________________________
public GLContext createContext(GLContext shareWith) {
    return drawable.createContext(shareWith);
  }
_____________________________________________________________________

I found an alternative in adding the canvas in a frame :

_____________________________________________________________________
Frame f = new Frame();
f.add(canvas);
f.setSize(200, 200);
f.setVisible(true);
GLContext sharedContext = canvas.createContext(this.getGEngine().getContext());
_____________________________________________________________________

but actually I don't need a frame at this step.
Anyone may got a way to create a valid context on a GLCanvas without adding it to an AWT component ?

Thanks for the informations :)