diff options
-rwxr-xr-x | make/scripts/tests-win.bat | 4 | ||||
-rwxr-xr-x | make/scripts/tests-x64-dbg.bat | 3 | ||||
-rw-r--r-- | make/scripts/tests.sh | 9 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLContext.java | 111 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java | 7 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 83 |
6 files changed, 119 insertions, 98 deletions
diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index c1da671b1..90226c28d 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -65,7 +65,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -134,7 +134,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index f7ee7b995..7c30d4db3 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -20,6 +20,7 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\% echo CP_ALL %CP_ALL%
+set D_ARGS="-Djogamp.debug=all"
REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject"
REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery"
REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK"
@@ -52,7 +53,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.Til REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer"
REM set D_ARGS="-Dnewt.debug.Window"
REM set D_ARGS="-Dnewt.debug.Window.KeyEvent"
-set D_ARGS="-Dnewt.debug.Window.MouseEvent"
+REM set D_ARGS="-Dnewt.debug.Window.MouseEvent"
REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent"
REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display"
REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL"
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9ada56c45..ece235a60 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -153,10 +153,9 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" - ##D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" - ##D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" + D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" @@ -314,7 +313,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* @@ -323,7 +322,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # tile rendring / printing w/ & w/o AWT diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index bd6867359..9f2e96781 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1362,7 +1362,7 @@ public abstract class GLContext { /* 1.*/ { 0, 1, 2, 3, 4, 5 }, /* 2.*/ { 0, 1 }, /* 3.*/ { 0, 1, 2, 3 }, - /* 4.*/ { 0, 1, 2, 3 } }; + /* 4.*/ { 0, 1, 2, 3, 4 } }; public static final int ES_VERSIONS[][] = { /* 0.*/ { -1 }, @@ -1387,51 +1387,100 @@ public abstract class GLContext { } } + /** + * Returns true, if the major.minor is not inferior to the lowest + * valid version and does not exceed the highest known major number by more than one. + * <p> + * The minor version number is ignored by the upper limit validation + * and the major version number may exceed by one. + * </p> + * <p> + * The upper limit check is relaxed since we don't want to cut-off + * unforseen new GL version since the release of JOGL. + * </p> + * <p> + * Hence it is important to iterate through GL version from the upper limit + * and {@link #decrementGLVersion(int, int[], int[])} until invalid. + * </p> + */ public static final boolean isValidGLVersion(int ctxProfile, int major, int minor) { if( 1>major || 0>minor ) { return false; } - if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { - if( major>=ES_VERSIONS.length) return false; - if( minor>=ES_VERSIONS[major].length) return false; + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( major >= ES_VERSIONS.length + 1 ) return false; } else { - if( major>=GL_VERSIONS.length) return false; - if( minor>=GL_VERSIONS[major].length) return false; + if( major>=GL_VERSIONS.length + 1 ) return false; } return true; } - public static final boolean decrementGLVersion(int ctxProfile, int major[], int minor[]) { - if(null==major || major.length<1 ||null==minor || minor.length<1) { - throw new GLException("invalid array arguments"); - } - int m = major[0]; - int n = minor[0]; - if( !isValidGLVersion(ctxProfile, m, n) ) { - return false; + /** + * Clip the given GL version to the maximum known valid version if exceeding. + * @return true if clipped, i.e. given value exceeds maximum, otherwise false. + */ + public static final boolean clipGLVersion(int ctxProfile, int major[], int minor[]) { + final int m = major[0]; + final int n = minor[0]; + + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( m >= ES_VERSIONS.length ) { + major[0] = ES_VERSIONS.length - 1; + minor[0] = ES_VERSIONS[major[0]].length - 1; + return true; + } + if( n >= ES_VERSIONS[m].length ) { + minor[0] = ES_VERSIONS[m].length - 1; + return true; + } + } else if( m >= GL_VERSIONS.length ) { // !isES + major[0] = GL_VERSIONS.length - 1; + minor[0] = GL_VERSIONS[major[0]].length - 1; + return true; + } else if( n >= GL_VERSIONS[m].length ) { // !isES + minor[0] = GL_VERSIONS[m].length - 1; + return true; } + return false; + } - // decrement .. - n -= 1; - if(n < 0) { - if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { - if( m >= 3) { - m -= 1; + /** + * Decrement the given GL version by one + * and return true if still valid, otherwise false. + * <p> + * If the given version exceeds the maximum known valid version, + * it is {@link #clipGLVersion(int, int[], int[]) clipped} and + * true is returned. + * </p> + * + * @param ctxProfile + * @param major + * @param minor + * @return + */ + public static final boolean decrementGLVersion(int ctxProfile, int major[], int minor[]) { + if( !clipGLVersion(ctxProfile, major, minor) ) { + int m = major[0]; + int n = minor[0] - 1; + if(n < 0) { + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( m >= 3 ) { + m -= 1; + } else { + m = 0; // major decr [1,2] -> 0 + } + n = ES_VERSIONS[m].length-1; } else { - m = 0; // major decr [1,2] -> 0 + m -= 1; + n = GL_VERSIONS[m].length-1; } - n = ES_VERSIONS[m].length-1; - } else { - m -= 1; - n = GL_VERSIONS[m].length-1; } + if( !isValidGLVersion(ctxProfile, m, n) ) { + return false; + } + major[0]=m; + minor[0]=n; } - if( !isValidGLVersion(ctxProfile, m, n) ) { - return false; - } - major[0]=m; - minor[0]=n; - return true; } diff --git a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java index b8bcd2e78..8d3d207ee 100644 --- a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java +++ b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java @@ -223,14 +223,13 @@ final class ExtensionAvailabilityCache { final VersionNumber version = context.getGLVersionNumber(); int major[] = new int[] { version.getMajor() }; int minor[] = new int[] { version.getMinor() }; - while (GLContext.isValidGLVersion(ctxOptions, major[0], minor[0])) { + do{ final String GL_XX_VERSION = ( context.isGLES() ? "GL_ES_VERSION_" : "GL_VERSION_" ) + major[0] + "_" + minor[0]; availableExtensionCache.add(GL_XX_VERSION); if (DEBUG) { System.err.println(getThreadName() + ":ExtensionAvailabilityCache: Added "+GL_XX_VERSION+" to known extensions"); } - if(!GLContext.decrementGLVersion(ctxOptions, major, minor)) break; - } + } while( GLContext.decrementGLVersion(ctxOptions, major, minor) ); // put a dummy var in here so that the cache is no longer empty even if // no extensions are in the GL_EXTENSIONS string @@ -248,7 +247,7 @@ final class ExtensionAvailabilityCache { private int glExtensionCount = 0; private String glXExtensions = null; private int glXExtensionCount = 0; - private HashSet<String> availableExtensionCache = new HashSet<String>(50); + private final HashSet<String> availableExtensionCache = new HashSet<String>(50); static String getThreadName() { return Thread.currentThread().getName(); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 5f487fa6d..911a4c2be 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -853,7 +853,6 @@ public abstract class GLContextImpl extends GLContext { boolean hasGL2 = false; boolean hasGL4 = false; boolean hasGL3 = false; - boolean hasES3 = false; // Even w/ PROFILE_ALIASING, try to use true core GL profiles // ensuring proper user behavior across platforms due to different feature sets! @@ -922,13 +921,6 @@ public abstract class GLContextImpl extends GLContext { resetStates(false); // clean this context states, since creation was temporary } } - if(!hasES3) { - hasES3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_ES); // ES3 - success |= hasES3; - if(hasES3) { - resetStates(false); // clean this context states, since creation was temporary - } - } if(success) { // only claim GL versions set [and hence detected] if ARB context creation was successful GLContext.setAvailableGLVersionsSet(device); @@ -1023,8 +1015,7 @@ public abstract class GLContextImpl extends GLContext { minor[0]=minorMax; long _context=0; - while ( GLContext.isValidGLVersion(ctxOptionFlags, major[0], minor[0]) && - ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) { + do { if (DEBUG) { System.err.println(getThreadName() + ": createContextARBVersions: share "+share+", direct "+direct+", version "+major[0]+"."+minor[0]); } @@ -1039,10 +1030,8 @@ public abstract class GLContextImpl extends GLContext { } } - if(!GLContext.decrementGLVersion(ctxOptionFlags, major, minor)) { - break; - } - } + } while ( ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) && + GLContext.decrementGLVersion(ctxOptionFlags, major, minor) ); return _context; } @@ -1059,10 +1048,6 @@ public abstract class GLContextImpl extends GLContext { if ( 0 == ctp ) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - - if (!GLContext.isValidGLVersion(ctp, major, minor)) { - throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); - } ctxVersion = new VersionNumber(major, minor, 0); ctxVersionString = getGLVersion(major, minor, ctp, glVersion); ctxVendorVersion = glVendorVersion; @@ -1244,16 +1229,6 @@ public abstract class GLContextImpl extends GLContext { } /** - * We cannot promote a non ARB context to >= 3.1, reduce it to 3.0 then. - */ - private static void limitNonARBContextVersion(int[] major, int[] minor, int ctp) { - if ( 0 == (ctp & CTX_IS_ARB_CREATED) && ( major[0] > 3 || major[0] == 3 && minor[0] >= 1 ) ) { - major[0] = 3; - minor[0] = 0; - } - } - - /** * Returns null if version string is invalid, otherwise a valid instance. * <p> * Note: Non ARB ctx is limited to GL 3.0. @@ -1265,7 +1240,6 @@ public abstract class GLContextImpl extends GLContext { if ( version.isValid() ) { int[] major = new int[] { version.getMajor() }; int[] minor = new int[] { version.getMinor() }; - limitNonARBContextVersion(major, minor, ctp); if ( GLContext.isValidGLVersion(ctp, major[0], minor[0]) ) { return new VersionNumber(major[0], minor[0], 0); } @@ -1297,7 +1271,6 @@ public abstract class GLContextImpl extends GLContext { } else { glGetIntegervInt(GL2GL3.GL_MAJOR_VERSION, glIntMajor, 0, _glGetIntegerv); glGetIntegervInt(GL2GL3.GL_MINOR_VERSION, glIntMinor, 0, _glGetIntegerv); - limitNonARBContextVersion(glIntMajor, glIntMinor, ctp); return true; } } @@ -1395,21 +1368,21 @@ public abstract class GLContextImpl extends GLContext { } } if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (Int): "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (Int): "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); } // Only validate if a valid int version was fetched, otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX! if ( GLContext.isValidGLVersion(ctxProfileBits, glIntMajor[0], glIntMinor[0]) ) { - if( glIntMajor[0]<major || ( glIntMajor[0]==major && glIntMinor[0]<minor ) || 0 == major ) { - if( strictMatch && 2 < major ) { // relaxed match for versions major < 3 requests, last resort! - if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (Int): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); - } - return false; + // relaxed match for versions major < 3 requests, last resort! + if( strictMatch && major >= 3 && glIntMajor[0]<major || ( glIntMajor[0]==major && glIntMinor[0]<minor ) ) { + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (Int): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); } - major = glIntMajor[0]; - minor = glIntMinor[0]; + return false; } + // Use returned GL version! + major = glIntMajor[0]; + minor = glIntMinor[0]; versionValidated = true; } else { versionGL3IntFailed = true; @@ -1417,44 +1390,44 @@ public abstract class GLContextImpl extends GLContext { } if( !versionValidated ) { // Validate the requested version w/ the GL-version from the version string. - final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); - final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); + final VersionNumber expGLVersionNumber = new VersionNumber(major, minor, 0); + final VersionNumber hasGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (String): "+glVersion+", "+strGLVersionNumber); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (String): "+glVersion+", "+hasGLVersionNumber); } // Only validate if a valid string version was fetched -> MIN > Version || Version > MAX! - if( null != strGLVersionNumber ) { - if( strGLVersionNumber.compareTo(setGLVersionNumber) < 0 || 0 == major ) { - if( strictMatch && 2 < major ) { // relaxed match for versions major < 3 requests, last resort! - if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (String): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber); - } - return false; + if( null != hasGLVersionNumber ) { + // relaxed match for versions major < 3 requests, last resort! + if( strictMatch && major >= 3 && hasGLVersionNumber.compareTo(expGLVersionNumber) < 0 ) { + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (String): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionNumber); } - major = strGLVersionNumber.getMajor(); - minor = strGLVersionNumber.getMinor(); + return false; } if( strictMatch && versionGL3IntFailed && major >= 3 ) { if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionNumber); } return false; } + // Use returned GL version! + major = hasGLVersionNumber.getMajor(); + minor = hasGLVersionNumber.getMinor(); versionValidated = true; } } - if( strictMatch && !versionValidated && 0 < major ) { + if( strictMatch && !versionValidated ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, No GL version validation possible: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion); } return false; } if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); } - if( 2 > major ) { // there is no ES2/3-compat for a profile w/ major < 2 + if( major < 2 ) { // there is no ES2/3-compat for a profile w/ major < 2 ctxProfileBits &= ~ ( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_ES3_COMPAT ) ; } |