summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java30
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java9
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);