diff options
author | Robert Bragg <robert@linux.intel.com> | 2010-07-23 17:46:41 +0100 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2010-11-10 14:24:52 +0000 |
commit | 5f30835eae218c8e80153101018c53862c03c353 (patch) | |
tree | 4a7bc9bf73ed5154b07f7eea35c32711823ad872 /clutter/clutter-blur-effect.c | |
parent | a4b984186ccd81879822ab7fad1af8b545b28e35 (diff) | |
download | clutter-5f30835eae218c8e80153101018c53862c03c353.tar.gz |
cogl-shader: Prepend boilerplate for portable shaders
We now prepend a set of defines to any given GLSL shader so that we can
define builtin uniforms/attributes within the "cogl" namespace that we
can use to provide compatibility across a range of the earlier versions
of GLSL.
This updates test-cogl-shader-glsl.c and test-shader.c so they no longer
needs to special case GLES vs GL when splicing together its shaders as
well as the blur, colorize and desaturate effects.
To get a feel for the new, portable uniform/attribute names here are the
defines for OpenGL vertex shaders:
#define cogl_position_in gl_Vertex
#define cogl_color_in gl_Color
#define cogl_tex_coord_in gl_MultiTexCoord0
#define cogl_tex_coord0_in gl_MultiTexCoord0
#define cogl_tex_coord1_in gl_MultiTexCoord1
#define cogl_tex_coord2_in gl_MultiTexCoord2
#define cogl_tex_coord3_in gl_MultiTexCoord3
#define cogl_tex_coord4_in gl_MultiTexCoord4
#define cogl_tex_coord5_in gl_MultiTexCoord5
#define cogl_tex_coord6_in gl_MultiTexCoord6
#define cogl_tex_coord7_in gl_MultiTexCoord7
#define cogl_normal_in gl_Normal
#define cogl_position_out gl_Position
#define cogl_point_size_out gl_PointSize
#define cogl_color_out gl_FrontColor
#define cogl_tex_coord_out gl_TexCoord
#define cogl_modelview_matrix gl_ModelViewMatrix
#define cogl_modelview_projection_matrix gl_ModelViewProjectionMatrix
#define cogl_projection_matrix gl_ProjectionMatrix
#define cogl_texture_matrix gl_TextureMatrix
And for fragment shaders we have:
#define cogl_color_in gl_Color
#define cogl_tex_coord_in gl_TexCoord
#define cogl_color_out gl_FragColor
#define cogl_depth_out gl_FragDepth
#define cogl_front_facing gl_FrontFacing
Diffstat (limited to 'clutter/clutter-blur-effect.c')
-rw-r--r-- | clutter/clutter-blur-effect.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/clutter/clutter-blur-effect.c b/clutter/clutter-blur-effect.c index 144ee96c1..901942c79 100644 --- a/clutter/clutter-blur-effect.c +++ b/clutter/clutter-blur-effect.c @@ -57,18 +57,17 @@ typedef struct _ClutterBlurEffectClass ClutterBlurEffectClass; * horizontal/vertical two pass shader for the gaussian blur */ static const gchar *box_blur_glsl_shader = -"#version 110\n" "uniform sampler2D tex;\n" "uniform float x_step, y_step;\n" "\n" "vec4 get_rgba_rel (sampler2D source, float dx, float dy)\n" "{\n" -" return texture2D (tex, gl_TexCoord[0].st + vec2 (dx, dy) * 2.0);\n" +" return texture2D (tex, cogl_tex_coord[0].st + vec2 (dx, dy) * 2.0);\n" "}\n" "\n" "void main ()\n" "{\n" -" vec4 color = gl_Color * texture2D (tex, vec2 (gl_TexCoord[0].xy));\n" +" vec4 color = cogl_color_in * texture2D (tex, vec2 (cogl_tex_coord[0].xy));\n" " color += get_rgba_rel (tex, -x_step, -y_step);\n" " color += get_rgba_rel (tex, 0.0, -y_step);\n" " color += get_rgba_rel (tex, x_step, -y_step);\n" @@ -78,7 +77,7 @@ static const gchar *box_blur_glsl_shader = " color += get_rgba_rel (tex, -x_step, y_step);\n" " color += get_rgba_rel (tex, 0.0, y_step);\n" " color += get_rgba_rel (tex, x_step, y_step);\n" -" gl_FragColor = color / 9.0;\n" +" cogl_color_out = color / 9.0;\n" "}"; struct _ClutterBlurEffect |