Login  Register

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

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

Actually, it seems than drawable member initialisation has been moved to addNotify() method of GLCanvas and not in constructor anymore :

JOGL2 :
__________________________________________________________________
 public void addNotify() {
    super.addNotify();
    if (!Beans.isDesignTime()) {
        disableBackgroundErase();

        if(null==device) {
            GraphicsConfiguration gc = super.getGraphicsConfiguration();
            if(null!=gc) {
                device = gc.getDevice();
            }
        }

        /*
* Save the chosen capabilities for use in getGraphicsConfiguration().
*/
        awtConfig = chooseGraphicsConfiguration(capabilities, chooser, device);
        if(DEBUG) {
            Exception e = new Exception("Created Config: "+awtConfig);
            e.printStackTrace();
        }
        if(null!=awtConfig) {
          // update ..
          chosen = awtConfig.getGraphicsConfiguration();

        }
        if(null==awtConfig) {
          throw new GLException("Error: AWTGraphicsConfiguration is null");
        }
        drawable = GLDrawableFactory.getFactory(glProfile).createGLDrawable(NativeWindowFactory.getNativeWindow(this, awtConfig));
        context = (GLContextImpl) drawable.createContext(shareWith);
        context.setSynchronized(true);

        if(DEBUG) {
            System.err.println("Created Drawable: "+drawable);
        }
        drawable.setRealized(true);
    }
  }
________________________________________________________________________________

JOGL 2
________________________________________________________________________________
 public GLCanvas(GLCapabilities capabilities,
                  GLCapabilitiesChooser chooser,
                  GLContext shareWith,
                  GraphicsDevice device) {
    super();

    if(null==capabilities) {
        capabilities = new GLCapabilities(defaultGLProfile);
    }
    glProfile = capabilities.getGLProfile();

    this.capabilities = capabilities;
    this.chooser = chooser;
    this.shareWith=shareWith;
    this.device = device;
  }
______________________________________________________________________________

JOGL 1.1.1

______________________________________________________________________________

 public GLCanvas(GLCapabilities glcapabilities, GLCapabilitiesChooser glcapabilitieschooser, GLContext glcontext, GraphicsDevice graphicsdevice)
    {
        drawableHelper = new GLDrawableHelper();
        autoSwapBufferMode = true;
        sendReshape = false;
        initAction = new InitAction();
        displayAction = new DisplayAction();
        swapBuffersAction = new SwapBuffersAction();
        displayOnEventDispatchThreadAction = new DisplayOnEventDispatchThreadAction();
        swapBuffersOnEventDispatchThreadAction = new SwapBuffersOnEventDispatchThreadAction();
        destroyAction = new DestroyAction();
        chosen = chooseGraphicsConfiguration(glcapabilities, glcapabilitieschooser, graphicsdevice);
        if(chosen != null)
        {
            glCapChooser = glcapabilitieschooser;
            glCaps = glcapabilities;
        }
        if(!Beans.isDesignTime())
        {
            drawable = GLDrawableFactory.getFactory().getGLDrawable(this, glcapabilities, glcapabilitieschooser);
            context = drawable.createContext(glcontext);
            context.setSynchronized(true);
        }
    }

_____________________________________________________________________________________________

But I'm not sure of what I'm saying and I don't know if it's a choice or an "error" :)