diff options
author | Sven Gothel <[email protected]> | 2011-02-11 08:09:53 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-02-11 08:09:53 +0100 |
commit | bf75331124d6d0c53b74d5235ec03f5fcbc55cba (patch) | |
tree | 36c9ad23c37826d3e4d6bc16832e271c48bd3682 /src/jogl/classes | |
parent | ffe215ecf60da12605b29f3fa1d08eafebcb415a (diff) |
Win,GDI,SWT: Fix pfd to caps conversion. Added thorough debug code.
Debug code added for use case: WinXP-32bit, GDI, SWT,
where WGL.wglGetCurrentDC() returns a non null value which is invalid.
Using the value (hdc) on eg GDI.GetObjectType(hdc) return 0 instead of
3 (OBJ_DC) and GDI.GetPixelFormat(hdc) returns 0 with last error 2000.
Diffstat (limited to 'src/jogl/classes')
3 files changed, 30 insertions, 11 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index 569463db5..845460c58 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -70,21 +70,39 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { } protected static WindowsExternalWGLContext create(GLDrawableFactory factory, GLProfile glp) { - long hdc = WGL.wglGetCurrentDC(); - if (0==hdc) { - throw new GLException("Error: attempted to make an external GLDrawable without a drawable current, werr " + GDI.GetLastError()); + /** + * Added thorough debug code, since we currently have problems with this code with use case: + * - WinXP [32bit] + * - GDI (Software GL) + * - SWT + * However, it works on other combinations, eg Win7 [64bit], GDI, SWT, etc .. + */ + if(DEBUG) { + System.err.println("WindowsExternalWGLContext 0: werr: " + GDI.GetLastError()); } + long ctx = WGL.wglGetCurrentContext(); - if (ctx == 0) { + if (0 == ctx) { throw new GLException("Error: attempted to make an external GLContext without a context current, werr " + GDI.GetLastError()); } + + long hdc = WGL.wglGetCurrentDC(); + if (0 == hdc) { + throw new GLException("Error: attempted to make an external GLDrawable without a drawable current, werr " + GDI.GetLastError()); + } + int hdcType = GDI.GetObjectType(hdc); + if( GDI.OBJ_DC != hdcType ) { + // FIXME: Turns out in above use case (WinXP-32bit, GDI, SWT) the returned DC (not 0) is invalid! + throw new GLException("Error: current WGL DC ("+toHexString(hdc)+") is not a DC but: "+hdcType+", werr " + GDI.GetLastError()); + } + int pfdID = GDI.GetPixelFormat(hdc); - if (pfdID == 0) { + if (0 == pfdID) { throw new GLException("Error: attempted to make an external GLContext without a valid pixelformat, werr " + GDI.GetLastError()); } AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromCurrent(factory, hdc, pfdID, glp, aScreen, true, true); + WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromCurrent(factory, hdc, pfdID, glp, aScreen, true); return new WindowsExternalWGLContext(new Drawable(factory, new ProxySurface(cfg, hdc)), ctx, cfg); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java index 86cc705b5..742a42709 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java @@ -69,7 +69,7 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { } AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromCurrent(factory, hdc, pfdID, glp, aScreen, true, true); + WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromCurrent(factory, hdc, pfdID, glp, aScreen, true); return new WindowsExternalWGLDrawable(factory, new ProxySurface(cfg, hdc)); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 82d170133..a80f68377 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -83,7 +83,7 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio static WindowsWGLGraphicsConfiguration createFromCurrent(GLDrawableFactory _factory, long hdc, int pfdID, - GLProfile glp, AbstractGraphicsScreen screen, boolean onscreen, boolean usePBuffer) + GLProfile glp, AbstractGraphicsScreen screen, boolean onscreen) { if(_factory==null) { throw new GLException("Null factory"); @@ -105,12 +105,13 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio WGLGLCapabilities caps = null; if(hasARB) { - caps = wglARBPFID2GLCapabilities(sharedContext, hdc, pfdID, glp, onscreen, usePBuffer); - } else if(!usePBuffer) { + caps = wglARBPFID2GLCapabilities(sharedContext, hdc, pfdID, glp, onscreen, true /* pbuffer */); + } else { caps = PFD2GLCapabilities(glp, hdc, pfdID, onscreen); } if(null==caps) { - throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+", pfdID "+pfdID+", hasARB "+hasARB); + throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+ + ", pfdID "+pfdID+", onscreen "+onscreen+", hasARB "+hasARB); } return new WindowsWGLGraphicsConfiguration(screen, caps, caps); |