Login  Register

Re: NPE when getting GLDrawableFactory

Posted by Sven Gothel on Mar 04, 2011; 11:10pm
URL: https://forum.jogamp.org/NPE-when-getting-GLDrawableFactory-tp2276026p2635935.html

On Friday, March 04, 2011 23:32:43 François Coupal [via jogamp] wrote:
>
> Found a workaround fooling around with Wade Walker's AWT examples on the
> JogAmp wiki.
>
> It appears that even though the canvas is created, it will not be able to
> process the default capabilities until a Frame has been created AND shown
> using the "setVisible(true)" method. Trying to access them will throw an
> NPE.

Please post this NPE using the current RC2 - thx.
  http://jogamp.org/deployment/archive/rc/v2.0-rc2/archive/
  http://jogamp.org/deployment/archive/rc/v2.0-rc2/all.artifact.properties.sorted
  http://jogamp.org/git/?p=jogl.git;a=commit;h=bcf5d6ac871a29398b441df617923d3dd2cf35c1

Even though it's true, that only after GLCanvas addNotify/display a valid
context/drawable/etc is instantiated, we shall not NPE. I would like to fix it.

>
> >From that moment, it is possible to fetch default capabilities and create a
> PBuffer for graphic card verifications. Tried it with both the default
> profile (whatever it may be) and a GL2 profile.
>
> I will try to use a NEWT-Based window toolkit to access a window-less
> PBuffer. If I can't then it would mean there are no way JOGL can fetch
> capabilities without the help of a window toolkit. I'd very much like to be
> proven wrong on this.

The only requirement here is that the shared resources for the target device
have been initialized.
In short: 'GLProfile.initSingleton(false);' shall be passed.

http://jogamp.org/git/?p=jogl.git;a=blob;f=src/newt/classes/jogamp/newt/awt/opengl/VersionApplet.java;h=18524d0bac330afbd04a425720d548170da84de7;hb=HEAD#l103

// shortcut:
GLProfile.initSingleton(false);
List/*<GLCapabilitiesImmutable>*/ availCaps = GLDrawableFactory.getDesktopFactory().getAvailableCapabilities(null);

And in action:
  http://jogamp.org/deployment/webstart/applet-version-jnlp.html

The fact that the applet also uses a GLCanvas is only due to the fact,
that it dumps it's actual GLContext as well.

http://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/javax/media/opengl/GLDrawableFactory.html#getAvailableCapabilities%28javax.media.nativewindow.AbstractGraphicsDevice%29


>
> By the way, I've found that using the method
> "GLProfile.initSingleton(false);" in Eclipse causes the windows to be
> unresponsive to closing. I have to switch them to "true" to be able to close
> them using the window close button. It's the exact opposite behavior that is
> mentionned in the comment just above the code line in the basic examples.

interesting.

I guess we have to discuss the whole SWT 'behavior' much more in detail.
Good that we have Wade helping here.

~Sven