From 409d23cc5434f192e2c38dc172b46a05c48ffe0a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Jun 2013 18:10:58 +0200 Subject: ES3.0 GLContext: Handle ES3.0 GLSL Version Number - Static detection and 'es' suffix. --- src/jogl/classes/javax/media/opengl/GLContext.java | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 7f8213992..cc37da0ff 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -729,9 +729,19 @@ public abstract class GLContext { /** * Returns the GLSL version string as to be used in a shader program, including a terminating newline '\n', - * i.e.: + * i.e. for desktop *
    *    #version 110
+   *    ..
+   *    #version 150
+   *    #version 330
+   *    ...
+   * 
+ * And for ES: + *
+   *    #version 100
+   *    #version 300 es
+   *    ..
    * 
*

* If context has not been made current yet, a string of zero length is returned. @@ -743,14 +753,17 @@ public abstract class GLContext { return ""; } final int minor = ctxGLSLVersion.getMinor(); - return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + "\n" ; + final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version30) >= 0 ? " es" : ""; + return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + esSuffix + "\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 + if( 3 > glMajorVersion ) { + return Version100; // ES 2.0 -> GLSL 1.00 + } } else if( 1 == glMajorVersion ) { - return Version110; // GL 1.x -> GLSL 1.10 + return Version110; // GL 1.x -> GLSL 1.10 } else if( 2 == glMajorVersion ) { switch ( glMinorVersion ) { case 0: return Version110; // GL 2.0 -> GLSL 1.10 @@ -758,13 +771,13 @@ public abstract class GLContext { } } else if( 3 == glMajorVersion && 2 >= glMinorVersion ) { 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 + 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 } - } else { // >= 3.3 - return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N } + // The new default: GL >= 3.3, ES >= 3.0 + return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N } /** -- cgit v1.2.3