GLCanvas returning null GraphicsConfiguration

Hi all.

I don’t know if this could be a bug, but to me it seems quite strange. I tried this with the latest beta (4), but it didn’t change anything.

I’ve got an app (3d rasterizer) that works fine on my machine, which is an Athlon with an ATI Radeon 9600 running on Linux.
Recently I’ve been working on another computer, a laptop running Windoze with an older ATI (Radeon 7000 DDR x86/SSE2 is the string returned as Renderer). In this machine I found a problem in the initialization stage of my app.
I try to get a Device to be able to set fullscreen mode, but when I try to obtain a GraphicsConfiguration instance from the canvas, I only get a null, so my app crashes with a NullPointerException.

My code is as simple as this:


	// create the canvas
	canvas = new GLCanvas(glcaps);
	
	// get the associated graphics device
	GraphicsConfiguration gc = canvas.getGraphicsConfiguration();
	device = gc.getDevice();                                     <--------------   NullPointerException!

The only thing I’ve come up with is getting the GraphicsConfiguration from the container window instead, which seems to work ok. But, since GLCanvas is an AWT widget too, where is the problem?.

I haven’t been able to spot any difference between the two setups that could be the root of the problem. Could this be any problem related to the laptop drivers, which seem to be a bit older?
Have you experienced any behaviour like this in the past?

Any feedback would be really appreciated.

Thanks for your time.

What happens if you replace the call to “new GLCanvas(…)” with one to “new Canvas()”? If it also returns null, it’s a behavioral issue with the Canvas. If not, it’s a bug in the GLCanvas, and please file a bug using the JOGL Issue Tracker and attach a test case.

Hi Ken.

If I create a normal Canvas instead, the problem persists.
However, thinking about it, I saw that I was adding the canvas to the container (a Window in this case) after I was requesting the GraphicsConfig, so the canvas was not yet bound to any container in the moment of the call.

I thought that could be the problem and you know what? I was right. Just moving the “getContentPane().add(canvas, BorderLayout.CENTER)” line before the call to getGraphicsConfiguration() made the trick. It works smooth now ;D

However I keep wondering… how is it that it worked previously, on the other computer? Shouldn’t the problem show up there too?

Big thanks for sheding some light.
See you around.

I think you’re seeing a difference between the X11 and Windows implementations of the AWT in how the GraphicsConfiguration of the Canvas is selected. In the case of JOGL’s GLCanvas, the OS difference is causing the difference in behavior. On X11 platforms the OpenGL pixel format is tied to the visual of the Canvas and from there to the GraphicsConfiguration, so the GraphicsConfiguration is non-null at the time of instantiation of the Canvas. On Windows platforms the OpenGL pixel format is only chosen at the time the GLCanvas is actually shown; at construction time the GLCanvas gets a null GraphicsConfiguration on this platform. I’m not sure how the shared code in the AWT manages the setting of the GraphicsConfiguration but it would make sense to me that it’s done when the native peer is created.

Yep. See what I found when browsing through the jogl sources:


    // The platform-specific GLDrawableFactory will only provide a
    // non-null GraphicsConfiguration on platforms where this is
    // necessary (currently only X11, as Windows allows the pixel
    // format of the window to be set later and Mac OS X seems to
    // handle this very differently than all other platforms). On

Thanks a lot for the info.
See ya.