summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2013-08-25 02:19:05 +0100
committerNeil Roberts <neil@linux.intel.com>2013-09-02 15:40:15 +0100
commitc28fc054788e88627bcc2346f4c4c368870ff777 (patch)
tree841bd682a2b2d967816d0806b00af0b8973bed4c
parente4dfe8b07e8af111ecbcb0da20ff2a2875a2b5d0 (diff)
downloadcogl-c28fc054788e88627bcc2346f4c4c368870ff777.tar.gz
Add the cogl_point_coord snippet builtin
This adds a #define for gl_PointCoord to all shaders so that it can be accessed with a name in the Cogl namespace. Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r--cogl/cogl-glsl-shader-boilerplate.h4
-rw-r--r--cogl/cogl-snippet.h13
-rw-r--r--cogl/driver/gl/cogl-pipeline-fragend-glsl.c2
3 files changed, 17 insertions, 2 deletions
diff --git a/cogl/cogl-glsl-shader-boilerplate.h b/cogl/cogl-glsl-shader-boilerplate.h
index 99c1dbc9..798149e7 100644
--- a/cogl/cogl-glsl-shader-boilerplate.h
+++ b/cogl/cogl-glsl-shader-boilerplate.h
@@ -64,7 +64,9 @@
"#define cogl_color_out gl_FragColor\n" \
"#define cogl_depth_out gl_FragDepth\n" \
"\n" \
- "#define cogl_front_facing gl_FrontFacing\n"
+ "#define cogl_front_facing gl_FrontFacing\n" \
+ "\n" \
+ "#define cogl_point_coord gl_PointCoord\n"
#if 0
/* GLSL 1.2 has a bottom left origin, though later versions
* allow use of an origin_upper_left keyword which would be
diff --git a/cogl/cogl-snippet.h b/cogl/cogl-snippet.h
index 5eecbfc8..cdce3b26 100644
--- a/cogl/cogl-snippet.h
+++ b/cogl/cogl-snippet.h
@@ -271,6 +271,19 @@ COGL_BEGIN_DECLS
* coloring algorithms. This is equivalent to #gl_FrontFacing.
* </para></glossdef>
* </glossentry>
+ * <glossentry>
+ * <glossterm>vec2 <emphasis>cogl_point_coord</emphasis></glossterm>
+ * <glossdef><para>
+ * When rendering points, this will contain a vec2 which represents
+ * the position within the point of the current fragment.
+ * vec2(0.0,0.0) will be the topleft of the point and vec2(1.0,1.0)
+ * will be the bottom right. Note that there is currently a bug in
+ * Cogl where when rendering to an offscreen buffer these
+ * coordinates will be upside-down. The value is undefined when not
+ * rendering points. This builtin can only be used if the
+ * %COGL_FEATURE_ID_POINT_SPRITE feature is available.
+ * </para></glossdef>
+ * </glossentry>
* </glosslist>
*
* Here is an example of using a snippet to add a desaturate effect to the
diff --git a/cogl/driver/gl/cogl-pipeline-fragend-glsl.c b/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
index 46264a9f..aff42258 100644
--- a/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
+++ b/cogl/driver/gl/cogl-pipeline-fragend-glsl.c
@@ -408,7 +408,7 @@ ensure_texture_lookup_generated (CoglPipelineShaderState *shader_state,
if (cogl_pipeline_get_layer_point_sprite_coords_enabled (pipeline,
layer->index))
g_string_append_printf (shader_state->source,
- "vec4 (gl_PointCoord, 0.0, 1.0)");
+ "vec4 (cogl_point_coord, 0.0, 1.0)");
else
g_string_append_printf (shader_state->source,
"cogl_tex_coord%i_in",