From fbbc153150faecdaa7f37c15eb03fc484276bb40 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Sep 2014 07:16:58 +0200 Subject: Bug 1058 - Fix GLContext.getGLSLVersionString(): Add 'profile' after version for GLSL >= 150 allowing GLSL compatibility profile --- src/jogl/classes/javax/media/opengl/GLContext.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 8266e84c9..8617df95c 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -148,6 +148,8 @@ public abstract class GLContext { protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0); + private static final String S_EMPTY = ""; + // // Cached keys, bits [0..15] // @@ -818,8 +820,8 @@ public abstract class GLContext { *
    *    #version 110
    *    ..
-   *    #version 150
-   *    #version 330
+   *    #version 150 core
+   *    #version 330 compatibility
    *    ...
    * 
* And for ES: @@ -835,11 +837,20 @@ public abstract class GLContext { */ public final String getGLSLVersionString() { if( ctxGLSLVersion.isZero() ) { - return ""; + return S_EMPTY; } final int minor = ctxGLSLVersion.getMinor(); - final String esSuffix = isGLES() && ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : ""; - return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + esSuffix + "\n" ; + final String profileOpt; + if( isGLES() ) { + profileOpt = ctxGLSLVersion.compareTo(Version300) >= 0 ? " es" : S_EMPTY; + } else if( isGLCoreProfile() ) { + profileOpt = ctxGLSLVersion.compareTo(Version150) >= 0 ? " core" : S_EMPTY; + } else if( isGLCompatibilityProfile() ) { + profileOpt = ctxGLSLVersion.compareTo(Version150) >= 0 ? " compatibility" : S_EMPTY; + } else { + throw new InternalError("Neither ES, Core nor Compat: "+this); // see validateProfileBits(..) + } + return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + profileOpt + "\n" ; } protected static final VersionNumber getStaticGLSLVersionNumber(final int glMajorVersion, final int glMinorVersion, final int ctxOptions) { -- cgit v1.2.3