aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-25 04:44:06 +0200
committerSven Gothel <[email protected]>2013-10-25 04:44:06 +0200
commit5ee57df0fab57124afb31bc65fd87e9184cf8f16 (patch)
tree88f304fefaa4e9dfc325dd56c0719dd6f3189085
parented47ed58374fe57e2d1db9b2d0af6e29595016dd (diff)
Fix Bug 872: ES3 and ES3-GLSL Version not properly Handled
GLContext: - Proper API doc for Version* fields - getStaticGLSLVersionNumber(): ES3 -> Version300 - hasGLSL(): Add ES3 ShaderCode: - addDefaultShaderPrecision(): - ES2 default precision: Don't 'tune up' default precision for fragment shader, use 'mediump' - Add ES3 default precision (equal to ES2 default precision) - requiresDefaultPrecision(): Shall returns 'true' for ES3 as well!
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java25
-rw-r--r--src/jogl/classes/javax/media/opengl/GLContext.java26
2 files changed, 35 insertions, 16 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
index 6f16cc4fe..206aa0fd7 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
@@ -65,7 +65,6 @@ import com.jogamp.common.util.VersionNumber;
* </p>
*/
public class ShaderCode {
- public static final boolean DEBUG = Debug.debug("GLSLCode");
public static final boolean DEBUG_CODE = Debug.isPropertyDefined("jogl.debug.GLSLCode", true);
/** Unique resource suffix for {@link GL2ES2#GL_VERTEX_SHADER} in source code: <code>vp</code> */
@@ -484,6 +483,7 @@ public class ShaderCode {
// Create & Compile the vertex/fragment shader objects
if(null!=shaderSource) {
if(DEBUG_CODE) {
+ System.err.println("ShaderCode.compile:");
dumpShaderSource(System.err);
}
valid=ShaderUtil.createAndCompileShader(gl, shader, shaderType,
@@ -829,9 +829,14 @@ public class ShaderCode {
// Shall we use: #ifdef GL_FRAGMENT_PRECISION_HIGH .. #endif for using highp in fragment shader if avail ?
/** Default precision of {@link GL#isGLES2() ES2} for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader}: {@value #es2_default_precision_vp} */
- public static final String es2_default_precision_vp = "\nprecision highp float;\nprecision highp int;\n";
+ public static final String es2_default_precision_vp = "\nprecision highp float;\nprecision highp int;\n/*precision lowp sampler2D;*/\n/*precision lowp samplerCube;*/\n";
/** Default precision of {@link GL#isGLES2() ES2} for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #es2_default_precision_fp} */
- public static final String es2_default_precision_fp = "\nprecision mediump float;\nprecision mediump int;\n/*precision lowp sampler2D;*/\n";
+ public static final String es2_default_precision_fp = "\nprecision mediump float;\nprecision mediump int;\n/*precision lowp sampler2D;*/\n/*precision lowp samplerCube;*/\n";
+
+ /** Default precision of {@link GL#isGLES3() ES3} for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader}: {@value #es3_default_precision_vp} */
+ public static final String es3_default_precision_vp = es2_default_precision_vp;
+ /** Default precision of {@link GL#isGLES3() ES3} for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #es3_default_precision_fp} */
+ public static final String es3_default_precision_fp = es2_default_precision_fp;
/** Default precision of GLSL &ge; 1.30 as required until &lt; 1.50 for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader} or {@link GL3#GL_GEOMETRY_SHADER geometry-shader}: {@value #gl3_default_precision_vp_gp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */
public static final String gl3_default_precision_vp_gp = "\nprecision highp float;\nprecision highp int;\n";
@@ -872,7 +877,17 @@ public class ShaderCode {
case GL2ES2.GL_VERTEX_SHADER:
defaultPrecision = es2_default_precision_vp; break;
case GL2ES2.GL_FRAGMENT_SHADER:
- defaultPrecision = es2_default_precision_vp; break;
+ defaultPrecision = es2_default_precision_fp; break;
+ default:
+ defaultPrecision = null;
+ break;
+ }
+ } else if( gl.isGLES3() ) {
+ switch ( shaderType ) {
+ case GL2ES2.GL_VERTEX_SHADER:
+ defaultPrecision = es3_default_precision_vp; break;
+ case GL2ES2.GL_FRAGMENT_SHADER:
+ defaultPrecision = es3_default_precision_fp; break;
default:
defaultPrecision = null;
break;
@@ -900,7 +915,7 @@ public class ShaderCode {
/** Returns true, if GLSL version requires default precision, i.e. ES2 or GLSL [1.30 .. 1.50[. */
public static final boolean requiresDefaultPrecision(GL2ES2 gl) {
- if( gl.isGLES2() ) {
+ if( gl.isGLES2() || gl.isGLES3() ) {
return true;
}
return requiresGL3DefaultPrecision(gl);
diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java
index 55050f25c..e83d60b66 100644
--- a/src/jogl/classes/javax/media/opengl/GLContext.java
+++ b/src/jogl/classes/javax/media/opengl/GLContext.java
@@ -118,20 +118,20 @@ public abstract class GLContext {
/** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}, value {@value}. */
public static final int CONTEXT_CURRENT_NEW = 2;
- /* Version 1.00, i.e. GLSL 1.00 for ES 2.0. */
+ /** Version 1.00, i.e. GLSL 1.00 for ES 2.0. */
public static final VersionNumber Version100 = new VersionNumber(1, 0, 0);
- /* Version 1.10, i.e. GLSL 1.10 for GL 2.0. */
+ /** Version 1.10, i.e. GLSL 1.10 for GL 2.0. */
public static final VersionNumber Version110 = new VersionNumber(1, 10, 0);
- /* Version 1.20, i.e. GLSL 1.20 for GL 2.1. */
+ /** Version 1.20, i.e. GLSL 1.20 for GL 2.1. */
public static final VersionNumber Version120 = new VersionNumber(1, 20, 0);
- /* Version 1.30, i.e. GLSL 1.30 for GL 3.0. */
+ /** Version 1.30, i.e. GLSL 1.30 for GL 3.0. */
public static final VersionNumber Version130 = new VersionNumber(1, 30, 0);
- /* Version 1.40, i.e. GLSL 1.40 for GL 3.1. */
+ /** Version 1.40, i.e. GLSL 1.40 for GL 3.1. */
public static final VersionNumber Version140 = new VersionNumber(1, 40, 0);
- /* Version 1.50, i.e. GLSL 1.50 for GL 3.2. */
+ /** Version 1.50, i.e. GLSL 1.50 for GL 3.2. */
public static final VersionNumber Version150 = new VersionNumber(1, 50, 0);
- /** Version 3.0. As an OpenGL version, it qualifies for desktop {@link #isGL2()} only, or ES 3.0. */
+ /** Version 3.0. As an OpenGL version, it qualifies for desktop {@link #isGL2()} only, or ES 3.0. Or GLSL 3.00 for ES 3.0. */
public static final VersionNumber Version300 = new VersionNumber(3, 0, 0);
/** Version 3.1. As an OpenGL version, it qualifies for {@link #isGL3core()}, {@link #isGL3bc()} and {@link #isGL3()} */
@@ -749,7 +749,8 @@ public abstract class GLContext {
* <p>
* 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), 3.00 (ES 3.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>
@@ -800,7 +801,9 @@ public abstract class GLContext {
protected static final VersionNumber getStaticGLSLVersionNumber(int glMajorVersion, int glMinorVersion, int ctxOptions) {
if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) {
- if( 3 > glMajorVersion ) {
+ if( 3 == glMajorVersion ) {
+ return Version300; // ES 3.0 -> GLSL 3.00
+ } else if( 2 == glMajorVersion ) {
return Version100; // ES 2.0 -> GLSL 1.00
}
} else if( 1 == glMajorVersion ) {
@@ -850,11 +853,12 @@ public abstract class GLContext {
}
/**
- * @return true if context supports GLSL, i.e. is either {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} <i>and</i> major-version > 1.
+ * @return true if context supports GLSL, i.e. is either {@link #isGLES3()}, {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} <i>and</i> major-version > 1.
* @see GLProfile#hasGLSL()
*/
public final boolean hasGLSL() {
- return isGLES2() ||
+ return isGLES3() ||
+ isGLES2() ||
isGL3() ||
isGL2() && ctxVersion.getMajor()>1 ;
}