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.
This commit is contained in:
Neil Roberts 2010-04-07 11:06:20 +01:00 committed by Robert Bragg
parent ad6d597445
commit f47152c557
2 changed files with 35 additions and 28 deletions

View File

@ -96,8 +96,10 @@ typedef enum {
* decide which of the above two to use. For cogl_rectangle(), it * decide which of the above two to use. For cogl_rectangle(), it
* will use repeat mode if any of the texture coordinates are * will use repeat mode if any of the texture coordinates are
* outside the range 01, otherwise it will use clamp to edge. For * outside the range 01, otherwise it will use clamp to edge. For
* cogl_polygon() and cogl_vertex_buffer_draw() it will always use * cogl_polygon() it will always use repeat mode. For
* repeat mode. This is the default value. * 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 * The wrap mode specifies what happens when texture coordinates
* outside the range 01 are used. Note that if the filter mode is * outside the range 01 are used. Note that if the filter mode is

View File

@ -1659,6 +1659,37 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
if (tex_handle == COGL_INVALID_HANDLE) if (tex_handle == COGL_INVALID_HANDLE)
continue; 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 /* Give the texture a chance to know that we're rendering
non-quad shaped primitives. If the texture is in an atlas it non-quad shaped primitives. If the texture is in an atlas it
will be migrated */ will be migrated */
@ -1691,32 +1722,6 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
*/ */
fallback_layers |= (1 << i); 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 */ /* Disable any tex coord arrays that we didn't use */