From ff9fb2d0adc81fdf25d6e26b91e1f67d8241e3e4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 26 Apr 2013 07:41:12 +0200 Subject: GLContext*'s ctxGLSLVersion: Use zeroVersion to denominate uninitialized VersionNumber instead of null, it's get*string returns a zero length string instead of null. --- src/jogl/classes/javax/media/opengl/GLContext.java | 20 +++++++++++--------- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index f303c5b1c..288329310 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -189,7 +189,7 @@ public abstract class GLContext { ctxVendorVersion = VersionNumberString.zeroVersion; ctxOptions=0; ctxVersionString=null; - ctxGLSLVersion=null; + ctxGLSLVersion = VersionNumber.zeroVersion; attachedObjects.clear(); contextHandle=0; currentSwapInterval = -1; @@ -671,7 +671,7 @@ public abstract class GLContext { * Returns the vendor's version, i.e. version number at the end of GL_VERSION not being the GL version. *

* In case no such version exists within GL_VERSION, - * the {@link VersionNumberString#zeroVersion zero version} instance is being returned. + * the {@link VersionNumberString#zeroVersion zero version} instance is returned. *

*

* The vendor's version is usually the vendor's OpenGL driver version. @@ -689,13 +689,14 @@ public abstract class GLContext { * via {@link GL2ES2#GL_SHADING_LANGUAGE_VERSION} if ≥ ES2.0 or GL2.0, * otherwise a static match is being utilized. *

- * The context must have been current once, otherwise null is returned. + * The context must have been current once, + * otherwise the {@link VersionNumberString#zeroVersion zero version} instance is returned. *

*

* Examples w/ major.minor: *

-   *    1.00 (ES2.0), 1.10 (GL2.0), 1.20 (GL2.1), 1.50 GL(3.2), 
-   *    3.30 (GL3.3), 4.40 (GL4.0)
+   *    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)
    * 
*

*

@@ -704,7 +705,8 @@ public abstract class GLContext { * The latter is not true on OSX w/ a GL3 context. *

* - * @param GLSL version number if context has been made current at least once, otherwise null. + * @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() */ @@ -719,13 +721,13 @@ public abstract class GLContext { * #version 110 * *

- * If context has not been made current, null is returned. + * If context has not been made current yet, a string of zero length is returned. *

* @see #getGLSLVersionNumber() */ public final String getGLSLVersionString() { - if(null == ctxGLSLVersion) { - return null; + if( ctxGLSLVersion.isZero() ) { + return ""; } final int minor = ctxGLSLVersion.getMinor(); return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + "\n" ; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 1b8b0316c..b947bd693 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1041,17 +1041,17 @@ public abstract class GLContextImpl extends GLContext { ctxVendorVersion = glVendorVersion; ctxOptions = ctp; if(useGL) { - ctxGLSLVersion = null; + ctxGLSLVersion = VersionNumber.zeroVersion; if(major >= 2) { // >= ES2 || GL2.0 final String glslVersion = gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION); if( null != glslVersion ) { ctxGLSLVersion = new VersionNumber(glslVersion, "."); if( ctxGLSLVersion.getMajor() < 1 ) { - ctxGLSLVersion = null; // failed .. + ctxGLSLVersion = VersionNumber.zeroVersion; // failed .. } } } - if( null == ctxGLSLVersion ){ + if( ctxGLSLVersion.isZero() ) { final int[] sver = new int[2]; getStaticGLSLVersionNumber(major, minor, ctxOptions, sver); ctxGLSLVersion = new VersionNumber(sver[0], sver[1], 0); -- cgit v1.2.3