[Cogl] [PATCH 4/4] Add the cogl_point_coord snippet builtin
Neil Roberts
neil at linux.intel.com
Sat Aug 24 18:42:35 PDT 2013
This adds a #define for gl_PointCoord to all shaders so that it can be
accessed with a name in the Cogl namespace.
---
cogl/cogl-glsl-shader-boilerplate.h | 4 +++-
cogl/cogl-snippet.h | 13 +++++++++++++
cogl/driver/gl/cogl-pipeline-fragend-glsl.c | 2 +-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/cogl/cogl-glsl-shader-boilerplate.h b/cogl/cogl-glsl-shader-boilerplate.h
index 99c1dbc..798149e 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 5eecbfc..cdce3b2 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 46264a9..aff4225 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",
--
1.8.3.1
More information about the Cogl
mailing list