diff options
author | Sven Gothel <[email protected]> | 2013-05-17 07:55:59 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-05-17 07:55:59 +0200 |
commit | b2802021acf8aa9b363ebef383c8dc8c8079ffa4 (patch) | |
tree | 7a9ba6c7b951e6eaf5fe7f91c5ef00ad9b357279 /src/jogl/classes/jogamp/graph/curve | |
parent | 33abeb8097a8f80acd1a4ce94b4866e5dc41f0c0 (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/jogamp/graph/curve')
21 files changed, 75 insertions, 193 deletions
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 2884aca2f..7f5afcd02 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -46,22 +46,25 @@ public class RegionRendererImpl01 extends RegionRenderer { } - @Override - protected String getFragmentShaderName(GL2ES2 gl) { - final String type = Region.isNonUniformWeight(renderModes) ? "02" : "01" ; - final String pass = Region.isVBAA(renderModes) ? "b" : "a" ; - return "curverenderer" + type + pass + getShaderGLVersionSuffix(gl); - } - protected boolean initShaderProgram(GL2ES2 gl) { final ShaderState st = rs.getShaderState(); - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader", - "shader/bin", getVertexShaderName(gl), false); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader", - "shader/bin", getFragmentShaderName(gl), false); - - ShaderProgram sp = new ShaderProgram(); + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader", + "shader/bin", getVertexShaderName(), true); + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader", + "shader/bin", getFragmentShaderName(), true); + rsVp.defaultShaderCustomization(gl, true, true); + // rsFp.defaultShaderCustomization(gl, true, true); + int pos = rsFp.addGLSLVersion(gl); + if( gl.isGLES2() ) { + pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + } + final String rsFpDefPrecision = getFragmentShaderPrecision(gl); + if( null != rsFpDefPrecision ) { + rsFp.insertShaderSource(0, pos, rsFpDefPrecision); + } + + final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 0cf424cd2..81c421371 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -49,12 +49,22 @@ public class TextRendererImpl01 extends TextRenderer { protected boolean initShaderProgram(GL2ES2 gl){ final ShaderState st = rs.getShaderState(); - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextRendererImpl01.class, "shader", - "shader/bin", getVertexShaderName(gl), false); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextRendererImpl01.class, "shader", - "shader/bin", getFragmentShaderName(gl), false); + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextRendererImpl01.class, "shader", + "shader/bin", getVertexShaderName(), true); + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextRendererImpl01.class, "shader", + "shader/bin", getFragmentShaderName(), true); + rsVp.defaultShaderCustomization(gl, true, true); + // rsFp.defaultShaderCustomization(gl, true, true); + int pos = rsFp.addGLSLVersion(gl); + if( gl.isGLES2() ) { + pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + } + final String rsFpDefPrecision = getFragmentShaderPrecision(gl); + if( null != rsFpDefPrecision ) { + rsFp.insertShaderSource(0, pos, rsFpDefPrecision); + } - ShaderProgram sp = new ShaderProgram(); + final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl index 108247c9c..ced118c1c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl @@ -2,6 +2,10 @@ #ifndef attributes_glsl #define attributes_glsl +#if __VERSION__ >= 130 + #define attribute in +#endif + // attribute vec3 gca_Vertices; attribute vec4 gca_Vertices; attribute vec2 gca_TexCoords; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp index d31bafb5a..ca03e605c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp @@ -4,6 +4,12 @@ // 1-pass shader w/ weight
//
+#if __VERSION__ >= 130
+ out vec4 mgl_FragColor;
+#else
+ #define mgl_FragColor gl_FragColor
+#endif
+
#include uniforms.glsl
#include varyings.glsl
@@ -44,5 +50,5 @@ void main (void) }
}
- gl_FragColor = vec4(c, alpha);
+ mgl_FragColor = vec4(c, alpha);
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp index f3a88adef..b978b62d1 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp @@ -4,6 +4,12 @@ // 1-pass shader w/o weight // +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + #include uniforms.glsl #include varyings.glsl @@ -38,5 +44,5 @@ void main (void) } } - gl_FragColor = vec4(c, alpha); + mgl_FragColor = vec4(c, alpha); } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp index be738498c..9440f314c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp @@ -4,6 +4,12 @@ // 2-pass shader w/ weight
//
+#if __VERSION__ >= 130
+ out vec4 mgl_FragColor;
+#else
+ #define mgl_FragColor gl_FragColor
+#endif
+
#include uniforms.glsl
#include varyings.glsl
@@ -48,10 +54,11 @@ void main (void) t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w;
t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w;
- /** discard freezes NV tegra2 compiler
+ #if 0
if(t.w == 0.0) {
- discard;
- } */
+ discard; // discard freezes NV tegra2 compiler
+ }
+ #endif
c = t.xyz;
alpha = gcu_Alpha * t.w;
@@ -84,5 +91,5 @@ void main (void) }
}
- gl_FragColor = vec4(c, alpha);
+ mgl_FragColor = vec4(c, alpha);
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp index 879e41e4c..0d878f2e4 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp @@ -4,6 +4,12 @@ // 2-pass shader w/o weight // +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + #include uniforms.glsl #include varyings.glsl @@ -49,10 +55,11 @@ void main (void) t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w; t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w; - /** discard freezes NV tegra2 compiler + #if 0 if(t.w == 0.0){ - discard; - } */ + discard; // discard freezes NV tegra2 compiler + } + #endif c = t.xyz; alpha = gcu_Alpha * t.w; @@ -78,5 +85,5 @@ void main (void) } } - gl_FragColor = vec4(c, alpha); + mgl_FragColor = vec4(c, alpha); } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp deleted file mode 100644 index 8fb985d69..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp +++ /dev/null @@ -1,19 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#ifdef GL_ES - precision highp float; - precision highp int; -#endif - -uniform mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi -varying vec2 gcv_TexCoord; - -attribute vec4 gca_Vertices; -attribute vec2 gca_TexCoords; - - -void main(void) -{ - gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * gca_Vertices; - gcv_TexCoord = gca_TexCoords; -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp deleted file mode 100644 index a5dc158ad..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp +++ /dev/null @@ -1,9 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -precision highp float; -precision highp int; - -#include curverenderer01-xxx.vp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp deleted file mode 100644 index 1ac33e8b3..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01-xxx.vp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp index 64a6835ec..64a6835ec 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp deleted file mode 100644 index a57d8fc62..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp +++ /dev/null @@ -1,52 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#ifdef GL_ES - precision mediump float; - precision mediump int; -#endif - -uniform mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi -uniform vec3 gcu_ColorStatic; -uniform float gcu_Alpha; - -varying vec2 gcv_TexCoord; - -const vec3 b_color = vec3(1.0, 1.0, 1.0); - -void main (void) -{ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - vec3 c = gcu_ColorStatic; - - float alpha = 0.0; - - if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { - alpha = gcu_Alpha; - } - else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { - vec2 dtx = dFdx(rtex); - vec2 dty = dFdy(rtex); - - rtex.y -= 0.1; - - if(rtex.y < 0.0) { - rtex.y = 0.0; - } - - vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); - float position = rtex.y - (rtex.x * (1.0 - rtex.x)); - float d = position/(length(f)); - - float a = (0.5 - d * sign(gcv_TexCoord.y)); - - if (a >= 1.0) { - alpha = gcu_Alpha; - } else if (a <= 0.0) { - alpha=0.0; - } else { - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp deleted file mode 100644 index e693891a6..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp +++ /dev/null @@ -1,13 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; - -#include curverenderer01a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp deleted file mode 100644 index d187fea24..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp deleted file mode 100644 index d4748722d..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer01b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp deleted file mode 100644 index 01e08ff30..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp deleted file mode 100644 index 240a6c30f..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer02a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp deleted file mode 100644 index 01715daa5..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer02a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp deleted file mode 100644 index 884e75674..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer02b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp deleted file mode 100644 index b1cc72188..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer02b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl index 7a9bc5a07..3b9a3b727 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl @@ -2,6 +2,10 @@ #ifndef varyings_glsl #define varyings_glsl +#if __VERSION__ >= 130 + #define varying out +#endif + //varying vec4 gcv_FrontColor; varying vec2 gcv_TexCoord; |