aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-11-03 07:30:20 +0100
committerSven Gothel <[email protected]>2010-11-03 07:30:20 +0100
commitf3c59f7491e0912d6f81e1f6218aecef381533bb (patch)
treef94310964ec4b767fb65b9e33b97c8963dff1962 /src/jogl/classes/com/jogamp/opengl/impl/windows/wgl
parent714e9375bbba134d333e50adf63cdd9237eb21af (diff)
JOGL/X11: Fix context scanning, misc simplifications ..
Fix context scanning --------------------- Ie on 3.0 NVidia systems, trying to create a 4.1 context leads to a BadAlloc X11 error. A prev patch disabled the X11 error handler, to reduce sideeffects. In case AWT is not being used, the BadAlloc isn't catched and the JVM freezes within the native function call. Decorating context scanning with NativeWindow's 'setX11ErrorHandler' solves this issue. Simplifications ----------------- X11: always try a direct context. If this is not possible due to the display connection, an indirect is being used anyways. Hence 'createContext(boolean direct)' -> 'createImpl()'. X11/WGL: Simplify the context creation logic a bit.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl/windows/wgl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java57
1 files changed, 27 insertions, 30 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
index 027fb0065..c9a12c85b 100644
--- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLContext.java
@@ -216,11 +216,11 @@ public class WindowsWGLContext extends GLContextImpl {
// utilize the shared context's GLXExt in case it was using the ARB method and it already exists
if( null!=factory.getSharedContext() && factory.getSharedContext().isCreatedWithARBMethod() ) {
- if(DEBUG) {
- System.err.println("WindowsWGLContext.createContext using shared Context: "+factory.getSharedContext());
- }
contextHandle = createContextARB(share, true, major, minor, ctp);
createContextARBTried = true;
+ if (DEBUG && 0!=contextHandle) {
+ System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+share);
+ }
}
long temp_ctx = 0;
@@ -234,34 +234,29 @@ public class WindowsWGLContext extends GLContextImpl {
if (!WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx)) {
throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: 0x"+Integer.toHexString(GDI.GetLastError()));
}
- setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
-
- if( createContextARBTried ||
- !isFunctionAvailable("wglCreateContextAttribsARB") ||
- !isExtensionAvailable("WGL_ARB_create_context") ) {
- if(glCaps.getGLProfile().isGL3()) {
- WGL.wglMakeCurrent(0, 0);
- WGL.wglDeleteContext(temp_ctx);
- throw new GLException("Unable to create OpenGL >= 3.1 context (no WGL_ARB_create_context)");
+ setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); // use GL_VERSION
+ WGL.wglMakeCurrent(0, 0); // release temp context
+
+ if( !createContextARBTried &&
+ isFunctionAvailable("wglCreateContextAttribsARB") &&
+ isExtensionAvailable("WGL_ARB_create_context") ) {
+ // initial ARB context creation
+ contextHandle = createContextARB(share, true, major, minor, ctp);
+ createContextARBTried=true;
+ if (DEBUG && 0!=contextHandle) {
+ System.err.println(getThreadName() + ": createImpl: OK (ARB, initial) share "+share);
}
-
- // continue with temp context for GL < 3.0
- contextHandle = temp_ctx;
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
- return true;
- }
- contextHandle = createContextARB(share, true, major, minor, ctp);
- createContextARBTried=true;
+ }
}
if(0!=contextHandle) {
- share = 0; // mark as shared ..
-
- WGL.wglMakeCurrent(0, 0);
- WGL.wglDeleteContext(temp_ctx);
-
- if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
- throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(GDI.GetLastError()));
+ share = 0; // mark as shared thx to the ARB create method
+ if(0!=temp_ctx) {
+ WGL.wglMakeCurrent(0, 0);
+ WGL.wglDeleteContext(temp_ctx);
+ if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
+ throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(GDI.GetLastError()));
+ }
}
} else {
if(glCaps.getGLProfile().isGL3()) {
@@ -280,6 +275,9 @@ public class WindowsWGLContext extends GLContextImpl {
WGL.wglDeleteContext(contextHandle);
throw new GLException("Error making old context current: 0x" + toHexString(contextHandle) + ", werr: 0x" + Integer.toHexString(GDI.GetLastError()));
}
+ if (DEBUG) {
+ System.err.println(getThreadName() + ": createImpl: OK (old) share "+share);
+ }
}
if(0!=share) {
@@ -289,7 +287,6 @@ public class WindowsWGLContext extends GLContextImpl {
Integer.toHexString(GDI.GetLastError()));
}
}
- setGLFunctionAvailability(false, -1, -1, CTX_PROFILE_COMPAT|CTX_OPTION_ANY);
return true;
}
@@ -348,7 +345,7 @@ public class WindowsWGLContext extends GLContextImpl {
if(null != table) {
wglExtProcAddressTable = table;
if(DEBUG) {
- System.err.println("GLContext WGL ProcAddressTable reusing key("+major+","+minor+","+ctp+") -> "+table.hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable reusing key("+major+","+minor+","+ctp+") -> "+table.hashCode());
}
} else {
if (wglExtProcAddressTable == null) {
@@ -360,7 +357,7 @@ public class WindowsWGLContext extends GLContextImpl {
synchronized(mappedProcAddressLock) {
mappedGLXProcAddress.put(key, getWGLExtProcAddressTable());
if(DEBUG) {
- System.err.println("GLContext WGL ProcAddressTable mapping key("+major+","+minor+","+ctp+") -> "+getWGLExtProcAddressTable().hashCode());
+ System.err.println(getThreadName() + ": !!! GLContext WGL ProcAddressTable mapping key("+major+","+minor+","+ctp+") -> "+getWGLExtProcAddressTable().hashCode());
}
}
}