diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am index 1a294245a..87ed88983 100644 --- a/clutter/cogl/cogl/Makefile.am +++ b/clutter/cogl/cogl/Makefile.am @@ -75,7 +75,7 @@ cogl_public_h = \ $(srcdir)/cogl-index-array.h \ $(srcdir)/cogl-vertex-array.h \ $(srcdir)/cogl-indices.h \ - $(srcdir)/cogl-vertex-attribute.h \ + $(srcdir)/cogl-attribute.h \ $(srcdir)/cogl-primitive.h \ $(srcdir)/cogl.h \ $(NULL) @@ -201,8 +201,8 @@ cogl_sources_c = \ $(srcdir)/cogl-vertex-array.c \ $(srcdir)/cogl-indices-private.h \ $(srcdir)/cogl-indices.c \ - $(srcdir)/cogl-vertex-attribute-private.h \ - $(srcdir)/cogl-vertex-attribute.c \ + $(srcdir)/cogl-attribute-private.h \ + $(srcdir)/cogl-attribute.c \ $(srcdir)/cogl-primitive-private.h \ $(srcdir)/cogl-primitive.c \ $(srcdir)/cogl-matrix.c \ diff --git a/clutter/cogl/cogl/cogl-vertex-attribute-private.h b/clutter/cogl/cogl/cogl-attribute-private.h similarity index 57% rename from clutter/cogl/cogl/cogl-vertex-attribute-private.h rename to clutter/cogl/cogl/cogl-attribute-private.h index a5663123d..d7acef6da 100644 --- a/clutter/cogl/cogl/cogl-vertex-attribute-private.h +++ b/clutter/cogl/cogl/cogl-attribute-private.h @@ -25,32 +25,32 @@ * Robert Bragg */ -#ifndef __COGL_VERTEX_ATTRIBUTE_PRIVATE_H -#define __COGL_VERTEX_ATTRIBUTE_PRIVATE_H +#ifndef __COGL_ATTRIBUTE_PRIVATE_H +#define __COGL_ATTRIBUTE_PRIVATE_H #include "cogl-object-private.h" -#include "cogl-vertex-attribute.h" +#include "cogl-attribute.h" typedef enum { - COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY, - COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY, - COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY, - COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY, - COGL_VERTEX_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY -} CoglVertexAttributeNameID; + COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY, + COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY, + COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY, + COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY, + COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY +} CoglAttributeNameID; -struct _CoglVertexAttribute +struct _CoglAttribute { CoglObject _parent; CoglVertexArray *array; char *name; - CoglVertexAttributeNameID name_id; + CoglAttributeNameID name_id; gsize stride; gsize offset; int n_components; - CoglVertexAttributeType type; + CoglAttributeType type; gboolean normalized; unsigned int texture_unit; @@ -75,29 +75,29 @@ typedef enum COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE = 1 << 4 } CoglDrawFlags; -CoglVertexAttribute * -_cogl_vertex_attribute_immutable_ref (CoglVertexAttribute *vertex_attribute); +CoglAttribute * +_cogl_attribute_immutable_ref (CoglAttribute *attribute); void -_cogl_vertex_attribute_immutable_unref (CoglVertexAttribute *vertex_attribute); +_cogl_attribute_immutable_unref (CoglAttribute *attribute); void -_cogl_draw_vertex_attributes_array (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglVertexAttribute **attributes, - CoglDrawFlags flags); +_cogl_draw_attributes_array (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglAttribute **attributes, + CoglDrawFlags flags); void -_cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglIndices *indices, - CoglVertexAttribute **attributes, - CoglDrawFlags flags); +_cogl_draw_indexed_attributes_array (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglIndices *indices, + CoglAttribute **attributes, + CoglDrawFlags flags); void -_cogl_vertex_attribute_disable_cached_arrays (void); +_cogl_attribute_disable_cached_arrays (void); -#endif /* __COGL_VERTEX_ATTRIBUTE_PRIVATE_H */ +#endif /* __COGL_ATTRIBUTE_PRIVATE_H */ diff --git a/clutter/cogl/cogl/cogl-vertex-attribute.c b/clutter/cogl/cogl/cogl-attribute.c similarity index 81% rename from clutter/cogl/cogl/cogl-vertex-attribute.c rename to clutter/cogl/cogl/cogl-attribute.c index 7bf306dc7..e81d1898f 100644 --- a/clutter/cogl/cogl/cogl-vertex-attribute.c +++ b/clutter/cogl/cogl/cogl-attribute.c @@ -32,8 +32,8 @@ #include "cogl-context.h" #include "cogl-object-private.h" #include "cogl-journal-private.h" -#include "cogl-vertex-attribute.h" -#include "cogl-vertex-attribute-private.h" +#include "cogl-attribute.h" +#include "cogl-attribute-private.h" #include "cogl-pipeline.h" #include "cogl-pipeline-private.h" #include "cogl-pipeline-opengl-private.h" @@ -90,15 +90,15 @@ #endif -static void _cogl_vertex_attribute_free (CoglVertexAttribute *attribute); +static void _cogl_attribute_free (CoglAttribute *attribute); -COGL_OBJECT_DEFINE (VertexAttribute, vertex_attribute); +COGL_OBJECT_DEFINE (Attribute, attribute); #if 0 gboolean validate_gl_attribute (const char *name, int n_components, - CoglVertexAttributeNameID *name_id, + CoglAttributeNameID *name_id, gboolean *normalized, unsigned int *texture_unit) { @@ -116,7 +116,7 @@ validate_gl_attribute (const char *name, "attributes where n_components == 2, 3 or 4"); return FALSE; } - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY; } else if (strcmp (name, "Color") == 0) { @@ -127,7 +127,7 @@ validate_gl_attribute (const char *name, "n_components == 3 or 4"); return FALSE; } - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY; *normalized = TRUE; } else if (strncmp (name, "MultiTexCoord", strlen ("MultiTexCoord")) == 0) @@ -138,7 +138,7 @@ validate_gl_attribute (const char *name, "texture unit number, E.g. gl_MultiTexCoord0\n"); unit = 0; } - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY; } else if (strncmp (name, "Normal") == 0) { @@ -149,7 +149,7 @@ validate_gl_attribute (const char *name, "n_components == 3"); return FALSE; } - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY; *normalized = TRUE; } else @@ -165,7 +165,7 @@ validate_gl_attribute (const char *name, gboolean validate_cogl_attribute (const char *name, int n_components, - CoglVertexAttributeNameID *name_id, + CoglAttributeNameID *name_id, gboolean *normalized, unsigned int *texture_unit) { @@ -183,7 +183,7 @@ validate_cogl_attribute (const char *name, "attributes where n_components == 2, 3 or 4"); return FALSE; } - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY; } else if (strcmp (name, "color_in") == 0) { @@ -194,10 +194,10 @@ validate_cogl_attribute (const char *name, "n_components == 3 or 4"); return FALSE; } - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY; } else if (strcmp (name, "tex_coord_in") == 0) - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY; else if (strncmp (name, "tex_coord", strlen ("tex_coord")) == 0) { if (sscanf (name, "tex_coord%u_in", texture_unit) != 1) @@ -207,7 +207,7 @@ validate_cogl_attribute (const char *name, "like \"cogl_tex_coord2_in\"\n"); return FALSE; } - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY; } else if (strcmp (name, "normal_in") == 0) { @@ -218,7 +218,7 @@ validate_cogl_attribute (const char *name, "where n_components == 3"); return FALSE; } - *name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY; + *name_id = COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY; *normalized = TRUE; } else @@ -230,15 +230,15 @@ validate_cogl_attribute (const char *name, return TRUE; } -CoglVertexAttribute * -cogl_vertex_attribute_new (CoglVertexArray *array, - const char *name, - gsize stride, - gsize offset, - int n_components, - CoglVertexAttributeType type) +CoglAttribute * +cogl_attribute_new (CoglVertexArray *array, + const char *name, + gsize stride, + gsize offset, + int n_components, + CoglAttributeType type) { - CoglVertexAttribute *attribute = g_slice_new (CoglVertexAttribute); + CoglAttribute *attribute = g_slice_new (CoglAttribute); gboolean status; attribute->array = cogl_object_ref (array); @@ -265,7 +265,7 @@ cogl_vertex_attribute_new (CoglVertexArray *array, #endif else { - attribute->name_id = COGL_VERTEX_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY; + attribute->name_id = COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY; attribute->normalized = FALSE; attribute->texture_unit = 0; status = TRUE; @@ -273,17 +273,17 @@ cogl_vertex_attribute_new (CoglVertexArray *array, if (!status) { - _cogl_vertex_attribute_free (attribute); + _cogl_attribute_free (attribute); return NULL; } - return _cogl_vertex_attribute_object_new (attribute); + return _cogl_attribute_object_new (attribute); } gboolean -cogl_vertex_attribute_get_normalized (CoglVertexAttribute *attribute) +cogl_attribute_get_normalized (CoglAttribute *attribute) { - g_return_val_if_fail (cogl_is_vertex_attribute (attribute), FALSE); + g_return_val_if_fail (cogl_is_attribute (attribute), FALSE); return attribute->normalized; } @@ -301,10 +301,10 @@ warn_about_midscene_changes (void) } void -cogl_vertex_attribute_set_normalized (CoglVertexAttribute *attribute, +cogl_attribute_set_normalized (CoglAttribute *attribute, gboolean normalized) { - g_return_if_fail (cogl_is_vertex_attribute (attribute)); + g_return_if_fail (cogl_is_attribute (attribute)); if (G_UNLIKELY (attribute->immutable_ref)) warn_about_midscene_changes (); @@ -313,18 +313,18 @@ cogl_vertex_attribute_set_normalized (CoglVertexAttribute *attribute, } CoglVertexArray * -cogl_vertex_attribute_get_array (CoglVertexAttribute *attribute) +cogl_attribute_get_array (CoglAttribute *attribute) { - g_return_val_if_fail (cogl_is_vertex_attribute (attribute), NULL); + g_return_val_if_fail (cogl_is_attribute (attribute), NULL); return attribute->array; } void -cogl_vertex_attribute_set_array (CoglVertexAttribute *attribute, +cogl_attribute_set_array (CoglAttribute *attribute, CoglVertexArray *array) { - g_return_if_fail (cogl_is_vertex_attribute (attribute)); + g_return_if_fail (cogl_is_attribute (attribute)); if (G_UNLIKELY (attribute->immutable_ref)) warn_about_midscene_changes (); @@ -335,33 +335,33 @@ cogl_vertex_attribute_set_array (CoglVertexAttribute *attribute, attribute->array = array; } -CoglVertexAttribute * -_cogl_vertex_attribute_immutable_ref (CoglVertexAttribute *vertex_attribute) +CoglAttribute * +_cogl_attribute_immutable_ref (CoglAttribute *attribute) { - g_return_val_if_fail (cogl_is_vertex_attribute (vertex_attribute), NULL); + g_return_val_if_fail (cogl_is_attribute (attribute), NULL); - vertex_attribute->immutable_ref++; - _cogl_buffer_immutable_ref (COGL_BUFFER (vertex_attribute->array)); - return vertex_attribute; + attribute->immutable_ref++; + _cogl_buffer_immutable_ref (COGL_BUFFER (attribute->array)); + return attribute; } void -_cogl_vertex_attribute_immutable_unref (CoglVertexAttribute *vertex_attribute) +_cogl_attribute_immutable_unref (CoglAttribute *attribute) { - g_return_if_fail (cogl_is_vertex_attribute (vertex_attribute)); - g_return_if_fail (vertex_attribute->immutable_ref > 0); + g_return_if_fail (cogl_is_attribute (attribute)); + g_return_if_fail (attribute->immutable_ref > 0); - vertex_attribute->immutable_ref--; - _cogl_buffer_immutable_unref (COGL_BUFFER (vertex_attribute->array)); + attribute->immutable_ref--; + _cogl_buffer_immutable_unref (COGL_BUFFER (attribute->array)); } static void -_cogl_vertex_attribute_free (CoglVertexAttribute *attribute) +_cogl_attribute_free (CoglAttribute *attribute) { g_free (attribute->name); cogl_object_unref (attribute->array); - g_slice_free (CoglVertexAttribute, attribute); + g_slice_free (CoglAttribute, attribute); } typedef struct @@ -477,7 +477,7 @@ set_enabled_arrays (CoglBitmask *value_cache, static CoglHandle enable_gl_state (CoglDrawFlags flags, - CoglVertexAttribute **attributes, + CoglAttribute **attributes, ValidateLayerState *state) { CoglFramebuffer *framebuffer = _cogl_get_framebuffer (); @@ -507,7 +507,7 @@ enable_gl_state (CoglDrawFlags flags, for (i = 0; attributes[i]; i++) switch (attributes[i]->name_id) { - case COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY: if ((flags & COGL_DRAW_COLOR_ATTRIBUTE_IS_OPAQUE) == 0 && !_cogl_pipeline_get_real_blend_enabled (source)) { @@ -520,7 +520,7 @@ enable_gl_state (CoglDrawFlags flags, skip_gl_color = TRUE; break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY: n_tex_coord_attribs++; break; @@ -597,7 +597,7 @@ enable_gl_state (CoglDrawFlags flags, for (i = 0; attributes[i]; i++) { - CoglVertexAttribute *attribute = attributes[i]; + CoglAttribute *attribute = attributes[i]; CoglVertexArray *vertex_array; CoglBuffer *buffer; void *base; @@ -605,13 +605,13 @@ enable_gl_state (CoglDrawFlags flags, int attrib_location; #endif - vertex_array = cogl_vertex_attribute_get_array (attribute); + vertex_array = cogl_attribute_get_array (attribute); buffer = COGL_BUFFER (vertex_array); base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY); switch (attribute->name_id) { - case COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY: #ifdef HAVE_COGL_GLES2 attrib_location = @@ -640,7 +640,7 @@ enable_gl_state (CoglDrawFlags flags, #endif break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY: #ifdef HAVE_COGL_GLES2 attrib_location = @@ -667,7 +667,7 @@ enable_gl_state (CoglDrawFlags flags, #endif break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY: #ifdef HAVE_COGL_GLES2 attrib_location = _cogl_pipeline_progend_glsl_get_tex_coord_attribute @@ -695,7 +695,7 @@ enable_gl_state (CoglDrawFlags flags, #endif break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY: #ifdef HAVE_COGL_GLES2 attrib_location = @@ -722,7 +722,7 @@ enable_gl_state (CoglDrawFlags flags, #endif break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY: { #ifdef MAY_HAVE_PROGRAMABLE_GL /* FIXME: go through cogl cache to enable generic array. */ @@ -755,7 +755,7 @@ enable_gl_state (CoglDrawFlags flags, } void -_cogl_vertex_attribute_disable_cached_arrays (void) +_cogl_attribute_disable_cached_arrays (void) { _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -766,7 +766,7 @@ _cogl_vertex_attribute_disable_cached_arrays (void) /* FIXME: we shouldn't be disabling state after drawing we should * just disable the things not needed after enabling state. */ static void -disable_gl_state (CoglVertexAttribute **attributes, +disable_gl_state (CoglAttribute **attributes, CoglPipeline *source) { #ifdef MAY_HAVE_PROGRAMABLE_GL @@ -781,30 +781,30 @@ disable_gl_state (CoglVertexAttribute **attributes, for (i = 0; attributes[i]; i++) { - CoglVertexAttribute *attribute = attributes[i]; + CoglAttribute *attribute = attributes[i]; switch (attribute->name_id) { - case COGL_VERTEX_ATTRIBUTE_NAME_ID_COLOR_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_COLOR_ARRAY: /* GE (glDisableClientState (GL_COLOR_ARRAY)); */ break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_NORMAL_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_NORMAL_ARRAY: /* FIXME: go through cogl cache to enable normal array */ #ifndef HAVE_COGL_GLES2 GE (glDisableClientState (GL_NORMAL_ARRAY)); #endif break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_TEXTURE_COORD_ARRAY: /* The enabled state of the texture coord arrays is cached in ctx->enabled_texcoord_arrays so we don't need to do anything here. The array will be disabled by the next drawing primitive if it is not required */ break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_POSITION_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_POSITION_ARRAY: /* GE (glDisableClientState (GL_VERTEX_ARRAY)); */ break; - case COGL_VERTEX_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY: + case COGL_ATTRIBUTE_NAME_ID_CUSTOM_ARRAY: #ifdef MAY_HAVE_PROGRAMABLE_GL /* FIXME: go through cogl cache to enable generic array */ GE (glDisableVertexAttribArray (generic_index++)); @@ -842,7 +842,7 @@ static void add_line (void *vertices, void *indices, CoglIndicesType indices_type, - CoglVertexAttribute *attribute, + CoglAttribute *attribute, int start, int end, CoglVertexP3 *lines, @@ -869,13 +869,13 @@ add_line (void *vertices, } static CoglVertexP3 * -get_wire_lines (CoglVertexAttribute *attribute, +get_wire_lines (CoglAttribute *attribute, CoglVerticesMode mode, int n_vertices_in, int *n_vertices_out, CoglIndices *_indices) { - CoglVertexArray *vertex_array = cogl_vertex_attribute_get_array (attribute); + CoglVertexArray *vertex_array = cogl_attribute_get_array (attribute); void *vertices; CoglIndexArray *index_array; void *indices; @@ -988,14 +988,14 @@ static void draw_wireframe (CoglVerticesMode mode, int first_vertex, int n_vertices, - CoglVertexAttribute **attributes, + CoglAttribute **attributes, CoglIndices *indices) { - CoglVertexAttribute *position = NULL; + CoglAttribute *position = NULL; int i; int n_line_vertices; static CoglPipeline *wire_pipeline; - CoglVertexAttribute *wire_attribute[2]; + CoglAttribute *wire_attribute[2]; CoglVertexP3 *lines; CoglVertexArray *array; @@ -1018,11 +1018,11 @@ draw_wireframe (CoglVerticesMode mode, array = cogl_vertex_array_new (sizeof (CoglVertexP3) * n_line_vertices, lines); wire_attribute[0] = - cogl_vertex_attribute_new (array, "cogl_position_in", - sizeof (CoglVertexP3), - 0, - 3, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + cogl_attribute_new (array, "cogl_position_in", + sizeof (CoglVertexP3), + 0, + 3, + COGL_ATTRIBUTE_TYPE_FLOAT); wire_attribute[1] = NULL; cogl_object_unref (array); @@ -1037,14 +1037,14 @@ draw_wireframe (CoglVerticesMode mode, /* temporarily disable the wireframe to avoid recursion! */ cogl_debug_flags &= ~COGL_DEBUG_WIREFRAME; - _cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_LINES, - 0, - n_line_vertices, - wire_attribute, - COGL_DRAW_SKIP_JOURNAL_FLUSH | - COGL_DRAW_SKIP_PIPELINE_VALIDATION | - COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH | - COGL_DRAW_SKIP_LEGACY_STATE); + _cogl_draw_attributes_array (COGL_VERTICES_MODE_LINES, + 0, + n_line_vertices, + wire_attribute, + COGL_DRAW_SKIP_JOURNAL_FLUSH | + COGL_DRAW_SKIP_PIPELINE_VALIDATION | + COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH | + COGL_DRAW_SKIP_LEGACY_STATE); cogl_debug_flags |= COGL_DEBUG_WIREFRAME; @@ -1087,11 +1087,11 @@ flush_state (CoglDrawFlags flags, * skipping the implicit journal flush, the framebuffer flush and * pipeline validation. */ void -_cogl_draw_vertex_attributes_array (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglVertexAttribute **attributes, - CoglDrawFlags flags) +_cogl_draw_attributes_array (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglAttribute **attributes, + CoglDrawFlags flags) { ValidateLayerState state; CoglPipeline *source; @@ -1113,43 +1113,43 @@ _cogl_draw_vertex_attributes_array (CoglVerticesMode mode, } void -cogl_draw_vertex_attributes_array (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglVertexAttribute **attributes) +cogl_draw_attributes_array (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglAttribute **attributes) { - _cogl_draw_vertex_attributes_array (mode, first_vertex, - n_vertices, attributes, - 0 /* no flags */); + _cogl_draw_attributes_array (mode, first_vertex, + n_vertices, attributes, + 0 /* no flags */); } void -cogl_draw_vertex_attributes (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - ...) +cogl_draw_attributes (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + ...) { va_list ap; int n_attributes; - CoglVertexAttribute *attribute; - CoglVertexAttribute **attributes; + CoglAttribute *attribute; + CoglAttribute **attributes; int i; va_start (ap, n_vertices); - for (n_attributes = 0; va_arg (ap, CoglVertexAttribute *); n_attributes++) + for (n_attributes = 0; va_arg (ap, CoglAttribute *); n_attributes++) ; va_end (ap); - attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1)); + attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1)); attributes[n_attributes] = NULL; va_start (ap, n_vertices); - for (i = 0; (attribute = va_arg (ap, CoglVertexAttribute *)); i++) + for (i = 0; (attribute = va_arg (ap, CoglAttribute *)); i++) attributes[i] = attribute; va_end (ap); - cogl_draw_vertex_attributes_array (mode, first_vertex, n_vertices, - attributes); + cogl_draw_attributes_array (mode, first_vertex, n_vertices, + attributes); } static size_t @@ -1168,12 +1168,12 @@ sizeof_index_type (CoglIndicesType type) } void -_cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglIndices *indices, - CoglVertexAttribute **attributes, - CoglDrawFlags flags) +_cogl_draw_indexed_attributes_array (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglIndices *indices, + CoglAttribute **attributes, + CoglDrawFlags flags) { ValidateLayerState state; CoglPipeline *source; @@ -1225,48 +1225,48 @@ _cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode, } void -cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglIndices *indices, - CoglVertexAttribute **attributes) +cogl_draw_indexed_attributes_array (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglIndices *indices, + CoglAttribute **attributes) { - _cogl_draw_indexed_vertex_attributes_array (mode, first_vertex, - n_vertices, indices, attributes, - 0 /* no flags */); + _cogl_draw_indexed_attributes_array (mode, first_vertex, + n_vertices, indices, attributes, + 0 /* no flags */); } void -cogl_draw_indexed_vertex_attributes (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglIndices *indices, - ...) +cogl_draw_indexed_attributes (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglIndices *indices, + ...) { va_list ap; int n_attributes; - CoglVertexAttribute **attributes; + CoglAttribute **attributes; int i; - CoglVertexAttribute *attribute; + CoglAttribute *attribute; va_start (ap, indices); - for (n_attributes = 0; va_arg (ap, CoglVertexAttribute *); n_attributes++) + for (n_attributes = 0; va_arg (ap, CoglAttribute *); n_attributes++) ; va_end (ap); - attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1)); + attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1)); attributes[n_attributes] = NULL; va_start (ap, indices); - for (i = 0; (attribute = va_arg (ap, CoglVertexAttribute *)); i++) + for (i = 0; (attribute = va_arg (ap, CoglAttribute *)); i++) attributes[i] = attribute; va_end (ap); - cogl_draw_indexed_vertex_attributes_array (mode, - first_vertex, - n_vertices, - indices, - attributes); + cogl_draw_indexed_attributes_array (mode, + first_vertex, + n_vertices, + indices, + attributes); } diff --git a/clutter/cogl/cogl/cogl-vertex-attribute.h b/clutter/cogl/cogl/cogl-attribute.h similarity index 64% rename from clutter/cogl/cogl/cogl-vertex-attribute.h rename to clutter/cogl/cogl/cogl-attribute.h index 65579541e..70d4c2bd7 100644 --- a/clutter/cogl/cogl/cogl-vertex-attribute.h +++ b/clutter/cogl/cogl/cogl-attribute.h @@ -28,8 +28,8 @@ #error "Only can be included directly." #endif -#ifndef __COGL_VERTEX_ATTRIBUTE_H__ -#define __COGL_VERTEX_ATTRIBUTE_H__ +#ifndef __COGL_ATTRIBUTE_H__ +#define __COGL_ATTRIBUTE_H__ #include #include @@ -37,40 +37,17 @@ G_BEGIN_DECLS /** - * SECTION:cogl-vertex-attribute - * @short_description: Fuctions for declaring and drawing vertex + * SECTION:cogl-attribute + * @short_description: Functions for declaring and drawing vertex * attributes * * FIXME */ -typedef struct _CoglVertexAttribute CoglVertexAttribute; +typedef struct _CoglAttribute CoglAttribute; /** - * CoglVertexAttributeType: - * @COGL_VERTEX_ATTRIBUTE_TYPE_BYTE: Data is the same size of a byte - * @COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE: Data is the same size of an - * unsigned byte - * @COGL_VERTEX_ATTRIBUTE_TYPE_SHORT: Data is the same size of a short integer - * @COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_SHORT: Data is the same size of - * an unsigned short integer - * @COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT: Data is the same size of a float - * - * Data types for the components of a vertex attribute. - * - * Since: 1.4 - * Stability: Unstable - */ -typedef enum { - COGL_VERTEX_ATTRIBUTE_TYPE_BYTE = 0x1400, - COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE = 0x1401, - COGL_VERTEX_ATTRIBUTE_TYPE_SHORT = 0x1402, - COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_SHORT = 0x1403, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT = 0x1406 -} CoglVertexAttributeType; - -/** - * cogl_vertex_attribute_new: + * cogl_attribute_new: * @array: The #CoglVertexArray containing the actual attribute data * @name: The name of the attribute (used to reference it from GLSL) * @stride: The number of bytes to jump to get to the next attribute @@ -145,7 +122,7 @@ typedef enum { * mapped into the GPU which can be a bottlneck when dealing with * a large number of vertices. * - * Returns: A newly allocated #CoglVertexAttribute describing the + * Returns: A newly allocated #CoglAttribute describing the * layout for a list of attribute values stored in @array. * * Since: 1.4 @@ -153,53 +130,53 @@ typedef enum { */ /* XXX: look for a precedent to see if the stride/offset args should * have a different order. */ -CoglVertexAttribute * -cogl_vertex_attribute_new (CoglVertexArray *array, - const char *name, - gsize stride, - gsize offset, - int components, - CoglVertexAttributeType type); +CoglAttribute * +cogl_attribute_new (CoglVertexArray *array, + const char *name, + gsize stride, + gsize offset, + int components, + CoglAttributeType type); /** - * cogl_is_vertex_attribute: + * cogl_is_attribute: * @object: A #CoglObject * - * Gets whether the given object references a #CoglVertexAttribute. + * Gets whether the given object references a #CoglAttribute. * - * Return value: %TRUE if the handle references a #CoglVertexAttribute, + * Return value: %TRUE if the handle references a #CoglAttribute, * %FALSE otherwise */ gboolean -cogl_is_vertex_attribute (void *object); +cogl_is_attribute (void *object); void -cogl_draw_vertex_attributes (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - ...) G_GNUC_NULL_TERMINATED; +cogl_draw_attributes (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + ...) G_GNUC_NULL_TERMINATED; void -cogl_draw_vertex_attributes_array (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglVertexAttribute **attributes); +cogl_draw_attributes_array (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglAttribute **attributes); void -cogl_draw_indexed_vertex_attributes (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglIndices *indices, - ...) G_GNUC_NULL_TERMINATED; +cogl_draw_indexed_attributes (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglIndices *indices, + ...) G_GNUC_NULL_TERMINATED; void -cogl_draw_indexed_vertex_attributes_array (CoglVerticesMode mode, - int first_vertex, - int n_vertices, - CoglIndices *indices, - CoglVertexAttribute **attributes); +cogl_draw_indexed_attributes_array (CoglVerticesMode mode, + int first_vertex, + int n_vertices, + CoglIndices *indices, + CoglAttribute **attributes); G_END_DECLS -#endif /* __COGL_VERTEX_ATTRIBUTE_H__ */ +#endif /* __COGL_ATTRIBUTE_H__ */ diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c index 28eac36b9..c1b061058 100644 --- a/clutter/cogl/cogl/cogl-context.c +++ b/clutter/cogl/cogl/cogl-context.c @@ -167,7 +167,7 @@ cogl_create_context (void) _context->default_gl_texture_rect_tex = COGL_INVALID_HANDLE; _context->journal_flush_attributes_array = - g_array_new (TRUE, FALSE, sizeof (CoglVertexAttribute *)); + g_array_new (TRUE, FALSE, sizeof (CoglAttribute *)); _context->journal_clip_bounds = NULL; _context->polygon_vertices = g_array_new (FALSE, FALSE, sizeof (float)); diff --git a/clutter/cogl/cogl/cogl-index-array.c b/clutter/cogl/cogl/cogl-index-array.c index d39a14583..2a8515185 100644 --- a/clutter/cogl/cogl/cogl-index-array.c +++ b/clutter/cogl/cogl/cogl-index-array.c @@ -89,7 +89,7 @@ cogl_index_array_allocate (CoglIndexArray *indices, * data. * * XXX: I think in the end it'll be that CoglIndices are to - * CoglIndexArrays as CoglVertexAttributes are to CoglVertices. I.e + * CoglIndexArrays as CoglAttributes are to CoglVertices. I.e * a CoglIndexArray is a lite subclass of CoglBuffer that simply * implies that the buffer will later be bound as indices but doesn't * track more detailed meta data. CoglIndices build on a @@ -98,7 +98,7 @@ cogl_index_array_allocate (CoglIndexArray *indices, * * XXX: The double plurel form that "Indices" "Array" implies could be * a bit confusing. Also to be a bit more consistent with - * CoglVertexArray vs CoglVertexAttribute it might be best to rename so + * CoglVertexArray vs CoglAttribute it might be best to rename so * we have CoglIndexArray vs CoglIndices? maybe even * CoglIndexRange :-/ ? * diff --git a/clutter/cogl/cogl/cogl-journal.c b/clutter/cogl/cogl/cogl-journal.c index e9f3a4cef..de2315cf3 100644 --- a/clutter/cogl/cogl/cogl-journal.c +++ b/clutter/cogl/cogl/cogl-journal.c @@ -36,7 +36,7 @@ #include "cogl-vertex-buffer-private.h" #include "cogl-framebuffer-private.h" #include "cogl-profile.h" -#include "cogl-vertex-attribute-private.h" +#include "cogl-attribute-private.h" #include "cogl-point-in-poly-private.h" #include @@ -260,7 +260,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, void *data) { CoglJournalFlushState *state = data; - CoglVertexAttribute **attributes; + CoglAttribute **attributes; CoglDrawFlags draw_flags = (COGL_DRAW_SKIP_JOURNAL_FLUSH | COGL_DRAW_SKIP_PIPELINE_VALIDATION | COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH | @@ -287,7 +287,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, COGL_MATRIX_MODELVIEW); } - attributes = (CoglVertexAttribute **)state->attributes->data; + attributes = (CoglAttribute **)state->attributes->data; cogl_push_source (state->source); if (!_cogl_pipeline_get_real_blend_enabled (state->source)) @@ -296,28 +296,28 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, #ifdef HAVE_COGL_GL /* XXX: it's rather evil that we sneak in the GL_QUADS enum here... */ - _cogl_draw_vertex_attributes_array (GL_QUADS, - state->current_vertex, batch_len * 4, - attributes, - draw_flags); + _cogl_draw_attributes_array (GL_QUADS, + state->current_vertex, batch_len * 4, + attributes, + draw_flags); #else /* HAVE_COGL_GL */ if (batch_len > 1) { - _cogl_draw_indexed_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLES, - state->current_vertex * 6 / 4, - batch_len * 6, - state->indices, - attributes, - draw_flags); + _cogl_draw_indexed_attributes_array (COGL_VERTICES_MODE_TRIANGLES, + state->current_vertex * 6 / 4, + batch_len * 6, + state->indices, + attributes, + draw_flags); } else { - _cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN, - state->current_vertex, 4, - attributes, - draw_flags); + _cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN, + state->current_vertex, 4, + attributes, + draw_flags); } #endif @@ -332,7 +332,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, static CoglPipeline *outline = NULL; guint8 color_intensity; int i; - CoglVertexAttribute *loop_attributes[2]; + CoglAttribute *loop_attributes[2]; _COGL_GET_CONTEXT (ctxt, NO_RETVAL); @@ -360,10 +360,10 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start, loop_attributes[0] = attributes[0]; /* we just want the position */ loop_attributes[1] = NULL; for (i = 0; i < batch_len; i++) - _cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_LINE_LOOP, - 4 * i + state->current_vertex, 4, - loop_attributes, - draw_flags); + _cogl_draw_attributes_array (COGL_VERTICES_MODE_LINE_LOOP, + 4 * i + state->current_vertex, 4, + loop_attributes, + draw_flags); /* Go to the next color */ do @@ -483,15 +483,14 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries ( /* NB: attributes 0 and 1 are position and color */ for (i = 2; i < state->attributes->len; i++) - cogl_object_unref (g_array_index (state->attributes, - CoglVertexAttribute *, i)); + cogl_object_unref (g_array_index (state->attributes, CoglAttribute *, i)); g_array_set_size (state->attributes, batch_start->n_layers + 2); for (i = 0; i < batch_start->n_layers; i++) { - CoglVertexAttribute **attribute_entry = - &g_array_index (state->attributes, CoglVertexAttribute *, i + 2); + CoglAttribute **attribute_entry = + &g_array_index (state->attributes, CoglAttribute *, i + 2); const char *names[] = { "cogl_tex_coord0_in", "cogl_tex_coord1_in", @@ -519,14 +518,14 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries ( /* XXX: it may be worth having some form of static initializer for * attributes... */ *attribute_entry = - cogl_vertex_attribute_new (state->vertex_array, - name, - state->stride, - state->array_offset + - (POS_STRIDE + COLOR_STRIDE) * 4 + - TEX_STRIDE * 4 * i, - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + cogl_attribute_new (state->vertex_array, + name, + state->stride, + state->array_offset + + (POS_STRIDE + COLOR_STRIDE) * 4 + + TEX_STRIDE * 4 * i, + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); if (i >= 8) g_free (name); @@ -559,7 +558,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, CoglJournalFlushState *state = data; gsize stride; int i; - CoglVertexAttribute **attribute_entry; + CoglAttribute **attribute_entry; COGL_STATIC_TIMER (time_flush_vbo_texcoord_pipeline_entries, "flush: clip+vbo+texcoords+pipeline+entries", /* parent */ "flush: vbo+texcoords+pipeline+entries", @@ -589,39 +588,36 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start, state->stride = stride; for (i = 0; i < state->attributes->len; i++) - cogl_object_unref (g_array_index (state->attributes, - CoglVertexAttribute *, i)); + cogl_object_unref (g_array_index (state->attributes, CoglAttribute *, i)); g_array_set_size (state->attributes, 2); - attribute_entry = - &g_array_index (state->attributes, CoglVertexAttribute *, 0); - *attribute_entry = - cogl_vertex_attribute_new (state->vertex_array, - "cogl_position_in", - stride, - state->array_offset, - N_POS_COMPONENTS, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 0); + *attribute_entry = cogl_attribute_new (state->vertex_array, + "cogl_position_in", + stride, + state->array_offset, + N_POS_COMPONENTS, + COGL_ATTRIBUTE_TYPE_FLOAT); - attribute_entry = - &g_array_index (state->attributes, CoglVertexAttribute *, 1); + attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 1); *attribute_entry = - cogl_vertex_attribute_new (state->vertex_array, - "cogl_color_in", - stride, - state->array_offset + (POS_STRIDE * 4), - 4, - COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE); + cogl_attribute_new (state->vertex_array, + "cogl_color_in", + stride, + state->array_offset + (POS_STRIDE * 4), + 4, + COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); #ifndef HAVE_COGL_GL state->indices = cogl_get_rectangle_indices (batch_len); #endif - /* We only create new VertexAttributes when the stride within the - * VertexArray changes. (due to a change in the number of pipeline layers) - * While the stride remains constant we walk forward through the above - * VertexArray using a vertex offset passed to cogl_draw_vertex_attributes + /* We only create new Attributes when the stride within the + * VertexArray changes. (due to a change in the number of pipeline + * layers) While the stride remains constant we walk forward through + * the above VertexArray using a vertex offset passed to + * cogl_draw_attributes */ state->current_vertex = 0; @@ -1376,8 +1372,7 @@ _cogl_journal_flush (CoglJournal *journal, &state); /* data */ for (i = 0; i < state.attributes->len; i++) - cogl_object_unref (g_array_index (state.attributes, - CoglVertexAttribute *, i)); + cogl_object_unref (g_array_index (state.attributes, CoglAttribute *, i)); g_array_set_size (state.attributes, 0); cogl_object_unref (state.vertex_array); diff --git a/clutter/cogl/cogl/cogl-path-private.h b/clutter/cogl/cogl/cogl-path-private.h index ba0b4cb8b..f3ea62299 100644 --- a/clutter/cogl/cogl/cogl-path-private.h +++ b/clutter/cogl/cogl/cogl-path-private.h @@ -82,10 +82,10 @@ struct _CoglPathData CoglVertexArray *fill_vbo; CoglIndices *fill_vbo_indices; unsigned int fill_vbo_n_indices; - CoglVertexAttribute *fill_vbo_attributes[COGL_PATH_N_ATTRIBUTES + 1]; + CoglAttribute *fill_vbo_attributes[COGL_PATH_N_ATTRIBUTES + 1]; CoglVertexArray *stroke_vbo; - CoglVertexAttribute **stroke_vbo_attributes; + CoglAttribute **stroke_vbo_attributes; unsigned int stroke_vbo_n_attributes; }; diff --git a/clutter/cogl/cogl/cogl-pipeline-progend-glsl-private.h b/clutter/cogl/cogl/cogl-pipeline-progend-glsl-private.h index 6fe6e4bd4..c100269b3 100644 --- a/clutter/cogl/cogl/cogl-pipeline-progend-glsl-private.h +++ b/clutter/cogl/cogl/cogl-pipeline-progend-glsl-private.h @@ -29,7 +29,7 @@ #define __COGL_PIPELINE_PROGEND_GLSL_PRIVATE_H #include "cogl-pipeline-private.h" -#include "cogl-vertex-attribute-private.h" +#include "cogl-attribute-private.h" extern const CoglPipelineProgend _cogl_pipeline_glsl_progend; diff --git a/clutter/cogl/cogl/cogl-primitive.c b/clutter/cogl/cogl/cogl-primitive.c index cfc45343a..9b76241ac 100644 --- a/clutter/cogl/cogl/cogl-primitive.c +++ b/clutter/cogl/cogl/cogl-primitive.c @@ -32,7 +32,7 @@ #include "cogl-object-private.h" #include "cogl-primitive.h" #include "cogl-primitive-private.h" -#include "cogl-vertex-attribute-private.h" +#include "cogl-attribute-private.h" #include @@ -44,7 +44,7 @@ COGL_OBJECT_DEFINE (Primitive, primitive); CoglPrimitive * cogl_primitive_new_with_attributes_array (CoglVerticesMode mode, int n_vertices, - CoglVertexAttribute **attributes) + CoglAttribute **attributes) { CoglPrimitive *primitive = g_slice_new (CoglPrimitive); int i; @@ -54,15 +54,15 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode, primitive->n_vertices = n_vertices; primitive->indices = NULL; primitive->attributes = - g_array_new (TRUE, FALSE, sizeof (CoglVertexAttribute *)); + g_array_new (TRUE, FALSE, sizeof (CoglAttribute *)); primitive->immutable_ref = 0; for (i = 0; attributes[i]; i++) { - CoglVertexAttribute *attribute = attributes[i]; + CoglAttribute *attribute = attributes[i]; cogl_object_ref (attribute); - g_return_val_if_fail (cogl_is_vertex_attribute (attribute), NULL); + g_return_val_if_fail (cogl_is_attribute (attribute), NULL); g_array_append_val (primitive->attributes, attribute); } @@ -74,10 +74,9 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode, new_with_attributes that also unrefs the attributes. It is just used for the builtin struct constructors */ static CoglPrimitive * -_cogl_primitive_new_with_attributes_array_unref - (CoglVerticesMode mode, - int n_vertices, - CoglVertexAttribute **attributes) +_cogl_primitive_new_with_attributes_array_unref (CoglVerticesMode mode, + int n_vertices, + CoglAttribute **attributes) { CoglPrimitive *primitive; int i; @@ -99,20 +98,20 @@ cogl_primitive_new (CoglVerticesMode mode, { va_list ap; int n_attributes; - CoglVertexAttribute **attributes; + CoglAttribute **attributes; int i; - CoglVertexAttribute *attribute; + CoglAttribute *attribute; va_start (ap, n_vertices); - for (n_attributes = 0; va_arg (ap, CoglVertexAttribute *); n_attributes++) + for (n_attributes = 0; va_arg (ap, CoglAttribute *); n_attributes++) ; va_end (ap); - attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1)); + attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1)); attributes[n_attributes] = NULL; va_start (ap, n_vertices); - for (i = 0; (attribute = va_arg (ap, CoglVertexAttribute *)); i++) + for (i = 0; (attribute = va_arg (ap, CoglAttribute *)); i++) attributes[i] = attribute; va_end (ap); @@ -127,15 +126,14 @@ cogl_primitive_new_p2 (CoglVerticesMode mode, { CoglVertexArray *array = cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2), data); - CoglVertexAttribute *attributes[2]; + CoglAttribute *attributes[2]; - attributes[0] = - cogl_vertex_attribute_new (array, - "cogl_position_in", - sizeof (CoglVertexP2), - offsetof (CoglVertexP2, x), - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + attributes[0] = cogl_attribute_new (array, + "cogl_position_in", + sizeof (CoglVertexP2), + offsetof (CoglVertexP2, x), + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); attributes[1] = NULL; cogl_object_unref (array); @@ -151,15 +149,14 @@ cogl_primitive_new_p3 (CoglVerticesMode mode, { CoglVertexArray *array = cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3), data); - CoglVertexAttribute *attributes[2]; + CoglAttribute *attributes[2]; - attributes[0] = - cogl_vertex_attribute_new (array, - "cogl_position_in", - sizeof (CoglVertexP3), - offsetof (CoglVertexP3, x), - 3, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + attributes[0] = cogl_attribute_new (array, + "cogl_position_in", + sizeof (CoglVertexP3), + offsetof (CoglVertexP3, x), + 3, + COGL_ATTRIBUTE_TYPE_FLOAT); attributes[1] = NULL; cogl_object_unref (array); @@ -175,22 +172,20 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode, { CoglVertexArray *array = cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2C4), data); - CoglVertexAttribute *attributes[3]; + CoglAttribute *attributes[3]; - attributes[0] = - cogl_vertex_attribute_new (array, - "cogl_position_in", - sizeof (CoglVertexP2C4), - offsetof (CoglVertexP2C4, x), - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = - cogl_vertex_attribute_new (array, - "cogl_color_in", - sizeof (CoglVertexP2C4), - offsetof (CoglVertexP2C4, r), - 4, - COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE); + attributes[0] = cogl_attribute_new (array, + "cogl_position_in", + sizeof (CoglVertexP2C4), + offsetof (CoglVertexP2C4, x), + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); + attributes[1] = cogl_attribute_new (array, + "cogl_color_in", + sizeof (CoglVertexP2C4), + offsetof (CoglVertexP2C4, r), + 4, + COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); attributes[2] = NULL; cogl_object_unref (array); @@ -206,22 +201,20 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode, { CoglVertexArray *array = cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3C4), data); - CoglVertexAttribute *attributes[3]; + CoglAttribute *attributes[3]; - attributes[0] = - cogl_vertex_attribute_new (array, - "cogl_position_in", - sizeof (CoglVertexP3C4), - offsetof (CoglVertexP3C4, x), - 3, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = - cogl_vertex_attribute_new (array, - "cogl_color_in", - sizeof (CoglVertexP3C4), - offsetof (CoglVertexP3C4, r), - 4, - COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE); + attributes[0] = cogl_attribute_new (array, + "cogl_position_in", + sizeof (CoglVertexP3C4), + offsetof (CoglVertexP3C4, x), + 3, + COGL_ATTRIBUTE_TYPE_FLOAT); + attributes[1] = cogl_attribute_new (array, + "cogl_color_in", + sizeof (CoglVertexP3C4), + offsetof (CoglVertexP3C4, r), + 4, + COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); attributes[2] = NULL; cogl_object_unref (array); @@ -237,22 +230,20 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode, { CoglVertexArray *array = cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2), data); - CoglVertexAttribute *attributes[3]; + CoglAttribute *attributes[3]; - attributes[0] = - cogl_vertex_attribute_new (array, - "cogl_position_in", - sizeof (CoglVertexP2T2), - offsetof (CoglVertexP2T2, x), - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = - cogl_vertex_attribute_new (array, - "cogl_tex_coord0_in", - sizeof (CoglVertexP2T2), - offsetof (CoglVertexP2T2, s), - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + attributes[0] = cogl_attribute_new (array, + "cogl_position_in", + sizeof (CoglVertexP2T2), + offsetof (CoglVertexP2T2, x), + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); + attributes[1] = cogl_attribute_new (array, + "cogl_tex_coord0_in", + sizeof (CoglVertexP2T2), + offsetof (CoglVertexP2T2, s), + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); attributes[2] = NULL; cogl_object_unref (array); @@ -268,22 +259,20 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode, { CoglVertexArray *array = cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2), data); - CoglVertexAttribute *attributes[3]; + CoglAttribute *attributes[3]; - attributes[0] = - cogl_vertex_attribute_new (array, - "cogl_position_in", - sizeof (CoglVertexP3T2), - offsetof (CoglVertexP3T2, x), - 3, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = - cogl_vertex_attribute_new (array, - "cogl_tex_coord0_in", - sizeof (CoglVertexP3T2), - offsetof (CoglVertexP3T2, s), - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + attributes[0] = cogl_attribute_new (array, + "cogl_position_in", + sizeof (CoglVertexP3T2), + offsetof (CoglVertexP3T2, x), + 3, + COGL_ATTRIBUTE_TYPE_FLOAT); + attributes[1] = cogl_attribute_new (array, + "cogl_tex_coord0_in", + sizeof (CoglVertexP3T2), + offsetof (CoglVertexP3T2, s), + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); attributes[2] = NULL; cogl_object_unref (array); @@ -299,29 +288,26 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode, { CoglVertexArray *array = cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2C4), data); - CoglVertexAttribute *attributes[4]; + CoglAttribute *attributes[4]; - attributes[0] = - cogl_vertex_attribute_new (array, - "cogl_position_in", - sizeof (CoglVertexP2T2C4), - offsetof (CoglVertexP2T2C4, x), - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = - cogl_vertex_attribute_new (array, - "cogl_tex_coord0_in", - sizeof (CoglVertexP2T2C4), - offsetof (CoglVertexP2T2C4, s), - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); - attributes[2] = - cogl_vertex_attribute_new (array, - "cogl_color_in", - sizeof (CoglVertexP2T2C4), - offsetof (CoglVertexP2T2C4, r), - 4, - COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE); + attributes[0] = cogl_attribute_new (array, + "cogl_position_in", + sizeof (CoglVertexP2T2C4), + offsetof (CoglVertexP2T2C4, x), + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); + attributes[1] = cogl_attribute_new (array, + "cogl_tex_coord0_in", + sizeof (CoglVertexP2T2C4), + offsetof (CoglVertexP2T2C4, s), + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); + attributes[2] = cogl_attribute_new (array, + "cogl_color_in", + sizeof (CoglVertexP2T2C4), + offsetof (CoglVertexP2T2C4, r), + 4, + COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); attributes[3] = NULL; cogl_object_unref (array); @@ -337,29 +323,26 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode, { CoglVertexArray *array = cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2C4), data); - CoglVertexAttribute *attributes[4]; + CoglAttribute *attributes[4]; - attributes[0] = - cogl_vertex_attribute_new (array, - "cogl_position_in", - sizeof (CoglVertexP3T2C4), - offsetof (CoglVertexP3T2C4, x), - 3, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); - attributes[1] = - cogl_vertex_attribute_new (array, - "cogl_tex_coord0_in", - sizeof (CoglVertexP3T2C4), - offsetof (CoglVertexP3T2C4, s), - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); - attributes[2] = - cogl_vertex_attribute_new (array, - "cogl_color_in", - sizeof (CoglVertexP3T2C4), - offsetof (CoglVertexP3T2C4, r), - 4, - COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE); + attributes[0] = cogl_attribute_new (array, + "cogl_position_in", + sizeof (CoglVertexP3T2C4), + offsetof (CoglVertexP3T2C4, x), + 3, + COGL_ATTRIBUTE_TYPE_FLOAT); + attributes[1] = cogl_attribute_new (array, + "cogl_tex_coord0_in", + sizeof (CoglVertexP3T2C4), + offsetof (CoglVertexP3T2C4, s), + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); + attributes[2] = cogl_attribute_new (array, + "cogl_color_in", + sizeof (CoglVertexP3T2C4), + offsetof (CoglVertexP3T2C4, r), + 4, + COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); attributes[3] = NULL; cogl_object_unref (array); @@ -375,8 +358,8 @@ free_attributes_list (CoglPrimitive *primitive) for (i = 0; i < primitive->attributes->len; i++) { - CoglVertexAttribute *attribute = - g_array_index (primitive->attributes, CoglVertexAttribute *, i); + CoglAttribute *attribute = + g_array_index (primitive->attributes, CoglAttribute *, i); cogl_object_unref (attribute); } g_array_set_size (primitive->attributes, 0); @@ -406,7 +389,7 @@ warn_about_midscene_changes (void) void cogl_primitive_set_attributes (CoglPrimitive *primitive, - CoglVertexAttribute **attributes) + CoglAttribute **attributes) { int i; @@ -424,7 +407,7 @@ cogl_primitive_set_attributes (CoglPrimitive *primitive, for (i = 0; attributes[i]; i++) { cogl_object_ref (attributes[i]); - g_return_if_fail (cogl_is_vertex_attribute (attributes[i])); + g_return_if_fail (cogl_is_attribute (attributes[i])); g_array_append_val (primitive->attributes, attributes[i]); } } @@ -522,9 +505,9 @@ _cogl_primitive_immutable_ref (CoglPrimitive *primitive) for (i = 0; i < primitive->attributes->len; i++) { - CoglVertexAttribute *attribute = - g_array_index (primitive->attributes, CoglVertexAttribute *, i); - _cogl_vertex_attribute_immutable_ref (attribute); + CoglAttribute *attribute = + g_array_index (primitive->attributes, CoglAttribute *, i); + _cogl_attribute_immutable_ref (attribute); } return primitive; @@ -542,9 +525,9 @@ _cogl_primitive_immutable_unref (CoglPrimitive *primitive) for (i = 0; i < primitive->attributes->len; i++) { - CoglVertexAttribute *attribute = - g_array_index (primitive->attributes, CoglVertexAttribute *, i); - _cogl_vertex_attribute_immutable_unref (attribute); + CoglAttribute *attribute = + g_array_index (primitive->attributes, CoglAttribute *, i); + _cogl_attribute_immutable_unref (attribute); } } @@ -552,19 +535,19 @@ _cogl_primitive_immutable_unref (CoglPrimitive *primitive) void cogl_primitive_draw (CoglPrimitive *primitive) { - CoglVertexAttribute **attributes = - (CoglVertexAttribute **)primitive->attributes->data; + CoglAttribute **attributes = + (CoglAttribute **)primitive->attributes->data; if (primitive->indices) - cogl_draw_indexed_vertex_attributes_array (primitive->mode, - primitive->first_vertex, - primitive->n_vertices, - primitive->indices, - attributes); + cogl_draw_indexed_attributes_array (primitive->mode, + primitive->first_vertex, + primitive->n_vertices, + primitive->indices, + attributes); else - cogl_draw_vertex_attributes_array (primitive->mode, - primitive->first_vertex, - primitive->n_vertices, - attributes); + cogl_draw_attributes_array (primitive->mode, + primitive->first_vertex, + primitive->n_vertices, + attributes); } diff --git a/clutter/cogl/cogl/cogl-primitive.h b/clutter/cogl/cogl/cogl-primitive.h index 0f0aeaceb..d286841be 100644 --- a/clutter/cogl/cogl/cogl-primitive.h +++ b/clutter/cogl/cogl/cogl-primitive.h @@ -32,7 +32,7 @@ #define __COGL_PRIMITIVE_H__ #include /* for CoglVerticesMode */ -#include +#include G_BEGIN_DECLS @@ -217,7 +217,7 @@ typedef struct * @n_vertices: The number of vertices to process when drawing * @Varargs: A %NULL terminated list of attributes * - * Combines a set of #CoglVertexAttributes with a specific draw @mode + * Combines a set of #CoglAttributes with a specific draw @mode * and defines a vertex count so a #CoglPrimitive object can be retained and * drawn later with no addition information required. * @@ -235,7 +235,7 @@ cogl_primitive_new (CoglVerticesMode mode, CoglPrimitive * cogl_primitive_new_with_attributes_array (CoglVerticesMode mode, int n_vertices, - CoglVertexAttribute **attributes); + CoglAttribute **attributes); /** * cogl_primitive_new_p2: @@ -246,7 +246,7 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode, * Provides a convenient way to describe a primitive, such as a single * triangle strip or a triangle fan, that will internally allocate the * necessary #CoglVertexArray storage, describe the position - * attribute with a #CoglVertexAttribute and upload your data. + * attribute with a #CoglAttribute and upload your data. * * For example to draw a convex polygon you can do: * |[ @@ -290,7 +290,7 @@ cogl_primitive_new_p2 (CoglVerticesMode mode, * Provides a convenient way to describe a primitive, such as a single * triangle strip or a triangle fan, that will internally allocate the * necessary #CoglVertexArray storage, describe the position - * attribute with a #CoglVertexAttribute and upload your data. + * attribute with a #CoglAttribute and upload your data. * * For example to draw a convex polygon you can do: * |[ @@ -334,7 +334,7 @@ cogl_primitive_new_p3 (CoglVerticesMode mode, * Provides a convenient way to describe a primitive, such as a single * triangle strip or a triangle fan, that will internally allocate the * necessary #CoglVertexArray storage, describe the position - * and color attributes with #CoglVertexAttributes and upload + * and color attributes with #CoglAttributes and upload * your data. * * For example to draw a convex polygon with a linear gradient you @@ -380,7 +380,7 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode, * Provides a convenient way to describe a primitive, such as a single * triangle strip or a triangle fan, that will internally allocate the * necessary #CoglVertexArray storage, describe the position - * and color attributes with #CoglVertexAttributes and upload + * and color attributes with #CoglAttributes and upload * your data. * * For example to draw a convex polygon with a linear gradient you @@ -426,7 +426,7 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode, * Provides a convenient way to describe a primitive, such as a single * triangle strip or a triangle fan, that will internally allocate the * necessary #CoglVertexArray storage, describe the position and - * texture coordinate attributes with #CoglVertexAttributes and + * texture coordinate attributes with #CoglAttributes and * upload your data. * * For example to draw a convex polygon with texture mapping you can @@ -472,7 +472,7 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode, * Provides a convenient way to describe a primitive, such as a single * triangle strip or a triangle fan, that will internally allocate the * necessary #CoglVertexArray storage, describe the position and - * texture coordinate attributes with #CoglVertexAttributes and + * texture coordinate attributes with #CoglAttributes and * upload your data. * * For example to draw a convex polygon with texture mapping you can @@ -518,7 +518,7 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode, * Provides a convenient way to describe a primitive, such as a single * triangle strip or a triangle fan, that will internally allocate the * necessary #CoglVertexArray storage, describe the position, texture - * coordinate and color attributes with #CoglVertexAttributes and + * coordinate and color attributes with #CoglAttributes and * upload your data. * * For example to draw a convex polygon with texture mapping and a @@ -564,7 +564,7 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode, * Provides a convenient way to describe a primitive, such as a single * triangle strip or a triangle fan, that will internally allocate the * necessary #CoglVertexArray storage, describe the position, texture - * coordinate and color attributes with #CoglVertexAttributes and + * coordinate and color attributes with #CoglAttributes and * upload your data. * * For example to draw a convex polygon with texture mapping and a @@ -624,7 +624,7 @@ cogl_primitive_set_mode (CoglPrimitive *primitive, /** * cogl_primitive_set_attributes: * @primitive: A #CoglPrimitive object - * @attributes: A %NULL terminated array of #CoglVertexAttribute + * @attributes: A %NULL terminated array of #CoglAttribute * pointers * * Replaces all the attributes of the given #CoglPrimitive object. @@ -634,7 +634,7 @@ cogl_primitive_set_mode (CoglPrimitive *primitive, */ void cogl_primitive_set_attributes (CoglPrimitive *primitive, - CoglVertexAttribute **attributes); + CoglAttribute **attributes); void diff --git a/clutter/cogl/cogl/cogl-primitives.c b/clutter/cogl/cogl/cogl-primitives.c index c88470cb9..8628ee434 100644 --- a/clutter/cogl/cogl/cogl-primitives.c +++ b/clutter/cogl/cogl/cogl-primitives.c @@ -35,7 +35,7 @@ #include "cogl-pipeline-opengl-private.h" #include "cogl-vertex-buffer-private.h" #include "cogl-framebuffer-private.h" -#include "cogl-vertex-attribute-private.h" +#include "cogl-attribute-private.h" #include #include @@ -68,7 +68,7 @@ typedef struct _TextureSlicedPolygonState const CoglTextureVertex *vertices; int n_vertices; int stride; - CoglVertexAttribute **attributes; + CoglAttribute **attributes; } TextureSlicedPolygonState; static void @@ -934,24 +934,24 @@ _cogl_rectangle_immediate (float x_1, x_2, y_2 }; CoglVertexArray *vertex_array; - CoglVertexAttribute *attributes[2]; + CoglAttribute *attributes[2]; vertex_array = cogl_vertex_array_new (sizeof (vertices), vertices); - attributes[0] = cogl_vertex_attribute_new (vertex_array, - "cogl_position_in", - sizeof (float) * 2, /* stride */ - 0, /* offset */ - 2, /* n_components */ - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + attributes[0] = cogl_attribute_new (vertex_array, + "cogl_position_in", + sizeof (float) * 2, /* stride */ + 0, /* offset */ + 2, /* n_components */ + COGL_ATTRIBUTE_TYPE_FLOAT); attributes[1] = NULL; - _cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLE_STRIP, - 0, /* first_index */ - 4, /* n_vertices */ - attributes, - COGL_DRAW_SKIP_JOURNAL_FLUSH | - COGL_DRAW_SKIP_PIPELINE_VALIDATION | - COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH); + _cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_STRIP, + 0, /* first_index */ + 4, /* n_vertices */ + attributes, + COGL_DRAW_SKIP_JOURNAL_FLUSH | + COGL_DRAW_SKIP_PIPELINE_VALIDATION | + COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH); cogl_object_unref (attributes[0]); @@ -1046,7 +1046,7 @@ cogl_polygon (const CoglTextureVertex *vertices, ValidateState validate_state; int n_layers; int n_attributes; - CoglVertexAttribute **attributes; + CoglAttribute **attributes; int i; unsigned int stride; gsize stride_bytes; @@ -1067,7 +1067,7 @@ cogl_polygon (const CoglTextureVertex *vertices, n_layers = cogl_pipeline_get_n_layers (pipeline); n_attributes = 1 + n_layers + (use_color ? 1 : 0); - attributes = g_alloca (sizeof (CoglVertexAttribute *) * (n_attributes + 1)); + attributes = g_alloca (sizeof (CoglAttribute *) * (n_attributes + 1)); attributes[n_attributes] = NULL; /* Our data is arranged like: @@ -1082,13 +1082,12 @@ cogl_polygon (const CoglTextureVertex *vertices, vertex_array = cogl_vertex_array_new (n_vertices * stride_bytes, NULL); - attributes[0] = - cogl_vertex_attribute_new (vertex_array, - "cogl_position_in", - stride_bytes, - 0, - 3, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + attributes[0] = cogl_attribute_new (vertex_array, + "cogl_position_in", + stride_bytes, + 0, + 3, + COGL_ATTRIBUTE_TYPE_FLOAT); for (i = 0; i < n_layers; i++) { @@ -1105,26 +1104,25 @@ cogl_polygon (const CoglTextureVertex *vertices, char *name = i < 8 ? (char *)names[i] : g_strdup_printf ("cogl_tex_coord%d_in", i); - attributes[i + 1] = - cogl_vertex_attribute_new (vertex_array, - name, - stride_bytes, - /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ - 12 + 8 * i, - 2, - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + attributes[i + 1] = cogl_attribute_new (vertex_array, + name, + stride_bytes, + /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ + 12 + 8 * i, + 2, + COGL_ATTRIBUTE_TYPE_FLOAT); } if (use_color) { attributes[n_attributes - 1] = - cogl_vertex_attribute_new (vertex_array, - "cogl_color_in", - stride_bytes, - /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ - 12 + 8 * n_layers, - 4, - COGL_VERTEX_ATTRIBUTE_TYPE_UNSIGNED_BYTE); + cogl_attribute_new (vertex_array, + "cogl_color_in", + stride_bytes, + /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ + 12 + 8 * n_layers, + 4, + COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); } /* Convert the vertices into an array of float vertex attributes */ @@ -1168,9 +1166,9 @@ cogl_polygon (const CoglTextureVertex *vertices, cogl_push_source (pipeline); - cogl_draw_vertex_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN, - 0, n_vertices, - attributes); + cogl_draw_attributes_array (COGL_VERTICES_MODE_TRIANGLE_FAN, + 0, n_vertices, + attributes); cogl_pop_source (); diff --git a/clutter/cogl/cogl/cogl-types.h b/clutter/cogl/cogl/cogl-types.h index 48b3fc4ff..6b5ff0366 100644 --- a/clutter/cogl/cogl/cogl-types.h +++ b/clutter/cogl/cogl/cogl-types.h @@ -471,6 +471,28 @@ typedef enum { /*< prefix=COGL_ERROR >*/ GQuark _cogl_error_quark (void); +/** + * CoglAttributeType: + * @COGL_ATTRIBUTE_TYPE_BYTE: Data is the same size of a byte + * @COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE: Data is the same size of an + * unsigned byte + * @COGL_ATTRIBUTE_TYPE_SHORT: Data is the same size of a short integer + * @COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT: Data is the same size of + * an unsigned short integer + * @COGL_ATTRIBUTE_TYPE_FLOAT: Data is the same size of a float + * + * Data types for the components of a vertex attribute. + * + * Since: 1.0 + */ +typedef enum { + COGL_ATTRIBUTE_TYPE_BYTE = 0x1400, + COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE = 0x1401, + COGL_ATTRIBUTE_TYPE_SHORT = 0x1402, + COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT = 0x1403, + COGL_ATTRIBUTE_TYPE_FLOAT = 0x1406 +} CoglAttributeType; + /** * CoglIndicesType: * @COGL_INDICES_TYPE_UNSIGNED_BYTE: Your indices are unsigned bytes diff --git a/clutter/cogl/cogl/cogl-vertex-buffer-private.h b/clutter/cogl/cogl/cogl-vertex-buffer-private.h index 0f2127cff..096c00bd9 100644 --- a/clutter/cogl/cogl/cogl-vertex-buffer-private.h +++ b/clutter/cogl/cogl/cogl-vertex-buffer-private.h @@ -93,14 +93,14 @@ typedef struct _CoglVertexBufferAttrib const void *pointer; size_t vbo_offset; } u; - CoglVertexAttributeType type; + CoglAttributeType type; size_t span_bytes; guint16 stride; guint8 n_components; guint8 texture_unit; int attribute_first; - CoglVertexAttribute *attribute; + CoglAttribute *attribute; } CoglVertexBufferAttrib; diff --git a/clutter/cogl/cogl/cogl-vertex-buffer.c b/clutter/cogl/cogl/cogl-vertex-buffer.c index a7788439d..23c10efd2 100644 --- a/clutter/cogl/cogl/cogl-vertex-buffer.c +++ b/clutter/cogl/cogl/cogl-vertex-buffer.c @@ -327,7 +327,7 @@ validate_custom_attribute_name (const char *attribute_name) * of all the submitted attributes * * Note: The CoglVertexBufferAttrib structs are deep copied, except the - * internal CoglVertexAttribute pointer is set to NULL. + * internal CoglAttribute pointer is set to NULL. */ static GList * copy_submitted_attributes_list (CoglVertexBuffer *buffer) @@ -1145,7 +1145,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer) { GList *l; int n_attributes = 0; - CoglVertexAttribute **attributes; + CoglAttribute **attributes; int i; if (!buffer->dirty_attributes) @@ -1164,7 +1164,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer) g_return_if_fail (n_attributes > 0); - attributes = g_alloca (sizeof (CoglVertexAttribute *) * n_attributes + 1); + attributes = g_alloca (sizeof (CoglAttribute *) * n_attributes + 1); i = 0; for (l = buffer->submitted_vbos; l; l = l->next) @@ -1181,12 +1181,12 @@ update_primitive_attributes (CoglVertexBuffer *buffer) if (G_UNLIKELY (!attribute->attribute)) { attribute->attribute = - cogl_vertex_attribute_new (cogl_vbo->array, - attribute->name_without_detail, - attribute->stride, - attribute->u.vbo_offset, - attribute->n_components, - attribute->type); + cogl_attribute_new (cogl_vbo->array, + attribute->name_without_detail, + attribute->stride, + attribute->u.vbo_offset, + attribute->n_components, + attribute->type); } attributes[i++] = attribute->attribute; diff --git a/clutter/cogl/cogl/cogl-vertex-buffer.h b/clutter/cogl/cogl/cogl-vertex-buffer.h index 4f9217c5e..c55d0324c 100644 --- a/clutter/cogl/cogl/cogl-vertex-buffer.h +++ b/clutter/cogl/cogl/cogl-vertex-buffer.h @@ -97,28 +97,6 @@ cogl_vertex_buffer_new (unsigned int n_vertices); unsigned int cogl_vertex_buffer_get_n_vertices (CoglHandle handle); -/** - * CoglAttributeType: - * @COGL_ATTRIBUTE_TYPE_BYTE: Data is the same size of a byte - * @COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE: Data is the same size of an - * unsigned byte - * @COGL_ATTRIBUTE_TYPE_SHORT: Data is the same size of a short integer - * @COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT: Data is the same size of - * an unsigned short integer - * @COGL_ATTRIBUTE_TYPE_FLOAT: Data is the same size of a float - * - * Data types for the components of cogl_vertex_buffer_add() - * - * Since: 1.0 - */ -typedef enum { - COGL_ATTRIBUTE_TYPE_BYTE = GL_BYTE, - COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE = GL_UNSIGNED_BYTE, - COGL_ATTRIBUTE_TYPE_SHORT = GL_SHORT, - COGL_ATTRIBUTE_TYPE_UNSIGNED_SHORT = GL_UNSIGNED_SHORT, - COGL_ATTRIBUTE_TYPE_FLOAT = GL_FLOAT -} CoglAttributeType; - /** * cogl_vertex_buffer_add: * @handle: A vertex buffer handle diff --git a/clutter/cogl/cogl/cogl.c b/clutter/cogl/cogl/cogl.c index d8b0827c9..333ef9a64 100644 --- a/clutter/cogl/cogl/cogl.c +++ b/clutter/cogl/cogl/cogl.c @@ -45,7 +45,7 @@ #include "cogl-bitmap-private.h" #include "cogl-texture-private.h" #include "cogl-texture-driver.h" -#include "cogl-vertex-attribute-private.h" +#include "cogl-attribute-private.h" #include "cogl-framebuffer-private.h" #ifdef HAVE_COGL_GL @@ -739,7 +739,7 @@ cogl_begin_gl (void) _cogl_flush_face_winding (); /* Disable any cached vertex arrays */ - _cogl_vertex_attribute_disable_cached_arrays (); + _cogl_attribute_disable_cached_arrays (); } void diff --git a/clutter/cogl/cogl/cogl.h b/clutter/cogl/cogl/cogl.h index 0e8d1ad08..a55b4ed4e 100644 --- a/clutter/cogl/cogl/cogl.h +++ b/clutter/cogl/cogl/cogl.h @@ -73,7 +73,7 @@ #include #include #include -#include +#include #include #include #endif diff --git a/clutter/cogl/cogl/cogl2-path.c b/clutter/cogl/cogl/cogl2-path.c index 6ab91dd1c..d812290d4 100644 --- a/clutter/cogl/cogl/cogl2-path.c +++ b/clutter/cogl/cogl/cogl2-path.c @@ -42,7 +42,7 @@ #include "cogl-texture-private.h" #include "cogl-primitives-private.h" #include "cogl-private.h" -#include "cogl-vertex-attribute-private.h" +#include "cogl-attribute-private.h" #include "tesselator/tesselator.h" #include @@ -233,7 +233,7 @@ _cogl_path_stroke_nodes (CoglPath *path) { node = &g_array_index (data->path_nodes, CoglPathNode, path_start); - cogl_draw_vertex_attributes (COGL_VERTICES_MODE_LINE_STRIP, + cogl_draw_attributes (COGL_VERTICES_MODE_LINE_STRIP, 0, node->path_size, data->stroke_vbo_attributes[path_num], NULL); @@ -338,7 +338,7 @@ _cogl_path_fill_nodes (CoglPath *path) _cogl_path_build_fill_vbo (path); - _cogl_draw_indexed_vertex_attributes_array + _cogl_draw_indexed_attributes_array (COGL_VERTICES_MODE_TRIANGLES, 0, /* first_vertex */ path->data->fill_vbo_n_indices, @@ -1447,19 +1447,19 @@ _cogl_path_build_fill_vbo (CoglPath *path) g_array_free (tess.vertices, TRUE); data->fill_vbo_attributes[0] = - cogl_vertex_attribute_new (data->fill_vbo, + cogl_attribute_new (data->fill_vbo, "cogl_position_in", sizeof (CoglPathTesselatorVertex), G_STRUCT_OFFSET (CoglPathTesselatorVertex, x), 2, /* n_components */ - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + COGL_ATTRIBUTE_TYPE_FLOAT); data->fill_vbo_attributes[1] = - cogl_vertex_attribute_new (data->fill_vbo, + cogl_attribute_new (data->fill_vbo, "cogl_tex_coord0_in", sizeof (CoglPathTesselatorVertex), G_STRUCT_OFFSET (CoglPathTesselatorVertex, s), 2, /* n_components */ - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + COGL_ATTRIBUTE_TYPE_FLOAT); /* NULL terminator */ data->fill_vbo_attributes[2] = NULL; @@ -1511,7 +1511,7 @@ _cogl_path_build_stroke_vbo (CoglPath *path) _cogl_buffer_unmap_for_fill_or_fallback (COGL_BUFFER (data->stroke_vbo)); - data->stroke_vbo_attributes = g_new (CoglVertexAttribute *, n_attributes); + data->stroke_vbo_attributes = g_new (CoglAttribute *, n_attributes); /* Now we can loop the sub paths again to create the attributes */ for (i = 0, path_start = 0; @@ -1521,12 +1521,12 @@ _cogl_path_build_stroke_vbo (CoglPath *path) node = &g_array_index (data->path_nodes, CoglPathNode, path_start); data->stroke_vbo_attributes[i] = - cogl_vertex_attribute_new (data->stroke_vbo, - "cogl_position_in", - sizeof (floatVec2), - path_start * sizeof (floatVec2), - 2, /* n_components */ - COGL_VERTEX_ATTRIBUTE_TYPE_FLOAT); + cogl_attribute_new (data->stroke_vbo, + "cogl_position_in", + sizeof (floatVec2), + path_start * sizeof (floatVec2), + 2, /* n_components */ + COGL_ATTRIBUTE_TYPE_FLOAT); } data->stroke_vbo_n_attributes = n_attributes; diff --git a/doc/reference/cogl-2.0/cogl-docs.xml.in b/doc/reference/cogl-2.0/cogl-docs.xml.in index 5b991c67a..f0f9a29e9 100644 --- a/doc/reference/cogl-2.0/cogl-docs.xml.in +++ b/doc/reference/cogl-2.0/cogl-docs.xml.in @@ -77,7 +77,7 @@
Describing the layout of GPU Memory - +