aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-11-02 16:26:02 +0100
committerSven Gothel <[email protected]>2013-11-02 16:26:02 +0100
commit7433e513c1f109f75aa34c224b1f5f14b612cba8 (patch)
tree550cb4580a25698a66de55e9cafe4a28f896d5e0 /src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
parent3ed74abaddb90cb537897b9928e923be50f7f99f (diff)
GLContextImpl: Move sharedContextHandle check to makeCurrentWithinLock(..) and let it fail there instead of within impl. class, only pass the handle - simplifies and removes redundancy.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java40
1 files changed, 15 insertions, 25 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
index b1e41624d..b214252c1 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java
@@ -268,7 +268,7 @@ public class WindowsWGLContext extends GLContextImpl {
* called by {@link #makeCurrentImpl()}.
*/
@Override
- protected boolean createImpl(GLContextImpl shareWith) {
+ protected boolean createImpl(long shareWithHandle) {
final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration();
final AbstractGraphicsDevice device = config.getScreen().getDevice();
final WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl();
@@ -278,18 +278,7 @@ public class WindowsWGLContext extends GLContextImpl {
isGLReadDrawableAvailable(); // trigger setup wglGLReadDrawableAvailable
if (DEBUG) {
- System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+shareWith);
- }
-
- // Windows can set up sharing of display lists after creation time
- long share;
- if ( null != shareWith ) {
- share = shareWith.getHandle();
- if (share == 0) {
- throw new GLException("GLContextShareSet returned an invalid OpenGL context");
- }
- } else {
- share = 0;
+ System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+toHexString(shareWithHandle));
}
boolean createContextARBTried = false;
@@ -300,17 +289,17 @@ public class WindowsWGLContext extends GLContextImpl {
if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) {
throw new GLException("Could not make Shared Context current: "+sharedContext);
}
- contextHandle = createContextARB(share, true);
+ contextHandle = createContextARB(shareWithHandle, true);
sharedContext.release();
if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) {
throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError());
}
} else {
- contextHandle = createContextARB(share, true);
+ contextHandle = createContextARB(shareWithHandle, true);
}
createContextARBTried = true;
if ( DEBUG && 0 != contextHandle ) {
- System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+share);
+ System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+toHexString(shareWithHandle));
}
}
@@ -343,17 +332,17 @@ public class WindowsWGLContext extends GLContextImpl {
}
if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) {
// initial ARB context creation
- contextHandle = createContextARB(share, true);
+ contextHandle = createContextARB(shareWithHandle, true);
createContextARBTried=true;
if (DEBUG) {
if( 0 != contextHandle ) {
- System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+share);
+ System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+toHexString(shareWithHandle));
} else {
- System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+share);
+ System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+toHexString(shareWithHandle));
}
}
} else if (DEBUG) {
- System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+share+
+ System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+toHexString(shareWithHandle)+
", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable);
}
}
@@ -362,7 +351,7 @@ public class WindowsWGLContext extends GLContextImpl {
}
if( 0 != contextHandle ) {
- share = 0; // mark as shared thx to the ARB create method
+ shareWithHandle = 0; // mark as shared thx to the ARB create method
if( 0 != temp_ctx ) {
WGL.wglMakeCurrent(0, 0);
WGL.wglDeleteContext(temp_ctx);
@@ -387,16 +376,17 @@ public class WindowsWGLContext extends GLContextImpl {
WGL.wglDeleteContext(contextHandle);
throw new GLException("Error making old context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError());
}
- if( 0 != share ) {
+ if( 0 != shareWithHandle ) {
+ // Windows can set up sharing of display lists after creation time if using GDI
// Only utilize the classic GDI 'wglShareLists' shared context method
// for traditional non ARB context.
- if ( !WGL.wglShareLists(share, contextHandle) ) {
- throw new GLException("wglShareLists(" + toHexString(share) +
+ if ( !WGL.wglShareLists(shareWithHandle, contextHandle) ) {
+ throw new GLException("wglShareLists(" + toHexString(shareWithHandle) +
", " + toHexString(contextHandle) + ") failed: werr " + GDI.GetLastError());
}
}
if (DEBUG) {
- System.err.println(getThreadName() + ": createImpl: OK (old) share "+share);
+ System.err.println(getThreadName() + ": createImpl: OK (old) share "+toHexString(shareWithHandle));
}
}