summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-05-17 07:55:59 +0200
committerSven Gothel <[email protected]>2013-05-17 07:55:59 +0200
commitb2802021acf8aa9b363ebef383c8dc8c8079ffa4 (patch)
tree7a9ba6c7b951e6eaf5fe7f91c5ef00ad9b357279 /src/jogl/classes/com/jogamp/opengl
parent33abeb8097a8f80acd1a4ce94b4866e5dc41f0c0 (diff)
Fix Bug 711: Align Graphs's Curve Shader programmatically to used GL/GLSL version, following all other internal GLSL usage utilizing ShaderCode.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java28
1 files changed, 24 insertions, 4 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 80a7efaec..edc3d2677 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
@@ -684,7 +684,7 @@ public class ShaderCode {
*
* @param shaderIdx the shader index to be used.
* @param position in shader source segments of shader <code>shaderIdx</code>
- * @param data the text to be inserted. Shall end with an EOL '\n' character.
+ * @param data the text to be inserted. Shall end with an EOL '\n' character
* @return index after the inserted <code>data</code>
*
* @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type <code>StringBuilder</code>
@@ -833,8 +833,11 @@ public class ShaderCode {
/** 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";
/** Default precision of GLSL &ge; 1.30 as required until &lt; 1.50 for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #gl3_default_precision_fp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */
- public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n";
+ public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n/*precision mediump sampler2D;*/\n";
+ /** Prefer <code>enable</code> over <code>require</code>, since it won't force a failure. */
+ public static final String extOESDerivativesEnable = "#extension GL_OES_standard_derivatives : enable\n";
+
/**
* Add GLSL version at the head of this shader source code.
* <p>
@@ -860,7 +863,6 @@ public class ShaderCode {
* @return the index after the inserted data, maybe 0 if nothing has be inserted.
*/
public final int addDefaultShaderPrecision(GL2ES2 gl, int pos) {
- final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber();
final String defaultPrecision;
if( gl.isGLES2() ) {
switch ( shaderType ) {
@@ -872,7 +874,7 @@ public class ShaderCode {
defaultPrecision = null;
break;
}
- } else if( glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ) {
+ } else if( requiresGL3DefaultPrecision(gl) ) {
// GLSL [ 1.30 .. 1.50 [ needs at least fragement float default precision!
switch ( shaderType ) {
case GL2ES2.GL_VERTEX_SHADER:
@@ -893,6 +895,24 @@ public class ShaderCode {
return pos;
}
+ /** 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() ) {
+ return true;
+ }
+ return requiresGL3DefaultPrecision(gl);
+ }
+
+ /** Returns true, if GL3 GLSL version requires default precision, i.e. GLSL [1.30 .. 1.50[. */
+ public static final boolean requiresGL3DefaultPrecision(GL2ES2 gl) {
+ if( gl.isGL3() ) {
+ final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber();
+ return glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ;
+ } else {
+ return false;
+ }
+ }
+
/**
* Default customization of this shader source code.
* <p>