diff options
author | Sven Gothel <[email protected]> | 2013-11-13 16:43:39 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-11-13 16:43:39 +0100 |
commit | b497b2cf2c6003186fc32b8c14bdcb07cc305787 (patch) | |
tree | 8c3f318cbb413f9057b9312f7dbf9cf068625f8a | |
parent | 71f256693ddb6c383f382e99149f752c84d17075 (diff) |
Resolve compilation issues of commit 71f256693ddb6c383f382e99149f752c84d17075 (Backport of 34b35c5a0a379a6b4c0b23b9d347a0b1338f0239)b202_gl44
-rwxr-xr-x | make/scripts/make.jogl.b202_gl44.linux-x86_64.sh | 60 | ||||
-rwxr-xr-x | make/scripts/tests-b202_gl44-x64.sh | 12 | ||||
-rwxr-xr-x | make/scripts/tests.sh | 8 | ||||
-rw-r--r-- | src/jogl/classes/javax/media/opengl/GLContext.java | 192 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/GLContextImpl.java | 270 |
5 files changed, 308 insertions, 234 deletions
diff --git a/make/scripts/make.jogl.b202_gl44.linux-x86_64.sh b/make/scripts/make.jogl.b202_gl44.linux-x86_64.sh new file mode 100755 index 000000000..df0027b69 --- /dev/null +++ b/make/scripts/make.jogl.b202_gl44.linux-x86_64.sh @@ -0,0 +1,60 @@ +#! /bin/sh + +SDIR=`dirname $0` + +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +fi + +if [ "$1" = "-libdir" ] ; then + shift + if [ -z "$1" ] ; then + echo libdir argument missing + print_usage + exit + fi + CUSTOMLIBDIR="-Dcustom.libdir=$1" + shift +fi + +# -Dc.compiler.debug=true \ + +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxAMD64=true \ +# -DisX11=true \ +# +# -Dtarget.sourcelevel=1.6 \ +# -Dtarget.targetlevel=1.6 \ +# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ +# +# -Dsetup.addNativeOpenMAX=true \ +# -Dsetup.addNativeKD=true \ + + +#LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64 +#export LD_LIBRARY_PATH + +LOGF=make.jogl.b202_gl44.linux-x86_64.log +rm -f $LOGF + +# export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri +# export LIBGL_DEBUG=verbose +echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a $LOGF +echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $LOGF +echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF + +# -Dc.compiler.debug=true \ +# -Djavacdebug="true" \ +# -Djavacdebuglevel="source,lines,vars" \ + +# BUILD_ARCHIVE=true \ +ant \ + $CUSTOMLIBDIR \ + -Dtarget.sourcelevel=1.6 \ + -Dtarget.targetlevel=1.6 \ + -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ + -Drootrel.build=build-b202_gl44-x86_64 \ + $* 2>&1 | tee -a $LOGF + diff --git a/make/scripts/tests-b202_gl44-x64.sh b/make/scripts/tests-b202_gl44-x64.sh new file mode 100755 index 000000000..cbfd3b1f7 --- /dev/null +++ b/make/scripts/tests-b202_gl44-x64.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +SDIR=`dirname $0` + +#export LD_LIBRARY_PATH=/home/sven/libav/lib:$LD_LIBRARY_PATH + +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +fi + +. $SDIR/tests.sh `which java` -d64 ../build-b202_gl44-x86_64 $* + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7d0b3724a..f9db68264 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -145,7 +145,7 @@ function jrun() { #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" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" @@ -281,7 +281,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -298,7 +298,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT #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 $* @@ -328,7 +328,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* -#testnoawt com.jogamp.newt.opengl.GLWindow $* +testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index b1ee8115f..0050b013c 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -72,10 +72,10 @@ import com.jogamp.opengl.GLRendererQuirks; abstraction provides a stable object which clients can use to refer to a given context. */ public abstract class GLContext { - - /** - * If <code>true</code> (default), bootstrapping the available GL profiles - * will use the highest compatible GL context for each profile, + + /** + * If <code>true</code> (default), bootstrapping the available GL profiles + * will use the highest compatible GL context for each profile, * hence skipping querying lower profiles if a compatible higher one is found: * <ul> * <li>4.2-core -> 4.2-core, 3.3-core</li> @@ -91,20 +91,20 @@ public abstract class GLContext { * </ul> * Using aliasing speeds up initialization about: * <ul> - * <li>Linux x86_64 - Nvidia: 28%, 700ms down to 500ms</li> - * <li>Linux x86_64 - AMD : 40%, 1500ms down to 900ms</li> + * <li>Linux x86_64 - Nvidia: 28%, 700ms down to 500ms</li> + * <li>Linux x86_64 - AMD : 40%, 1500ms down to 900ms</li> * <p> * Can be turned off with property <code>jogl.debug.GLContext.NoProfileAliasing</code>. * </p> */ public static final boolean PROFILE_ALIASING = !Debug.isPropertyDefined("jogl.debug.GLContext.NoProfileAliasing", true); - + protected static final boolean FORCE_NO_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.none", true); protected static final boolean FORCE_MIN_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.min", true); - + public static final boolean DEBUG = Debug.debug("GLContext"); public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); - public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; + public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */ public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); @@ -130,16 +130,16 @@ public abstract class GLContext { public static final VersionNumber Version140 = new VersionNumber(1, 40, 0); /* Version 1.50, i.e. GLSL 1.50 for GL 3.2. */ public static final VersionNumber Version150 = new VersionNumber(1, 50, 0); - + /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */ public static final VersionNumber Version32 = new VersionNumber(3, 2, 0); - + /** Version 3.1. As an OpenGL version, it qualifies for {@link #isGL3core()}, {@link #isGL3bc()} and {@link #isGL3()} */ public static final VersionNumber Version31 = new VersionNumber(3, 1, 0); - + /** Version 3.0. As an OpenGL version, it qualifies for {@link #isGL2()} only */ public static final VersionNumber Version30 = new VersionNumber(3, 0, 0); - + protected static final VersionNumber Version80 = new VersionNumber(8, 0, 0); /** <code>ARB_create_context</code> related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ @@ -190,9 +190,9 @@ public abstract class GLContext { private int currentSwapInterval; protected GLRendererQuirks glRendererQuirks; - /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */ - protected boolean drawableRetargeted; - + /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */ + protected boolean drawableRetargeted; + protected void resetStates() { if (DEBUG) { System.err.println(getThreadName() + ": GLContext.resetStates()"); @@ -210,12 +210,12 @@ public abstract class GLContext { drawableRetargeted = false; } - /** + /** * Returns the instance of {@link GLRendererQuirks}, allowing one to determine workarounds. * @return instance of {@link GLRendererQuirks} if context was made current once, otherwise <code>null</code>. */ public final GLRendererQuirks getRendererQuirks() { return glRendererQuirks; } - + /** * Returns true if the <code>quirk</code> exist in {@link #getRendererQuirks()}, otherwise false. * <p> @@ -228,10 +228,10 @@ public abstract class GLContext { * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}. * @throws IllegalArgumentException if the quirk is out of range */ - public final boolean hasRendererQuirk(int quirk) throws IllegalArgumentException { - return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ; + public final boolean hasRendererQuirk(int quirk) throws IllegalArgumentException { + return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ; } - + /** * Sets the read/write drawable for framebuffer operations. * <p> @@ -244,13 +244,13 @@ public abstract class GLContext { * attempts to make this context current. Otherwise a race condition may happen. * </p> * @param readWrite The read/write drawable for framebuffer operations, maybe <code>null</code> to remove association. - * @param setWriteOnly Only change the write-drawable, if <code>setWriteOnly</code> is <code>true</code> and - * if the {@link #getGLReadDrawable() read-drawable} differs - * from the {@link #getGLDrawable() write-drawable}. + * @param setWriteOnly Only change the write-drawable, if <code>setWriteOnly</code> is <code>true</code> and + * if the {@link #getGLReadDrawable() read-drawable} differs + * from the {@link #getGLDrawable() write-drawable}. * Otherwise set both drawables, read and write. * @return The previous read/write drawable * - * @throws GLException in case <code>null</code> is being passed or + * @throws GLException in case <code>null</code> is being passed or * this context is made current on another thread. * * @see #isGLReadDrawableAvailable() @@ -259,13 +259,13 @@ public abstract class GLContext { * @see #getGLDrawable() */ public abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly); - + /** * Returns the write-drawable this context uses for framebuffer operations. * <p> * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, * it equals to the write-drawable (default). - * </p> + * </p> * @see #setGLDrawable(GLDrawable, boolean) * @see #setGLReadDrawable(GLDrawable) */ @@ -303,7 +303,7 @@ public abstract class GLContext { * <p> * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, * it equals to the write-drawable (default). - * </p> + * </p> * @see #isGLReadDrawableAvailable() * @see #setGLReadDrawable(javax.media.opengl.GLDrawable) * @see #getGLDrawable() @@ -321,9 +321,9 @@ public abstract class GLContext { * </p> * <p> * A return value of {@link #CONTEXT_CURRENT_NEW} - * indicates that that context has been made current for the 1st time, + * indicates that that context has been made current for the 1st time, * or that the state of the underlying context or drawable has - * changed since the last time this context was current. + * changed since the last time this context was current. * In this case, the application may wish to initialize the render state. * </p> * <p> @@ -345,7 +345,7 @@ public abstract class GLContext { * </p> * * @return <ul> - * <li>{@link #CONTEXT_CURRENT_NEW} if the context was successfully made current the 1st time,</li> + * <li>{@link #CONTEXT_CURRENT_NEW} if the context was successfully made current the 1st time,</li> * <li>{@link #CONTEXT_CURRENT} if the context was successfully made current,</li> * <li>{@link #CONTEXT_NOT_CURRENT} if the context could not be made current.</li> * </ul> @@ -676,16 +676,16 @@ public abstract class GLContext { /** @deprecated Use {@link #getGLVersionNumber()} */ public final int getGLVersionMinor() { return ctxVersion.getMinor(); } /** - * Returns this context OpenGL version. - * @see #getGLSLVersionNumber() + * Returns this context OpenGL version. + * @see #getGLSLVersionNumber() **/ public final VersionNumber getGLVersionNumber() { return ctxVersion; } - /** + /** * Returns the vendor's version, i.e. version number at the end of <code>GL_VERSION</code> not being the GL version. * <p> - * In case no such version exists within <code>GL_VERSION</code>, + * In case no such version exists within <code>GL_VERSION</code>, * the {@link VersionNumberString#zeroVersion zero version} instance is returned. - * </p> + * </p> * <p> * The vendor's version is usually the vendor's OpenGL driver version. * </p> @@ -702,31 +702,31 @@ public abstract class GLContext { * via {@link GL2ES2#GL_SHADING_LANGUAGE_VERSION} if ≥ ES2.0 or GL2.0, * otherwise a static match is being utilized. * <p> - * The context must have been current once, - * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. + * The context must have been current once, + * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. * </p> * <p> - * Examples w/ <code>major.minor</code>: + * Examples w/ <code>major.minor</code>: * <pre> - * 1.00 (ES 2.0), 1.10 (GL 2.0), 1.20 (GL 2.1), 1.50 (GL 3.2), + * 1.00 (ES 2.0), 1.10 (GL 2.0), 1.20 (GL 2.1), 1.50 (GL 3.2), * 3.30 (GL 3.3), 4.00 (GL 4.0), 4.10 (GL 4.1), 4.20 (GL 4.2) * </pre > * </p> * <p> * <i>Matching</i> could also refer to the maximum GLSL version usable by this context * since <i>normal</i> GL implementations are capable of using a lower GLSL version as well. - * The latter is not true on OSX w/ a GL3 context. + * The latter is not true on OSX w/ a GL3 context. * </p> - * - * @return GLSL version number if context has been made current at least once, + * + * @return GLSL version number if context has been made current at least once, * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. - * + * * @see #getGLVersionNumber() */ public final VersionNumber getGLSLVersionNumber() { return ctxGLSLVersion; } - + /** * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n', * i.e.: @@ -745,7 +745,7 @@ public abstract class GLContext { final int minor = ctxGLSLVersion.getMinor(); return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + "\n" ; } - + protected static final VersionNumber getStaticGLSLVersionNumber(int glMajorVersion, int glMinorVersion, int ctxOptions) { if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) { return Version100; // ES 2.0 -> GLSL 1.00 @@ -760,13 +760,13 @@ public abstract class GLContext { switch ( glMinorVersion ) { case 0: return Version130; // GL 3.0 -> GLSL 1.30 case 1: return Version140; // GL 3.1 -> GLSL 1.40 - default: return Version150; // GL 3.2 -> GLSL 1.50 + default: return Version150; // GL 3.2 -> GLSL 1.50 } } else { // >= 3.3 return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N } } - + /** * @return true if this context is an ES2 context or implements * the extension <code>GL_ARB_ES2_compatibility</code>, otherwise false @@ -775,18 +775,18 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_ES2_COMPAT ) ; } - /** + /** * @return true if impl. is a hardware rasterizer, otherwise false. * @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile) - * @see GLProfile#isHardwareRasterizer() + * @see GLProfile#isHardwareRasterizer() */ public final boolean isHardwareRasterizer() { return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ; } - + /** * @return true if context supports GLSL, i.e. is either {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} <i>and</i> major-version > 1. - * @see GLProfile#hasGLSL() + * @see GLProfile#hasGLSL() */ public final boolean hasGLSL() { return isGLES2() || @@ -794,7 +794,7 @@ public abstract class GLContext { isGL2() && ctxVersion.getMajor()>1 ; } - /** + /** * Returns <code>true</code> if basic FBO support is available, otherwise <code>false</code>. * <p> * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions @@ -810,21 +810,21 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; } - /** + /** * Returns <code>true</code> if full FBO support is available, otherwise <code>false</code>. * <p> * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions * <code>ARB_framebuffer_object</code>, or all of - * <code>EXT_framebuffer_object</code>, <code>EXT_framebuffer_multisample</code>, + * <code>EXT_framebuffer_object</code>, <code>EXT_framebuffer_multisample</code>, * <code>EXT_framebuffer_blit</code>, <code>GL_EXT_packed_depth_stencil</code>. * </p> * <p> * Full FBO support includes multiple color attachments and multisampling. * </p> */ - public final boolean hasFullFBOSupport() { + public final boolean hasFullFBOSupport() { return hasBasicFBOSupport() && !hasRendererQuirk(GLRendererQuirks.NoFullFBOSupport) && - ( isGL3() || // GL >= 3.0 + ( isGL3() || // GL >= 3.0 isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && @@ -833,10 +833,10 @@ public abstract class GLContext { ) ) ; } - + /** * Returns the maximum number of FBO RENDERBUFFER samples - * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. + * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. */ public final int getMaxRenderbufferSamples() { if( hasFullFBOSupport() ) { @@ -854,7 +854,7 @@ public abstract class GLContext { } return 0; } - + /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns <code>true</code>. */ public boolean isNPOTTextureAvailable() { return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two); @@ -883,7 +883,7 @@ public abstract class GLContext { return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_CORE); } - + /** @see GLProfile#isGL3bc() */ public final boolean isGL3bc() { return ctxVersion.compareTo(Version31) >= 0 @@ -897,20 +897,20 @@ public abstract class GLContext { && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } - + /** Indicates whether this profile is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1 <p>Includes [ GL4, GL3 ].</p> */ public final boolean isGL3core() { return ctxVersion.compareTo(Version31) >= 0 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_CORE); } - + /** @see GLProfile#isGL2() */ public final boolean isGL2() { return ctxVersion.getMajor()>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT); } - /** @see GLProfile#isGL2GL3() */ + /** @see GLProfile#isGL2GL3() */ public final boolean isGL2GL3() { return isGL2() || isGL3(); } @@ -971,7 +971,7 @@ public abstract class GLContext { * </p> * <p> * For a valid context the default value is <code>1</code> - * in case of an EGL based profile (ES1 or ES2) and <code>-1</code> + * in case of an EGL based profile (ES1 or ES2) and <code>-1</code> * (undefined) for desktop. * </p> */ @@ -1008,51 +1008,51 @@ public abstract class GLContext { } protected boolean bindSwapBarrierImpl(int group, int barrier) { /** nop per default .. **/ return false; } - /** - * Return the framebuffer name bound to this context, + /** + * Return the framebuffer name bound to this context, * see {@link GL#glBindFramebuffer(int, int)}. */ public abstract int getBoundFramebuffer(int target); - - /** + + /** * Return the default draw framebuffer name. - * <p> + * <p> * May differ from it's default <code>zero</code> * in case an framebuffer object ({@link FBObject}) based drawable * is being used. - * </p> + * </p> */ public abstract int getDefaultDrawFramebuffer(); - - /** + + /** * Return the default read framebuffer name. - * <p> + * <p> * May differ from it's default <code>zero</code> * in case an framebuffer object ({@link FBObject}) based drawable * is being used. - * </p> + * </p> */ public abstract int getDefaultReadFramebuffer(); - - /** - * Returns the default color buffer within the current bound - * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​, - * which will be used as the source for pixel reading commands, + + /** + * Returns the default color buffer within the current bound + * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​, + * which will be used as the source for pixel reading commands, * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)} etc. * <p> * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0}, - * otherwise this is {@link GL#GL_FRONT} for single buffer configurations + * otherwise this is {@link GL#GL_FRONT} for single buffer configurations * and {@link GL#GL_BACK} for double buffer configurations. - * </p> + * </p> */ public abstract int getDefaultReadBuffer(); - + /** Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ public abstract int getDefaultPixelDataType(); - + /** Get the default pixel data format, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ public abstract int getDefaultPixelDataFormat(); - + /** * @return The extension implementing the GLDebugOutput feature, * either <i>GL_ARB_debug_output</i> or <i>GL_AMD_debug_output</i>. @@ -1314,7 +1314,7 @@ public abstract class GLContext { deviceVersionsAvailableSet.add(devKey); if (DEBUG) { System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey); - System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); + System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); } } } @@ -1398,7 +1398,7 @@ public abstract class GLContext { } return val; } - + /** * @param reqMajor Key Value either 1, 2, 3 or 4 * @param reqProfile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} @@ -1470,7 +1470,7 @@ public abstract class GLContext { reqMajorCTP[1]=CTX_PROFILE_CORE; } } - + /** * @param device the device the context profile is being requested for * @param GLProfile the GLProfile the context profile is being requested for @@ -1479,7 +1479,7 @@ public abstract class GLContext { protected static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp) { final int[] reqMajorCTP = new int[] { 0, 0 }; getRequestMajorAndCompat(glp, reqMajorCTP); - + int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; @@ -1525,7 +1525,7 @@ public abstract class GLContext { * Returns true if it is possible to create an <i>framebuffer object</i> (FBO). * <p> * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. - * </p> + * </p> * <p> * FBO support is queried as described in {@link #hasBasicFBOSupport()}. * </p> @@ -1537,16 +1537,16 @@ public abstract class GLContext { public static final boolean isFBOAvailable(AbstractGraphicsDevice device, GLProfile glp) { return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) ); } - + /** - * @return <code>1</code> if using a hardware rasterizer, <code>0</code> if using a software rasterizer and <code>-1</code> if not determined yet. + * @return <code>1</code> if using a hardware rasterizer, <code>0</code> if using a software rasterizer and <code>-1</code> if not determined yet. * @see GLContext#isHardwareRasterizer() - * @see GLProfile#isHardwareRasterizer() + * @see GLProfile#isHardwareRasterizer() */ public static final int isHardwareRasterizer(AbstractGraphicsDevice device, GLProfile glp) { final int r; final int ctp = getAvailableContextProperties(device, glp); - if(0 == ctp) { + if(0 == ctp) { r = -1; } else if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { r = 1; @@ -1555,7 +1555,7 @@ public abstract class GLContext { } return r; } - + /** * @param device the device to request whether the profile is available for * @param reqMajor Key Value either 1, 2, 3 or 4 @@ -1652,6 +1652,6 @@ public abstract class GLContext { } protected 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 a9e63d2f2..93472a6ba 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -102,14 +102,14 @@ public abstract class GLContextImpl extends GLContext { private final GLStateTracker glStateTracker = new GLStateTracker(); private GLDebugMessageHandler glDebugHandler = null; private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read } - private int defaultVAO = 0; - + private int defaultVAO = 0; + protected GLDrawableImpl drawable; protected GLDrawableImpl drawableRead; - + private volatile boolean pixelDataEvaluated; private int /* pixelDataInternalFormat, */ pixelDataFormat, pixelDataType; - + protected GL gl; protected static final Object mappedContextTypeObjectLock; @@ -173,12 +173,12 @@ public abstract class GLContextImpl extends GLContext { glRenderer = glVendor; glRendererLowerCase = glRenderer; glVersion = glVendor; - + if (boundFBOTarget != null) { // <init> boundFBOTarget[0] = 0; // draw boundFBOTarget[1] = 0; // read } - + pixelDataEvaluated = false; super.resetStates(); @@ -186,7 +186,7 @@ public abstract class GLContextImpl extends GLContext { @Override public final GLDrawable setGLReadDrawable(GLDrawable read) { - if(!isGLReadDrawableAvailable()) { + if(!isGLReadDrawableAvailable()) { throw new GLException("Setting read drawable feature not available"); } final boolean lockHeld = lock.isOwner(Thread.currentThread()); @@ -216,7 +216,7 @@ public abstract class GLContextImpl extends GLContext { final Thread currentThread = Thread.currentThread(); if( lock.isLockedByOtherThread() ) { throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName()); - } + } final boolean lockHeld = lock.isOwner(currentThread); if( lockHeld && lock.getHoldCount() > 1 ) { // would need to makeCurrent * holdCount @@ -263,6 +263,8 @@ public abstract class GLContextImpl extends GLContext { return gl; } + public final int getCtxOptions() { return ctxOptions; } + @Override public GL setGL(GL gl) { if(DEBUG) { @@ -294,7 +296,7 @@ public abstract class GLContextImpl extends GLContext { @Override public void release() throws GLException { release(false); - } + } private void release(boolean inDestruction) throws GLException { if( TRACE_SWITCH ) { System.err.println(getThreadName() +": GLContext.ContextSwitch[release.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+", inDestruction: "+inDestruction+", "+lock); @@ -312,7 +314,7 @@ public abstract class GLContextImpl extends GLContext { } throw new GLException(msg); } - + Throwable drawableContextMadeCurrentException = null; final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle; try { @@ -345,7 +347,7 @@ public abstract class GLContextImpl extends GLContext { if(null != drawableContextMadeCurrentException) { throw new GLException("GLContext.release(false) during GLDrawableImpl.contextMadeCurrent(this, false)", drawableContextMadeCurrentException); } - + } private Throwable lastCtxReleaseStack = null; protected abstract void releaseImpl() throws GLException; @@ -495,21 +497,21 @@ public abstract class GLContextImpl extends GLContext { public final int makeCurrent() throws GLException { return makeCurrent(false); } - + protected final int makeCurrent(boolean forceDrawableAssociation) throws GLException { if( TRACE_SWITCH ) { System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+lock); - } + } // Note: the surface is locked within [makeCurrent .. swap .. release] final int lockRes = drawable.lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { if( DEBUG_TRACE_SWITCH ) { - System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - Surface Not Ready - CONTEXT_NOT_CURRENT - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - Surface Not Ready - CONTEXT_NOT_CURRENT - "+lock); } return CONTEXT_NOT_CURRENT; } - + boolean unlockResources = true; // Must be cleared if successful, otherwise finally block will release context and/or surface! int res = CONTEXT_NOT_CURRENT; try { @@ -529,7 +531,7 @@ public abstract class GLContextImpl extends GLContext { drawableUpdatedNotify(); unlockResources = false; // success if( TRACE_SWITCH ) { - System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock); } return CONTEXT_CURRENT; } else { @@ -538,7 +540,7 @@ public abstract class GLContextImpl extends GLContext { } res = makeCurrentWithinLock(lockRes); unlockResources = CONTEXT_NOT_CURRENT == res; // success ? - + /** * FIXME: refactor dependence on Java 2D / JOGL bridge if ( tracker != null && res == CONTEXT_CURRENT_NEW ) { @@ -585,16 +587,16 @@ public abstract class GLContextImpl extends GLContext { if(TRACE_GL) { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } - + forceDrawableAssociation = true; } - + if( forceDrawableAssociation ) { associateDrawable(true); } - + contextMadeCurrent(true); - + /* FIXME: refactor dependence on Java 2D / JOGL bridge // Try cleaning up any stale server-side OpenGL objects @@ -606,10 +608,10 @@ public abstract class GLContextImpl extends GLContext { } if( TRACE_SWITCH ) { System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - "+makeCurrentResultToString(res)+" - "+lock); - } + } return res; } - + private final int makeCurrentWithinLock(int surfaceLockRes) throws GLException { if (!isCreated()) { if( 0 >= drawable.getWidth() || 0 >= drawable.getHeight() ) { @@ -635,7 +637,7 @@ public abstract class GLContextImpl extends GLContext { // Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296), // GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) // there is no more default VAO buffer 0 bound, hence generating and binding one - // to avoid INVALID_OPERATION at VertexAttribPointer. + // to avoid INVALID_OPERATION at VertexAttribPointer. // More clear is GL 4.3 core spec: 10.4 (p 307). final int[] tmp = new int[1]; gl.getGL2GL3().glGenVertexArrays(1, tmp, 0); @@ -664,7 +666,7 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice device = config.getScreen().getDevice(); - // Non ARB desktop profiles may not have been registered + // Non ARB desktop profiles may not have been registered if( !GLContext.getAvailableGLVersionsSet(device) ) { // not yet set if( 0 == ( ctxOptions & GLContext.CTX_PROFILE_ES) ) { // not ES profile final int reqMajor; @@ -682,10 +684,10 @@ public abstract class GLContextImpl extends GLContext { GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); GLContext.setAvailableGLVersionsSet(device); - + if (DEBUG) { System.err.println(getThreadName() + ": createContextOLD-MapVersionsAvailable HAVE: " + device+" -> "+reqMajor+"."+reqProfile+ " -> "+getGLVersion()); - } + } } } } @@ -698,17 +700,17 @@ public abstract class GLContextImpl extends GLContext { protected abstract void makeCurrentImpl() throws GLException; /** - * Calls {@link GLDrawableImpl#associateContext(GLContext, boolean)} - */ - protected void associateDrawable(boolean bound) { - drawable.associateContext(this, bound); + * Calls {@link GLDrawableImpl#associateContext(GLContext, boolean)} + */ + protected void associateDrawable(boolean bound) { + drawable.associateContext(this, bound); } - + /** - * Calls {@link GLDrawableImpl#contextMadeCurrent(GLContext, boolean)} - */ + * Calls {@link GLDrawableImpl#contextMadeCurrent(GLContext, boolean)} + */ protected void contextMadeCurrent(boolean current) { - drawable.contextMadeCurrent(this, current); + drawable.contextMadeCurrent(this, current); } /** @@ -808,7 +810,7 @@ public abstract class GLContextImpl extends GLContext { final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final int[] reqMajorCTP = new int[] { 0, 0 }; getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP); - + int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; @@ -823,7 +825,7 @@ public abstract class GLContextImpl extends GLContext { } return _ctx; } - + private final boolean mapGLVersions(AbstractGraphicsDevice device) { synchronized (GLContext.deviceVersionAvailable) { final long t0 = ( DEBUG ) ? System.nanoTime() : 0; @@ -843,7 +845,7 @@ public abstract class GLContextImpl extends GLContext { success |= hasGL4; if(hasGL4) { // Map all lower compatible profiles: GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); if(PROFILE_ALIASING) { hasGL3 = true; } @@ -854,7 +856,7 @@ public abstract class GLContextImpl extends GLContext { hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 success |= hasGL3; if(hasGL3) { - resetStates(); // clean this context states, since creation was temporary + resetStates(); // clean this context states, since creation was temporary } } if(!hasGL4bc) { @@ -899,7 +901,7 @@ public abstract class GLContextImpl extends GLContext { hasGL2 = createContextARBMapVersionsAvailable(2, CTX_PROFILE_COMPAT); // GL2 success |= hasGL2; if(hasGL2) { - resetStates(false); // clean this context states, since creation was temporary + resetStates(); // clean this context states, since creation was temporary } } if(success) { @@ -908,7 +910,7 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { final long t1 = System.nanoTime(); System.err.println("GLContextImpl.mapGLVersions: "+device+", profileAliasing: "+PROFILE_ALIASING+", total "+(t1-t0)/1e6 +"ms"); - System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); + System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); } } else if (DEBUG) { System.err.println(getThreadName() + ": createContextARB-MapVersions NONE for :"+device); @@ -917,9 +919,9 @@ public abstract class GLContextImpl extends GLContext { } } - /** + /** * Note: Since context creation is temporary, caller need to issue {@link #resetStates()}, if creation was successful, i.e. returns true. - * This method does not reset the states, allowing the caller to utilize the state variables. + * This method does not reset the states, allowing the caller to utilize the state variables. **/ private final boolean createContextARBMapVersionsAvailable(int reqMajor, int reqProfile) { long _context; @@ -1034,7 +1036,7 @@ public abstract class GLContextImpl extends GLContext { if ( 0 == ctp ) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - + ctxVersion = new VersionNumber(major, minor, 0); ctxVersionString = getGLVersion(major, minor, ctxOptions, glVersion); ctxVendorVersion = glVendorVersion; @@ -1052,10 +1054,10 @@ public abstract class GLContextImpl extends GLContext { if( ctxGLSLVersion.isZero() ) { ctxGLSLVersion = getStaticGLSLVersionNumber(major, minor, ctxOptions); } - } + } } } - + //---------------------------------------------------------------------- // Helpers for various context implementations // @@ -1161,7 +1163,7 @@ public abstract class GLContextImpl extends GLContext { return false; } glVendor = _glVendor; - + final String _glRenderer = glGetStringInt(GL.GL_RENDERER, _glGetString); if(null == _glRenderer) { if(DEBUG) { @@ -1172,7 +1174,7 @@ public abstract class GLContextImpl extends GLContext { } glRenderer = _glRenderer; glRendererLowerCase = glRenderer.toLowerCase(); - + final String _glVersion = glGetStringInt(GL.GL_VERSION, _glGetString); if(null == _glVersion) { // FIXME @@ -1183,7 +1185,7 @@ public abstract class GLContextImpl extends GLContext { return false; } glVersion = _glVersion; - + return true; } } @@ -1213,7 +1215,7 @@ public abstract class GLContextImpl extends GLContext { * version for given arrays. * <p> * If the GL query fails, major will be zero. - * </p> + * </p> * <p> * Note: Non ARB ctx is limited to GL 3.0. * </p> @@ -1227,14 +1229,14 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { Thread.dumpStack(); } - return false; + return false; } else { glGetIntegervInt(GL2GL3.GL_MAJOR_VERSION, glIntMajor, 0, _glGetIntegerv); glGetIntegervInt(GL2GL3.GL_MINOR_VERSION, glIntMinor, 0, _glGetIntegerv); return true; } } - + /** * Sets the OpenGL implementation class and * the cache of which GL functions are available for calling through this @@ -1254,8 +1256,8 @@ public abstract class GLContextImpl extends GLContext { * <li>be greater or equal than the requested <code>major.minor</code> version, and</li> * <li>match the ctxProfileBits</li> * </ul>, otherwise method aborts and returns <code>false</code>. - * @return returns <code>true</code> if successful, otherwise <code>false</code>. See <code>strictMatch</code>. - * If <code>false</code> is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc. + * @return returns <code>true</code> if successful, otherwise <code>false</code>. See <code>strictMatch</code>. + * If <code>false</code> is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc. * @see #setContextVersion * @see javax.media.opengl.GLContext#CTX_OPTION_ANY * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT @@ -1266,10 +1268,10 @@ public abstract class GLContextImpl extends GLContext { return true; // already done and not forced } - if ( 0 < major && !GLContext.isValidGLVersion(major, minor) ) { + if ( 0 < major && !GLContext.isValidGLVersion(ctxProfileBits, major, minor) ) { throw new GLException("Invalid GL Version Request "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } - + if(null==this.gl || !verifyInstance(gl.getGLProfile(), "Impl", this.gl)) { setGL( createGL( getGLDrawable().getGLProfile() ) ); } @@ -1277,7 +1279,7 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - + { final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings(); if( !initGLRendererAndGLVersionStringsOK ) { @@ -1296,7 +1298,7 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Given "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)); } } - + // // Validate GL version either by GL-Integer or GL-String // @@ -1306,8 +1308,8 @@ public abstract class GLContextImpl extends GLContext { boolean versionValidated = false; boolean versionGL3IntFailed = false; { - // Validate the requested version w/ the GL-version from an integer query. - final int[] glIntMajor = new int[] { 0 }, glIntMinor = new int[] { 0 }; + // Validate the requested version w/ the GL-version from an integer query. + final int[] glIntMajor = new int[] { 0 }, glIntMinor = new int[] { 0 }; final boolean getGLIntVersionOK = getGLIntVersion(glIntMajor, glIntMinor, ctxProfileBits); if( !getGLIntVersionOK ) { final String errMsg = "Fetching GL Integer Version failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null); @@ -1321,11 +1323,11 @@ public abstract class GLContextImpl extends GLContext { // unusable GL context - non query mode - hard fail! throw new GLException(errMsg); } - } + } if (DEBUG) { 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]) ) { // relaxed match for versions major < 3 requests, last resort! @@ -1350,7 +1352,7 @@ public abstract class GLContextImpl extends GLContext { if (DEBUG) { 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 != hasGLVersionNumber ) { // relaxed match for versions major < 3 requests, last resort! @@ -1364,7 +1366,7 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionNumber); } - return false; + return false; } // Use returned GL version! major = hasGLVersionNumber.getMajor(); @@ -1376,27 +1378,27 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, No GL version validation possible: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion); } - return false; + 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); } 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 ) ; + ctxProfileBits &= ~ ( GLContext.CTX_IMPL_ES2_COMPAT /** | GLContext.CTX_IMPL_ES3_COMPAT (does not exist in this branch) */ ) ; } - + final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion); - + setRendererQuirks(adevice, major, minor, ctxProfileBits, vendorVersion); - + if( strictMatch && glRendererQuirks.exist(GLRendererQuirks.GLNonCompliant) ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL is not compliant: "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)+", "+glRenderer); } return false; } - + if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; } @@ -1458,44 +1460,44 @@ public abstract class GLContextImpl extends GLContext { } } } - + if( ( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && major >= 2 ) || isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) ) { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; ctxProfileBits |= CTX_IMPL_FBO; } else if( hasFBOImpl(major, ctxProfileBits, extensionAvailability) ) { ctxProfileBits |= CTX_IMPL_FBO; } - + if(FORCE_NO_FBO_SUPPORT) { ctxProfileBits &= ~CTX_IMPL_FBO ; - } - + } + // // Set GL Version (complete w/ version string) // setContextVersion(major, minor, ctxProfileBits, vendorVersion, true); - + setDefaultSwapInterval(); - + final int glErrX = gl.glGetError(); // clear GL error, maybe caused by above operations - + if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: OK "+contextFQN+" - "+GLContext.getGLVersion(ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions, null)+" - glErr "+toHexString(glErrX)); } return true; } - + private final void setRendererQuirks(final AbstractGraphicsDevice adevice, int major, int minor, int ctp, final VersionNumberString vendorVersion) { int[] quirks = new int[GLRendererQuirks.COUNT + 1]; // + 1 ( NoFullFBOSupport ) int i = 0; - + final String MesaSP = "Mesa "; final boolean hwAccel = 0 == ( ctp & GLContext.CTX_IMPL_ACCEL_SOFT ); final boolean compatCtx = 0 != ( ctp & GLContext.CTX_PROFILE_COMPAT ); final boolean isDriverMesa = glRenderer.contains(MesaSP) || glRenderer.contains("Gallium "); final boolean isDriverATICatalyst = !isDriverMesa && ( glVendor.contains("ATI Technologies") || glRenderer.startsWith("ATI ") ); final boolean isDriverNVIDIAGeForce = !isDriverMesa && ( glVendor.contains("NVIDIA Corporation") || glRenderer.contains("NVIDIA ") ); - + // // OS related quirks // @@ -1510,7 +1512,7 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - + final VersionNumber OSXVersion173 = new VersionNumber(1,7,3); if( Platform.getOSVersionNumber().compareTo(OSXVersion173) < 0 && isDriverNVIDIAGeForce ) { final int quirk = GLRendererQuirks.GLFlushBeforeRelease; @@ -1519,7 +1521,7 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) { + } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) { // // WINDOWS // @@ -1530,28 +1532,28 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - + if( isDriverATICatalyst ) { - final VersionNumber winXPVersionNumber = new VersionNumber ( 5, 1, 0); - final VersionNumber amdSafeMobilityVersion = new VersionNumber(12, 102, 3); - + final VersionNumber winXPVersionNumber = new VersionNumber ( 5, 1, 0); + final VersionNumber amdSafeMobilityVersion = new VersionNumber(12, 102, 3); + if ( vendorVersion.compareTo(amdSafeMobilityVersion) < 0 ) { // includes: vendorVersion.isZero() final int quirk = GLRendererQuirks.NeedCurrCtx4ARBCreateContext; if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", [Vendor "+glVendor+" or Renderer "+glRenderer+"], driverVersion "+vendorVersion); } - quirks[i++] = quirk; + quirks[i++] = quirk; } - + if( Platform.getOSVersionNumber().compareTo(winXPVersionNumber) <= 0 ) { final int quirk = GLRendererQuirks.NeedCurrCtx4ARBPixFmtQueries; if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS-Version "+Platform.getOSType()+" "+Platform.getOSVersionNumber()+", [Vendor "+glVendor+" or Renderer "+glRenderer+"]"); } - quirks[i++] = quirk; + quirks[i++] = quirk; } } - } else if( Platform.OSType.ANDROID == Platform.getOSType() ) { + } else if( Platform.OSType.ANDROID == Platform.getOSType() ) { // // ANDROID // @@ -1564,7 +1566,7 @@ public abstract class GLContextImpl extends GLContext { quirks[i++] = quirk; } } - + // // Windowing Toolkit related quirks // @@ -1601,8 +1603,8 @@ public abstract class GLContextImpl extends GLContext { } } } - - + + // // RENDERER related quirks // @@ -1633,8 +1635,8 @@ public abstract class GLContextImpl extends GLContext { } if( Platform.getOSType() == Platform.OSType.WINDOWS && glRenderer.contains("SVGA3D") ) { - final VersionNumber mesaSafeFBOVersion = new VersionNumber(8, 0, 0); - if ( vendorVersion.compareTo(mesaSafeFBOVersion) < 0 ) { // includes: vendorVersion.isZero() + final VersionNumber mesaSafeFBOVersion = new VersionNumber(8, 0, 0); + if ( vendorVersion.compareTo(mesaSafeFBOVersion) < 0 ) { // includes: vendorVersion.isZero() final int quirk = GLRendererQuirks.NoFullFBOSupport; if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer + " / Mesa-Version "+vendorVersion); @@ -1643,7 +1645,7 @@ public abstract class GLContextImpl extends GLContext { } } } - + // // Property related quirks // @@ -1652,28 +1654,28 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: property"); } - quirks[i++] = quirk; + quirks[i++] = quirk; } - + glRendererQuirks = new GLRendererQuirks(quirks, 0, i); } - + private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) { return ( 0 != (ctp & CTX_PROFILE_ES) && major >= 2 ) || // ES >= 2.0 - - major >= 3 || // any >= 3.0 GL ctx - + + major >= 3 || // any >= 3.0 GL ctx + ( null != extCache && - + extCache.isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) || // ES 2.0 compatible - + extCache.isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object - + extCache.isExtensionAvailable(GLExtensions.EXT_framebuffer_object) || // EXT_framebuffer_object - - extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ; // OES_framebuffer_object excluded + + extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ; // OES_framebuffer_object excluded } - + private final void removeCachedVersion(int major, int minor, int ctxProfileBits) { if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; @@ -1833,7 +1835,7 @@ public abstract class GLContextImpl extends GLContext { evalPixelDataType(); return pixelDataFormat; } - + private final void evalPixelDataType() { if(!pixelDataEvaluated) { synchronized(this) { @@ -1841,20 +1843,20 @@ public abstract class GLContextImpl extends GLContext { /* if(isGL2GL3() && 3 == components) { pixelDataInternalFormat=GL.GL_RGB; pixelDataFormat=GL.GL_RGB; - pixelDataType = GL.GL_UNSIGNED_BYTE; + pixelDataType = GL.GL_UNSIGNED_BYTE; } else */ if(isGLES2Compatible() || isExtensionAvailable(GLExtensions.OES_read_format)) { final int[] glImplColorReadVals = new int[] { 0, 0 }; gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_FORMAT, glImplColorReadVals, 0); - gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1); + gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1); // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; pixelDataFormat = glImplColorReadVals[0]; pixelDataType = glImplColorReadVals[1]; } else { - // RGBA read is safe for all GL profiles + // RGBA read is safe for all GL profiles // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; pixelDataFormat=GL.GL_RGBA; pixelDataType = GL.GL_UNSIGNED_BYTE; - } + } // TODO: Consider: // return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1; pixelDataEvaluated = true; @@ -1881,7 +1883,7 @@ public abstract class GLContextImpl extends GLContext { public final GLStateTracker getGLStateTracker() { return glStateTracker; } - + public final boolean isDefaultVAO(int vao) { return defaultVAO == vao; } @@ -1891,48 +1893,48 @@ public abstract class GLContextImpl extends GLContext { // current on the OpenGL worker thread // - /** + /** * Returns true if the given thread is owner, otherwise false. * <p> * Method exists merely for code validation of {@link #isCurrent()}. - * </p> + * </p> */ public final boolean isOwner(Thread thread) { return lock.isOwner(thread); } - - /** + + /** * Returns true if there are other threads waiting for this GLContext to {@link #makeCurrent()}, otherwise false. * <p> * Since method does not perform any synchronization, accurate result are returned if lock is hold - only. - * </p> + * </p> */ public final boolean hasWaiters() { return lock.getQueueLength()>0; } - - /** + + /** * Returns the number of hold locks. See {@link RecursiveLock#getHoldCount()} for semantics. * <p> * Since method does not perform any synchronization, accurate result are returned if lock is hold - only. - * </p> + * </p> */ public final int getLockCount() { return lock.getHoldCount(); } - + //--------------------------------------------------------------------------- // Special FBO hook // - + /** * Tracks {@link GL#GL_FRAMEBUFFER}, {@link GL2GL3#GL_DRAW_FRAMEBUFFER} and {@link GL2GL3#GL_READ_FRAMEBUFFER} * to be returned via {@link #getBoundFramebuffer(int)}. - * + * * <p>Invoked by {@link GL#glBindFramebuffer(int, int)}. </p> - * - * <p>Assumes valid <code>framebufferName</code> range of [0..{@link Integer#MAX_VALUE}]</p> - * + * + * <p>Assumes valid <code>framebufferName</code> range of [0..{@link Integer#MAX_VALUE}]</p> + * * <p>Does not throw an exception if <code>target</code> is unknown or <code>framebufferName</code> invalid.</p> */ public final void setBoundFramebuffer(int target, int framebufferName) { @@ -1965,14 +1967,14 @@ public abstract class GLContextImpl extends GLContext { throw new InternalError("Invalid FBO target name: "+toHexString(target)); } } - + @Override - public final int getDefaultDrawFramebuffer() { return drawable.getDefaultDrawFramebuffer(); } + public final int getDefaultDrawFramebuffer() { return drawable.getDefaultDrawFramebuffer(); } @Override - public final int getDefaultReadFramebuffer() { return drawable.getDefaultReadFramebuffer(); } + public final int getDefaultReadFramebuffer() { return drawable.getDefaultReadFramebuffer(); } @Override public final int getDefaultReadBuffer() { return drawable.getDefaultReadBuffer(gl); } - + //--------------------------------------------------------------------------- // GL_ARB_debug_output, GL_AMD_debug_output helpers // @@ -2061,7 +2063,7 @@ public abstract class GLContextImpl extends GLContext { /** Internal bootstraping glGetString(GL_RENDERER) */ protected static native String glGetStringInt(int name, long procAddress); - + /** Internal bootstraping glGetIntegerv(..) for version */ - protected static native void glGetIntegervInt(int pname, int[] params, int params_offset, long procAddress); + protected static native void glGetIntegervInt(int pname, int[] params, int params_offset, long procAddress); } |