diff --git a/cogl/cogl-glsl-shader-boilerplate.h b/cogl/cogl-glsl-shader-boilerplate.h index 9df0279fa..c58a88188 100644 --- a/cogl/cogl-glsl-shader-boilerplate.h +++ b/cogl/cogl-glsl-shader-boilerplate.h @@ -66,7 +66,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 6baba62b8..120a9be93 100644 --- a/cogl/cogl-snippet.h +++ b/cogl/cogl-snippet.h @@ -279,6 +279,19 @@ COGL_BEGIN_DECLS * coloring algorithms. This is equivalent to #gl_FrontFacing. * * + * + * vec2 cogl_point_coord + * + * 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. + * + * * * * 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 2073a9234..18f1ff6f5 100644 --- a/cogl/driver/gl/cogl-pipeline-fragend-glsl.c +++ b/cogl/driver/gl/cogl-pipeline-fragend-glsl.c @@ -421,7 +421,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",