Bug 452 - "GL_VERSION is NULL" exception in createExternalGLContext() for SWT tests
Summary: "GL_VERSION is NULL" exception in createExternalGLContext() for SWT tests
Status: VERIFIED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: opengl (show other bugs)
Version: 2
Hardware: pc_x86_64 windows
: --- normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2011-01-03 22:43 CET by Wade Walker
Modified: 2011-02-03 08:04 CET (History)
3 users (show)

See Also:
Type: ---
SCM Refs:
6dd574f75e0b27de31136c05cc0ed18f075f004f
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wade Walker 2011-01-03 22:43:21 CET
I get a GLException that says "GL_VERSION is NULL" inside GLDrawableFactoryImpl.createExternalGLContext() from my new SWT unit tests. I'm running Windows 7 64-bit, nvidia drivers 260.99, GeForce 8800GTX.

I'm currently working on fixing this bug so I can submit a fix to HEAD, then re-submit my working SWT unit tests to HEAD afterwards. I think I'm pretty close to a fix, but we'll see :)

My new SWT unit tests are at https://github.com/WadeWalker/jogl/tree/swt_tests (currently applied to b244).

The last autobuild that runs my new SWT tests correctly is b244. The last good commit of jogl is 7753e1c5a50700771b1e0be4bc99c2585398e3ce. The first bad commit of jogl is 0a6a592c04a85d8124aa9d38b67f0caa1d739b75.

The bug seems to have been introduced in the changes to WindowsWGLGraphicsConfiguration.java and WindowsWGLGraphicsConfigurationFactory.java. I've applied all the other changes in commit 0a6a592c04a85d8124aa9d38b67f0caa1d739b75 successfully with my SWT tests still working, so I know the bug is in those two files somewhere.

My next debugging step is to pick apart the changes to those two files and see exactly where the problem started.

For reference, the stack trace for the exception is:

javax.media.opengl.GLException: GL_VERSION is NULL: com.jogamp.opengl.impl.windows.wgl.WindowsExternalWGLContext [OpenGL -1.-1, options 0x0, null, handle 0x20000, com.jogamp.opengl.impl.gl4.GL4bcImpl@7f6877f8,
	Drawable: com.jogamp.opengl.impl.windows.wgl.WindowsExternalWGLContext$Drawable[Realized true,
	Factory   com.jogamp.opengl.impl.windows.wgl.WindowsWGLDrawableFactory@239c7c21,
	handle    0x4001198b,
	Window    ProxySurface[config WindowsWGLGraphicsConfiguration[class javax.media.nativewindow.DefaultGraphicsScreen[class javax.media.nativewindow.DefaultGraphicsDevice[type Windows, connection decon, unitID 0, handle 0x0], idx 0], pfdID 7, ARB-Choosen true,
	requested GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: true, DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16, Multisample: false, Num samples: 0, PBuffer-FloatingPointBuffers: true, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false],
	chosen    GLCapabilities[Capabilities[Onscreen: true, Red: 8, Green: 8, Blue: 8, Alpha: 0, Opaque: true], GL profile: GLProfile[GL2/GL2], PBuffer: true, DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 0, Red Accum: 16, Green Accum: 16, Blue Accum: 16, Alpha Accum: 16, Multisample: false, Num samples: 0, PBuffer-FloatingPointBuffers: true, PBuffer-RenderToTexture: false, PBuffer-RenderToTextureRectangle: false]], displayHandle 0x0, surfaceHandle 0x4001198b, size 0x0]]] 
	at com.jogamp.opengl.impl.GLContextImpl.setContextVersion(GLContextImpl.java:681)
	at com.jogamp.opengl.impl.GLContextImpl.setGLFunctionAvailability(GLContextImpl.java:868)
	at com.jogamp.opengl.impl.windows.wgl.WindowsExternalWGLContext.<init>(WindowsExternalWGLContext.java:68)
	at com.jogamp.opengl.impl.windows.wgl.WindowsExternalWGLContext.create(WindowsExternalWGLContext.java:88)
	at com.jogamp.opengl.impl.windows.wgl.WindowsWGLDrawableFactory.createExternalGLContextImpl(WindowsWGLDrawableFactory.java:339)
	at com.jogamp.opengl.impl.GLDrawableFactoryImpl.createExternalGLContext(GLDrawableFactoryImpl.java:282)
	at com.jogamp.test.junit.jogl.swt.TestSWT01GLn.runTestGL(TestSWT01GLn.java:117)
	at com.jogamp.test.junit.jogl.swt.TestSWT01GLn.test01GLDefault(TestSWT01GLn.java:167)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Comment 1 Wade Walker 2011-01-04 02:15:17 CET
The problem seems to be in WindowsWGLGraphicsConfiguration.create() at line 112:

if(hasARB) {
    sharedContext.makeCurrent();
    try {
        caps = wglARBPFID2GLCapabilities(sharedContext, hdc, pfdID, glp, onscreen, usePBuffer);
    } finally {
        sharedContext.release();
    }

If I comment out the two lines to make the shared context current and to release it, the "GL_VERSION is NULL" problem a bit later in the WindowsExternalWGLContext constructor goes away. Apparently this disturbance in the context is enough to mess up later access to the GL object so that getGL().glGetString(GL.GL_VERSION) returns null.

The problem is, I don't believe that removing these two lines is the correct solution. The call to sharedCtx.getWGLExt().wglGetPixelFormatAttribivARB() inside wglARBPFID2GLCapabilities() is supposed to require a current context, so I'm not sure why it works without one. The AWT tests still work like this, but I'm suspicious.

Do you have any suggestions about a better solution? Perhaps your upcoming changes are going over this area again?
Comment 2 Wade Walker 2011-01-14 15:50:08 CET
Hi Sven,

I'm waiting for your next checkin before doing more on this bug. From your forum post on January 10th, it sounded like you were making changes to GLCapabilities, which seems to be where the bug lies.
Comment 3 Kai Giebeler 2011-01-26 21:10:42 CET
Hi,

I'm facing the very same problem using jogl-2.0-b270-20110125-windows-amd64

Kind regards,
Kai
Comment 4 mateushek 2011-01-26 21:33:01 CET
Having the same problem in my application, after upgrading the jogl to newest version. My system is Windows 7 32bit & Nvidia.
Comment 5 Wade Walker 2011-01-26 21:58:26 CET
I've submitted a pull request for two SWT unit tests that reproduce this problem. You can comment/vote on it at https://github.com/sgothel/jogl/pull/14.
Comment 6 Wade Walker 2011-02-03 03:09:35 CET
These problems are now reproduced in the auto build, since the new SWT tests have been merged in.
Comment 7 Sven Gothel 2011-02-03 06:18:39 CET
I can confirm this bug is related to WindowsWGLGraphicsConfiguration
and WindowsWGLGraphicsConfigurationFactory.

WindowsWGLGraphicsConfiguration.create(..) ->
WindowsWGLGraphicsConfiguration.createFromCurrent(..) emphasizing that 
all resources are 'current' ie locked and available.
This method is used for the external context/drawable creation only, called
while they are current.
Hence this method no more makeCurrent/release, which interfered with the
current external context state.

WindowsWGLGraphicsConfigurationFactory: Move surface locking to the right
(common) place.

Testing ..
Comment 8 Sven Gothel 2011-02-03 08:04:11 CET
6dd574f75e0b27de31136c05cc0ed18f075f004f