diff options
author | Sven Gothel <[email protected]> | 2015-03-26 16:33:55 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2015-03-26 16:33:55 +0100 |
commit | e0ed09f8e2df570a9542f606a133c8fde074cbfe (patch) | |
tree | bf6df61a15771999212290b369a88620ddc8040d /src/jogl/classes/jogamp/opengl/windows | |
parent | 590b5bed36622933f452caf1db18b4dd16a75669 (diff) |
Bug 1150 - Fix GLContextImpl.createImpl(..) NoARBCreateContext and '!ARB GL >= 3.1' issues
This fix solves the described issues below.
Test cases added for onscreen and offscreen drawables,
the latter includes Window's bitmap special case.
GLContextImpl.createImpl(..): Fix NoARBCreateContext and '!ARB GL >= 3.1' issues:
=================================================================================
GLContextImpl.createImpl(..) implementation of X11GLXContext and WindowsWGLContext
wrongly handles the case of NoARBCreateContext.
Here the !ARB created context shall allow GL >= 3.1,
since ARB context creation is disabled and 'no mix' can occur.
The latter was already intended due to failure criteris 'createContextARBTried'
in:
if( glCaps.getGLProfile().isGL3() && createContextARBTried ) {
failure("createImpl ctx !ARB but ARB is used, profile > GL2 requested");
}
Further, WindowsWGLContext treats glCaps.isBitmap()
within the 'createContextARBTried=true' case, but it shall never
tried using the ARB context creation method.
This even lead to the issue of creating a 1.1 context,
but having the ProcAddressTable being still on the GL > 2 cached table.
This is due to 'setGLFunctionAvailability(..)'.
Ensure 'setGLFunctionAvailability(..)' is functional
====================================================
Caller shall either throws an exception if method returns false
or issues a state reset.
In case 'setGLFunctionAvailability(..)' throws an exception itself,
the states are no issue.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/windows')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 966a4dcf5..a8269ad5c 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -50,7 +50,6 @@ import com.jogamp.nativewindow.NativeSurface; import com.jogamp.opengl.GLContext; import com.jogamp.opengl.GLException; import com.jogamp.opengl.GLCapabilitiesImmutable; - import com.jogamp.common.nio.Buffers; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; @@ -278,7 +277,7 @@ public class WindowsWGLContext extends GLContextImpl { * called by {@link #makeCurrentImpl()}. */ @Override - protected boolean createImpl(long shareWithHandle) { + protected boolean createImpl(long shareWithHandle) throws GLException { final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice device = config.getScreen().getDevice(); final WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl(); @@ -287,14 +286,18 @@ public class WindowsWGLContext extends GLContextImpl { isGLReadDrawableAvailable(); // trigger setup wglGLReadDrawableAvailable - if (DEBUG) { - System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+toHexString(shareWithHandle)); + final boolean createContextARBAvailable = isCreateContextARBAvail(device) && !glCaps.isBitmap(); + final boolean sharedCreatedWithARB = null != sharedContext && sharedContext.isCreatedWithARBMethod(); + if(DEBUG) { + System.err.println(getThreadName() + ": WindowsWGLContext.createImpl: START "+glCaps+", share "+toHexString(shareWithHandle)); + System.err.println(getThreadName() + ": Use ARB[avail["+getCreateContextARBAvailStr(device)+ + "], bitmap "+glCaps.isBitmap()+" -> "+createContextARBAvailable+ + "], shared "+sharedCreatedWithARB+"]"); } - boolean createContextARBTried = false; - // utilize the shared context's GLXExt in case it was using the ARB method and it already exists ; exclude BITMAP - if( null != sharedContext && sharedContext.isCreatedWithARBMethod() && !glCaps.isBitmap() ) { + // utilize the shared context's GLXExt in case it was using the ARB method and it already exists + if( createContextARBAvailable && sharedCreatedWithARB ) { if ( sharedContext.getRendererQuirks().exist( GLRendererQuirks.NeedCurrCtx4ARBCreateContext ) ) { if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) { throw new GLException("Could not make Shared Context current: "+sharedContext); @@ -327,34 +330,27 @@ public class WindowsWGLContext extends GLContextImpl { if( !setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, null == sharedContext /* withinGLVersionsMapping */) ) { // use GL_VERSION WGL.wglMakeCurrent(0, 0); // release temp context WGL.wglDeleteContext(temp_ctx); - throw new InternalError("setGLFunctionAvailability !strictMatch failed"); + throw new GLException("setGLFunctionAvailability !strictMatch failed"); } WGL.wglMakeCurrent(0, 0); // release temp context - if( !createContextARBTried ) { + if( createContextARBAvailable && !createContextARBTried ) { // is*Available calls are valid since setGLFunctionAvailability(..) was called - final boolean isProcCreateContextAttribsARBAvailable; - final boolean isExtARBCreateContextAvailable; - if( !glCaps.isBitmap() ) { // exclude ARB if BITMAP - isProcCreateContextAttribsARBAvailable = isFunctionAvailable("wglCreateContextAttribsARB"); - isExtARBCreateContextAvailable = isExtensionAvailable("WGL_ARB_create_context"); - } else { - isProcCreateContextAttribsARBAvailable = false; - isExtARBCreateContextAvailable = false; - } + final boolean isProcCreateContextAttribsARBAvailable = isFunctionAvailable("wglCreateContextAttribsARB"); + final boolean isExtARBCreateContextAvailable = isExtensionAvailable("WGL_ARB_create_context"); if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) { // initial ARB context creation contextHandle = createContextARB(shareWithHandle, true); createContextARBTried=true; if (DEBUG) { if( 0 != contextHandle ) { - System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+toHexString(shareWithHandle)); + System.err.println(getThreadName() + ": createImpl: OK (ARB, initial) share "+toHexString(shareWithHandle)); } else { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+toHexString(shareWithHandle)); + System.err.println(getThreadName() + ": createImpl: 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 "+toHexString(shareWithHandle)+ + System.err.println(getThreadName() + ": createImpl: NOT OK (ARB, initial) - extension not available - share "+toHexString(shareWithHandle)+ ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+ ", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); } @@ -378,10 +374,11 @@ public class WindowsWGLContext extends GLContextImpl { // otherwise context of similar profile but different creation method may not be share-able. WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_ctx); - throw new GLException(getThreadName()+": WindowsWGLContex.createContextImpl ctx !ARB but ARB is used, profile > GL2 requested (OpenGL >= 3.1). Requested: "+glCaps.getGLProfile()+", current: "+getGLVersion()); + throw new GLException(getThreadName()+": createImpl ctx !ARB but ARB is used, profile > GL2 requested (OpenGL >= 3.1). Requested: "+glCaps.getGLProfile()+", current: "+getGLVersion()); } if(DEBUG) { - System.err.println("WindowsWGLContext.createContext ARB not used, fall back to !ARB context "+getGLVersion()); + System.err.println(getThreadName()+": createImpl ARB not used[avail "+createContextARBAvailable+ + ", tried "+createContextARBTried+"], fall back to !ARB context "+getGLVersion()); } // continue with temp context |