From f47152c557c3d21ebacc7b774e94cfa4f6dcb3bc Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 7 Apr 2010 11:06:20 +0100 Subject: [PATCH] cogl-vertex-buffer: Default to GL_CLAMP_TO_EDGE for point sprites For point sprites you are usually drawing the whole texture so you most often want GL_CLAMP_TO_EDGE. This patch removes the override for COGL_MATERIAL_WRAP_MODE_AUTOMATIC when point sprites are enabled for a layer so that it will clamp to edge. --- clutter/cogl/cogl/cogl-material.h | 6 ++- clutter/cogl/cogl/cogl-vertex-buffer.c | 57 ++++++++++++++------------ 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/clutter/cogl/cogl/cogl-material.h b/clutter/cogl/cogl/cogl-material.h index 7c9de1aaa..c9c9763c6 100644 --- a/clutter/cogl/cogl/cogl-material.h +++ b/clutter/cogl/cogl/cogl-material.h @@ -96,8 +96,10 @@ typedef enum { * decide which of the above two to use. For cogl_rectangle(), it * will use repeat mode if any of the texture coordinates are * outside the range 0→1, otherwise it will use clamp to edge. For - * cogl_polygon() and cogl_vertex_buffer_draw() it will always use - * repeat mode. This is the default value. + * cogl_polygon() it will always use repeat mode. For + * cogl_vertex_buffer_draw() it will use repeat mode except for + * layers that have point sprite coordinate generation enabled. This + * is the default value. * * The wrap mode specifies what happens when texture coordinates * outside the range 0→1 are used. Note that if the filter mode is diff --git a/clutter/cogl/cogl/cogl-vertex-buffer.c b/clutter/cogl/cogl/cogl-vertex-buffer.c index 57a353ecb..9664adc96 100644 --- a/clutter/cogl/cogl/cogl-vertex-buffer.c +++ b/clutter/cogl/cogl/cogl-vertex-buffer.c @@ -1659,6 +1659,37 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer) if (tex_handle == COGL_INVALID_HANDLE) continue; + if (!cogl_material_get_layer_point_sprite_coords_enabled (source, i)) + { + /* By default COGL_MATERIAL_WRAP_MODE_AUTOMATIC becomes + GL_CLAMP_TO_EDGE but we want GL_REPEAT to maintain + compatibility with older versions of Cogl so we'll + override it. We don't want to do this for point sprites + because in that case the whole texture is drawn so you + would usually want clamp-to-edge. */ + if (cogl_material_layer_get_wrap_mode_s (layer) == + COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + { + options.wrap_mode_overrides.values[i].s = + COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; + options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; + } + if (cogl_material_layer_get_wrap_mode_t (layer) == + COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + { + options.wrap_mode_overrides.values[i].t = + COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; + options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; + } + if (_cogl_material_layer_get_wrap_mode_r (layer) == + COGL_MATERIAL_WRAP_MODE_AUTOMATIC) + { + options.wrap_mode_overrides.values[i].r = + COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; + options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; + } + } + /* Give the texture a chance to know that we're rendering non-quad shaped primitives. If the texture is in an atlas it will be migrated */ @@ -1691,32 +1722,6 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer) */ fallback_layers |= (1 << i); } - - /* By default COGL_MATERIAL_WRAP_MODE_AUTOMATIC becomes - GL_CLAMP_TO_EDGE but we want GL_REPEAT to maintain - compatibility with older versions of Cogl so we'll override - it */ - if (cogl_material_layer_get_wrap_mode_s (layer) == - COGL_MATERIAL_WRAP_MODE_AUTOMATIC) - { - options.wrap_mode_overrides.values[i].s = - COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; - options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; - } - if (cogl_material_layer_get_wrap_mode_t (layer) == - COGL_MATERIAL_WRAP_MODE_AUTOMATIC) - { - options.wrap_mode_overrides.values[i].t = - COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; - options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; - } - if (_cogl_material_layer_get_wrap_mode_r (layer) == - COGL_MATERIAL_WRAP_MODE_AUTOMATIC) - { - options.wrap_mode_overrides.values[i].r = - COGL_MATERIAL_WRAP_MODE_OVERRIDE_REPEAT; - options.flags |= COGL_MATERIAL_FLUSH_WRAP_MODE_OVERRIDES; - } } /* Disable any tex coord arrays that we didn't use */