Rename CoglVertexArray to CoglAttributeBuffer

This is part of a broader cleanup of some of the experimental Cogl API.
One of the reasons for this particular rename is to switch away from
using the term "Array" which implies a regular, indexable layout which
isn't the case. We also want to have a strongly implied relationship
between CoglAttributes and CoglAttributeBuffers.
This commit is contained in:
Robert Bragg 2011-03-02 15:01:41 +00:00
parent 2da24ab863
commit ce7c06dc03
20 changed files with 235 additions and 229 deletions

View File

@ -77,7 +77,7 @@ cogl_public_h = \
$(srcdir)/cogl-types.h \ $(srcdir)/cogl-types.h \
$(srcdir)/cogl-vertex-buffer.h \ $(srcdir)/cogl-vertex-buffer.h \
$(srcdir)/cogl-index-array.h \ $(srcdir)/cogl-index-array.h \
$(srcdir)/cogl-vertex-array.h \ $(srcdir)/cogl-attribute-buffer.h \
$(srcdir)/cogl-indices.h \ $(srcdir)/cogl-indices.h \
$(srcdir)/cogl-attribute.h \ $(srcdir)/cogl-attribute.h \
$(srcdir)/cogl-primitive.h \ $(srcdir)/cogl-primitive.h \
@ -222,8 +222,8 @@ cogl_sources_c = \
$(srcdir)/cogl-vertex-buffer.c \ $(srcdir)/cogl-vertex-buffer.c \
$(srcdir)/cogl-index-array-private.h \ $(srcdir)/cogl-index-array-private.h \
$(srcdir)/cogl-index-array.c \ $(srcdir)/cogl-index-array.c \
$(srcdir)/cogl-vertex-array-private.h \ $(srcdir)/cogl-attribute-buffer-private.h \
$(srcdir)/cogl-vertex-array.c \ $(srcdir)/cogl-attribute-buffer.c \
$(srcdir)/cogl-indices-private.h \ $(srcdir)/cogl-indices-private.h \
$(srcdir)/cogl-indices.c \ $(srcdir)/cogl-indices.c \
$(srcdir)/cogl-attribute-private.h \ $(srcdir)/cogl-attribute-private.h \

View File

@ -25,15 +25,14 @@
* Robert Bragg <robert@linux.intel.com> * Robert Bragg <robert@linux.intel.com>
*/ */
#ifndef __COGL_VERTEX_ARRAY_PRIVATE_H #ifndef __COGL_ATTRIBUTE_BUFFER_PRIVATE_H
#define __COGL_VERTEX_ARRAY_PRIVATE_H #define __COGL_ATTRIBUTE_BUFFER_PRIVATE_H
#include "cogl-buffer-private.h" #include "cogl-buffer-private.h"
struct _CoglVertexArray struct _CoglAttributeBuffer
{ {
CoglBuffer _parent; CoglBuffer _parent;
}; };
#endif /* __COGL_VERTEX_ARRAY_PRIVATE_H */ #endif /* __COGL_ATTRIBUTE_BUFFER_PRIVATE_H */

View File

@ -30,17 +30,17 @@
#endif #endif
#include "cogl-object-private.h" #include "cogl-object-private.h"
#include "cogl-vertex-array.h" #include "cogl-attribute-buffer.h"
#include "cogl-vertex-array-private.h" #include "cogl-attribute-buffer-private.h"
static void _cogl_vertex_array_free (CoglVertexArray *array); static void _cogl_attribute_buffer_free (CoglAttributeBuffer *array);
COGL_BUFFER_DEFINE (VertexArray, vertex_array); COGL_BUFFER_DEFINE (AttributeBuffer, attribute_buffer);
CoglVertexArray * CoglAttributeBuffer *
cogl_vertex_array_new (gsize bytes, const void *data) cogl_attribute_buffer_new (gsize bytes, const void *data)
{ {
CoglVertexArray *array = g_slice_new (CoglVertexArray); CoglAttributeBuffer *array = g_slice_new (CoglAttributeBuffer);
gboolean use_malloc; gboolean use_malloc;
if (!cogl_features_available (COGL_FEATURE_VBOS)) if (!cogl_features_available (COGL_FEATURE_VBOS))
@ -52,11 +52,11 @@ cogl_vertex_array_new (gsize bytes, const void *data)
_cogl_buffer_initialize (COGL_BUFFER (array), _cogl_buffer_initialize (COGL_BUFFER (array),
bytes, bytes,
use_malloc, use_malloc,
COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
COGL_BUFFER_USAGE_HINT_VERTEX_ARRAY, COGL_BUFFER_USAGE_HINT_ATTRIBUTE_BUFFER,
COGL_BUFFER_UPDATE_HINT_STATIC); COGL_BUFFER_UPDATE_HINT_STATIC);
_cogl_vertex_array_object_new (array); _cogl_attribute_buffer_object_new (array);
if (data) if (data)
cogl_buffer_set_data (COGL_BUFFER (array), cogl_buffer_set_data (COGL_BUFFER (array),
@ -67,11 +67,11 @@ cogl_vertex_array_new (gsize bytes, const void *data)
} }
static void static void
_cogl_vertex_array_free (CoglVertexArray *array) _cogl_attribute_buffer_free (CoglAttributeBuffer *array)
{ {
/* parent's destructor */ /* parent's destructor */
_cogl_buffer_fini (COGL_BUFFER (array)); _cogl_buffer_fini (COGL_BUFFER (array));
g_slice_free (CoglVertexArray, array); g_slice_free (CoglAttributeBuffer, array);
} }

View File

@ -28,26 +28,27 @@
#error "Only <cogl/cogl.h> can be included directly." #error "Only <cogl/cogl.h> can be included directly."
#endif #endif
#ifndef __COGL_VERTEX_ARRAY_H__ #ifndef __COGL_ATTRIBUTE_BUFFER_H__
#define __COGL_VERTEX_ARRAY_H__ #define __COGL_ATTRIBUTE_BUFFER_H__
G_BEGIN_DECLS G_BEGIN_DECLS
/** /**
* SECTION:cogl-vertex-array * SECTION:cogl-attribute-buffer
* @short_description: Functions for creating and manipulating vertex arrays * @short_description: Functions for creating and manipulating attribute
* buffers
* *
* FIXME * FIXME
*/ */
typedef struct _CoglVertexArray CoglVertexArray; typedef struct _CoglAttributeBuffer CoglAttributeBuffer;
/** /**
* cogl_vertex_array_new: * cogl_attribute_buffer_new:
* @bytes: The number of bytes to allocate for vertex attribute data. * @bytes: The number of bytes to allocate for vertex attribute data.
* @data: An optional pointer to vertex data to upload immediately. * @data: An optional pointer to vertex data to upload immediately.
* *
* Declares a new #CoglVertexArray of @size bytes to contain arrays of vertex * Declares a new #CoglAttributeBuffer of @size bytes to contain arrays of vertex
* attribute data. Once declared, data can be set using cogl_buffer_set_data() * attribute data. Once declared, data can be set using cogl_buffer_set_data()
* or by mapping it into the application's address space using cogl_buffer_map(). * or by mapping it into the application's address space using cogl_buffer_map().
* *
@ -57,26 +58,25 @@ typedef struct _CoglVertexArray CoglVertexArray;
* Since: 1.4 * Since: 1.4
* Stability: Unstable * Stability: Unstable
*/ */
CoglVertexArray * CoglAttributeBuffer *
cogl_vertex_array_new (gsize bytes, cogl_attribute_buffer_new (gsize bytes, const void *data);
const void *data);
/** /**
* cogl_is_vertex_array: * cogl_is_attribute_buffer:
* @object: A #CoglObject * @object: A #CoglObject
* *
* Gets whether the given object references a #CoglVertexArray. * Gets whether the given object references a #CoglAttributeBuffer.
* *
* Returns: %TRUE if the handle references a #CoglVertexArray, * Returns: %TRUE if the handle references a #CoglAttributeBuffer,
* %FALSE otherwise * %FALSE otherwise
* *
* Since: 1.4 * Since: 1.4
* Stability: Unstable * Stability: Unstable
*/ */
gboolean gboolean
cogl_is_vertex_array (void *object); cogl_is_attribute_buffer (void *object);
G_END_DECLS G_END_DECLS
#endif /* __COGL_VERTEX_ARRAY_H__ */ #endif /* __COGL_ATTRIBUTE_BUFFER_H__ */

View File

@ -44,7 +44,7 @@ struct _CoglAttribute
{ {
CoglObject _parent; CoglObject _parent;
CoglVertexArray *array; CoglAttributeBuffer *attribute_buffer;
char *name; char *name;
CoglAttributeNameID name_id; CoglAttributeNameID name_id;
gsize stride; gsize stride;

View File

@ -231,7 +231,7 @@ validate_cogl_attribute (const char *name,
} }
CoglAttribute * CoglAttribute *
cogl_attribute_new (CoglVertexArray *array, cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
const char *name, const char *name,
gsize stride, gsize stride,
gsize offset, gsize offset,
@ -241,7 +241,7 @@ cogl_attribute_new (CoglVertexArray *array,
CoglAttribute *attribute = g_slice_new (CoglAttribute); CoglAttribute *attribute = g_slice_new (CoglAttribute);
gboolean status; gboolean status;
attribute->array = cogl_object_ref (array); attribute->attribute_buffer = cogl_object_ref (attribute_buffer);
attribute->name = g_strdup (name); attribute->name = g_strdup (name);
attribute->stride = stride; attribute->stride = stride;
attribute->offset = offset; attribute->offset = offset;
@ -312,27 +312,27 @@ cogl_attribute_set_normalized (CoglAttribute *attribute,
attribute->normalized = normalized; attribute->normalized = normalized;
} }
CoglVertexArray * CoglAttributeBuffer *
cogl_attribute_get_array (CoglAttribute *attribute) cogl_attribute_get_buffer (CoglAttribute *attribute)
{ {
g_return_val_if_fail (cogl_is_attribute (attribute), NULL); g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
return attribute->array; return attribute->attribute_buffer;
} }
void void
cogl_attribute_set_array (CoglAttribute *attribute, cogl_attribute_set_array (CoglAttribute *attribute,
CoglVertexArray *array) CoglAttributeBuffer *attribute_buffer)
{ {
g_return_if_fail (cogl_is_attribute (attribute)); g_return_if_fail (cogl_is_attribute (attribute));
if (G_UNLIKELY (attribute->immutable_ref)) if (G_UNLIKELY (attribute->immutable_ref))
warn_about_midscene_changes (); warn_about_midscene_changes ();
cogl_object_ref (array); cogl_object_ref (attribute_buffer);
cogl_object_unref (attribute->array); cogl_object_unref (attribute->attribute_buffer);
attribute->array = array; attribute->attribute_buffer = attribute_buffer;
} }
CoglAttribute * CoglAttribute *
@ -341,7 +341,7 @@ _cogl_attribute_immutable_ref (CoglAttribute *attribute)
g_return_val_if_fail (cogl_is_attribute (attribute), NULL); g_return_val_if_fail (cogl_is_attribute (attribute), NULL);
attribute->immutable_ref++; attribute->immutable_ref++;
_cogl_buffer_immutable_ref (COGL_BUFFER (attribute->array)); _cogl_buffer_immutable_ref (COGL_BUFFER (attribute->attribute_buffer));
return attribute; return attribute;
} }
@ -352,14 +352,14 @@ _cogl_attribute_immutable_unref (CoglAttribute *attribute)
g_return_if_fail (attribute->immutable_ref > 0); g_return_if_fail (attribute->immutable_ref > 0);
attribute->immutable_ref--; attribute->immutable_ref--;
_cogl_buffer_immutable_unref (COGL_BUFFER (attribute->array)); _cogl_buffer_immutable_unref (COGL_BUFFER (attribute->attribute_buffer));
} }
static void static void
_cogl_attribute_free (CoglAttribute *attribute) _cogl_attribute_free (CoglAttribute *attribute)
{ {
g_free (attribute->name); g_free (attribute->name);
cogl_object_unref (attribute->array); cogl_object_unref (attribute->attribute_buffer);
g_slice_free (CoglAttribute, attribute); g_slice_free (CoglAttribute, attribute);
} }
@ -598,16 +598,16 @@ enable_gl_state (CoglDrawFlags flags,
for (i = 0; attributes[i]; i++) for (i = 0; attributes[i]; i++)
{ {
CoglAttribute *attribute = attributes[i]; CoglAttribute *attribute = attributes[i];
CoglVertexArray *vertex_array; CoglAttributeBuffer *attribute_buffer;
CoglBuffer *buffer; CoglBuffer *buffer;
guint8 *base; guint8 *base;
#ifdef HAVE_COGL_GLES2 #ifdef HAVE_COGL_GLES2
int attrib_location; int attrib_location;
#endif #endif
vertex_array = cogl_attribute_get_array (attribute); attribute_buffer = cogl_attribute_get_buffer (attribute);
buffer = COGL_BUFFER (vertex_array); buffer = COGL_BUFFER (attribute_buffer);
base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY); base = _cogl_buffer_bind (buffer, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER);
switch (attribute->name_id) switch (attribute->name_id)
{ {
@ -875,7 +875,7 @@ get_wire_lines (CoglAttribute *attribute,
int *n_vertices_out, int *n_vertices_out,
CoglIndices *_indices) CoglIndices *_indices)
{ {
CoglVertexArray *vertex_array = cogl_attribute_get_array (attribute); CoglAttributeBuffer *attribute_buffer = cogl_attribute_get_buffer (attribute);
void *vertices; void *vertices;
CoglIndexArray *index_array; CoglIndexArray *index_array;
void *indices; void *indices;
@ -884,7 +884,7 @@ get_wire_lines (CoglAttribute *attribute,
int n_lines; int n_lines;
CoglVertexP3 *out = NULL; CoglVertexP3 *out = NULL;
vertices = cogl_buffer_map (COGL_BUFFER (vertex_array), vertices = cogl_buffer_map (COGL_BUFFER (attribute_buffer),
COGL_BUFFER_ACCESS_READ, 0); COGL_BUFFER_ACCESS_READ, 0);
if (_indices) if (_indices)
{ {
@ -982,7 +982,7 @@ get_wire_lines (CoglAttribute *attribute,
#endif #endif
if (vertices != NULL) if (vertices != NULL)
cogl_buffer_unmap (COGL_BUFFER (vertex_array)); cogl_buffer_unmap (COGL_BUFFER (attribute_buffer));
if (indices != NULL) if (indices != NULL)
cogl_buffer_unmap (COGL_BUFFER (index_array)); cogl_buffer_unmap (COGL_BUFFER (index_array));
@ -1003,7 +1003,7 @@ draw_wireframe (CoglVerticesMode mode,
static CoglPipeline *wire_pipeline; static CoglPipeline *wire_pipeline;
CoglAttribute *wire_attribute[2]; CoglAttribute *wire_attribute[2];
CoglVertexP3 *lines; CoglVertexP3 *lines;
CoglVertexArray *array; CoglAttributeBuffer *attribute_buffer;
for (i = 0; attributes[i]; i++) for (i = 0; attributes[i]; i++)
{ {
@ -1021,16 +1021,17 @@ draw_wireframe (CoglVerticesMode mode,
n_vertices, n_vertices,
&n_line_vertices, &n_line_vertices,
indices); indices);
array = cogl_vertex_array_new (sizeof (CoglVertexP3) * n_line_vertices, attribute_buffer =
lines); cogl_attribute_buffer_new (sizeof (CoglVertexP3) * n_line_vertices,
lines);
wire_attribute[0] = wire_attribute[0] =
cogl_attribute_new (array, "cogl_position_in", cogl_attribute_new (attribute_buffer, "cogl_position_in",
sizeof (CoglVertexP3), sizeof (CoglVertexP3),
0, 0,
3, 3,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
wire_attribute[1] = NULL; wire_attribute[1] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
if (!wire_pipeline) if (!wire_pipeline)
{ {

View File

@ -31,7 +31,7 @@
#ifndef __COGL_ATTRIBUTE_H__ #ifndef __COGL_ATTRIBUTE_H__
#define __COGL_ATTRIBUTE_H__ #define __COGL_ATTRIBUTE_H__
#include <cogl/cogl-vertex-array.h> #include <cogl/cogl-attribute-buffer.h>
#include <cogl/cogl-indices.h> #include <cogl/cogl-indices.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -48,13 +48,14 @@ typedef struct _CoglAttribute CoglAttribute;
/** /**
* cogl_attribute_new: * cogl_attribute_new:
* @array: The #CoglVertexArray containing the actual attribute data * @attribute_buffer: The #CoglAttributeBuffer containing the actual
* attribute data
* @name: The name of the attribute (used to reference it from GLSL) * @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 * @stride: The number of bytes to jump to get to the next attribute
* value for the next vertex. (Usually * value for the next vertex. (Usually
* <pre>sizeof (MyVertex)</pre>) * <pre>sizeof (MyVertex)</pre>)
* @offset: The byte offset from the start of @array for the first * @offset: The byte offset from the start of @attribute_buffer for
* attribute value. (Usually * the first attribute value. (Usually
* <pre>offsetof (MyVertex, component0)</pre> * <pre>offsetof (MyVertex, component0)</pre>
* @components: The number of components (e.g. 4 for an rgba color or * @components: The number of components (e.g. 4 for an rgba color or
* 3 for and (x,y,z) position) * 3 for and (x,y,z) position)
@ -131,7 +132,7 @@ typedef struct _CoglAttribute CoglAttribute;
/* XXX: look for a precedent to see if the stride/offset args should /* XXX: look for a precedent to see if the stride/offset args should
* have a different order. */ * have a different order. */
CoglAttribute * CoglAttribute *
cogl_attribute_new (CoglVertexArray *array, cogl_attribute_new (CoglAttributeBuffer *attribute_buffer,
const char *name, const char *name,
gsize stride, gsize stride,
gsize offset, gsize offset,

View File

@ -64,14 +64,14 @@ typedef enum _CoglBufferFlags
typedef enum { typedef enum {
COGL_BUFFER_USAGE_HINT_TEXTURE, COGL_BUFFER_USAGE_HINT_TEXTURE,
COGL_BUFFER_USAGE_HINT_VERTEX_ARRAY, COGL_BUFFER_USAGE_HINT_ATTRIBUTE_BUFFER,
COGL_BUFFER_USAGE_HINT_INDEX_ARRAY COGL_BUFFER_USAGE_HINT_INDEX_ARRAY
} CoglBufferUsageHint; } CoglBufferUsageHint;
typedef enum { typedef enum {
COGL_BUFFER_BIND_TARGET_PIXEL_PACK, COGL_BUFFER_BIND_TARGET_PIXEL_PACK,
COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK, COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK,
COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY, COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER,
COGL_BUFFER_BIND_TARGET_INDEX_ARRAY, COGL_BUFFER_BIND_TARGET_INDEX_ARRAY,
COGL_BUFFER_BIND_TARGET_COUNT COGL_BUFFER_BIND_TARGET_COUNT

View File

@ -128,7 +128,7 @@ convert_bind_target_to_gl_target (CoglBufferBindTarget target)
return GL_PIXEL_PACK_BUFFER; return GL_PIXEL_PACK_BUFFER;
case COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK: case COGL_BUFFER_BIND_TARGET_PIXEL_UNPACK:
return GL_PIXEL_UNPACK_BUFFER; return GL_PIXEL_UNPACK_BUFFER;
case COGL_BUFFER_BIND_TARGET_VERTEX_ARRAY: case COGL_BUFFER_BIND_TARGET_ATTRIBUTE_BUFFER:
return GL_ARRAY_BUFFER; return GL_ARRAY_BUFFER;
case COGL_BUFFER_BIND_TARGET_INDEX_ARRAY: case COGL_BUFFER_BIND_TARGET_INDEX_ARRAY:
return GL_ELEMENT_ARRAY_BUFFER; return GL_ELEMENT_ARRAY_BUFFER;

View File

@ -98,13 +98,14 @@ cogl_index_array_allocate (CoglIndexArray *indices,
* *
* XXX: The double plurel form that "Indices" "Array" implies could be * XXX: The double plurel form that "Indices" "Array" implies could be
* a bit confusing. Also to be a bit more consistent with * a bit confusing. Also to be a bit more consistent with
* CoglVertexArray vs CoglAttribute it might be best to rename so * CoglAttributeBuffer vs CoglAttribute it might be best to rename so
* we have CoglIndexArray vs CoglIndices? maybe even * we have CoglIndexArray vs CoglIndices? maybe even
* CoglIndexRange :-/ ? * CoglIndexRange :-/ ?
* *
* CoglBuffer * CoglBuffer
* CoglVertexArray (buffer sub-class) * CoglAttributeBuffer (buffer sub-class)
* CoglPrimitive (defines meta data for sub-region of array) * CoglAttribute (defines meta data for sub-region of buffer)
* CoglPrimitive (object encapsulating a set of attributes)
* CoglPixelArray (buffer sub-class) * CoglPixelArray (buffer sub-class)
* CoglIndexArray (buffer sub-class) * CoglIndexArray (buffer sub-class)
* CoglIndices (defines meta data for sub-region of array) * CoglIndices (defines meta data for sub-region of array)

View File

@ -95,7 +95,7 @@ typedef struct _CoglJournalFlushState
{ {
CoglJournal *journal; CoglJournal *journal;
CoglVertexArray *vertex_array; CoglAttributeBuffer *attribute_buffer;
GArray *attributes; GArray *attributes;
int current_attribute; int current_attribute;
@ -518,7 +518,7 @@ _cogl_journal_flush_texcoord_vbo_offsets_and_entries (
/* XXX: it may be worth having some form of static initializer for /* XXX: it may be worth having some form of static initializer for
* attributes... */ * attributes... */
*attribute_entry = *attribute_entry =
cogl_attribute_new (state->vertex_array, cogl_attribute_new (state->attribute_buffer,
name, name,
state->stride, state->stride,
state->array_offset + state->array_offset +
@ -593,7 +593,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
g_array_set_size (state->attributes, 2); g_array_set_size (state->attributes, 2);
attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 0); attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 0);
*attribute_entry = cogl_attribute_new (state->vertex_array, *attribute_entry = cogl_attribute_new (state->attribute_buffer,
"cogl_position_in", "cogl_position_in",
stride, stride,
state->array_offset, state->array_offset,
@ -602,7 +602,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 1); attribute_entry = &g_array_index (state->attributes, CoglAttribute *, 1);
*attribute_entry = *attribute_entry =
cogl_attribute_new (state->vertex_array, cogl_attribute_new (state->attribute_buffer,
"cogl_color_in", "cogl_color_in",
stride, stride,
state->array_offset + (POS_STRIDE * 4), state->array_offset + (POS_STRIDE * 4),
@ -614,9 +614,9 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
#endif #endif
/* We only create new Attributes when the stride within the /* We only create new Attributes when the stride within the
* VertexArray changes. (due to a change in the number of pipeline * AttributeBuffer changes. (due to a change in the number of pipeline
* layers) While the stride remains constant we walk forward through * layers) While the stride remains constant we walk forward through
* the above VertexArray using a vertex offset passed to * the above AttributeBuffer using a vertex offset passed to
* cogl_draw_attributes * cogl_draw_attributes
*/ */
state->current_vertex = 0; state->current_vertex = 0;
@ -628,15 +628,15 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
/* Mapping a buffer for read is probably a really bad thing to /* Mapping a buffer for read is probably a really bad thing to
do but this will only happen during debugging so it probably do but this will only happen during debugging so it probably
doesn't matter */ doesn't matter */
verts = ((guint8 *) cogl_buffer_map (COGL_BUFFER (state->vertex_array), verts = ((guint8 *)cogl_buffer_map (COGL_BUFFER (state->attribute_buffer),
COGL_BUFFER_ACCESS_READ, 0) + COGL_BUFFER_ACCESS_READ, 0) +
state->array_offset); state->array_offset);
_cogl_journal_dump_quad_batch (verts, _cogl_journal_dump_quad_batch (verts,
batch_start->n_layers, batch_start->n_layers,
batch_len); batch_len);
cogl_buffer_unmap (COGL_BUFFER (state->vertex_array)); cogl_buffer_unmap (COGL_BUFFER (state->attribute_buffer));
} }
batch_and_call (batch_start, batch_and_call (batch_start,
@ -1092,13 +1092,13 @@ compare_entry_clip_stacks (CoglJournalEntry *entry0, CoglJournalEntry *entry1)
return entry0->clip_stack == entry1->clip_stack; return entry0->clip_stack == entry1->clip_stack;
} }
static CoglVertexArray * static CoglAttributeBuffer *
upload_vertices (const CoglJournalEntry *entries, upload_vertices (const CoglJournalEntry *entries,
int n_entries, int n_entries,
size_t needed_vbo_len, size_t needed_vbo_len,
GArray *vertices) GArray *vertices)
{ {
CoglVertexArray *array; CoglAttributeBuffer *attribute_buffer;
CoglBuffer *buffer; CoglBuffer *buffer;
const float *vin; const float *vin;
float *vout; float *vout;
@ -1107,8 +1107,8 @@ upload_vertices (const CoglJournalEntry *entries,
g_assert (needed_vbo_len); g_assert (needed_vbo_len);
array = cogl_vertex_array_new (needed_vbo_len * 4, NULL); attribute_buffer = cogl_attribute_buffer_new (needed_vbo_len * 4, NULL);
buffer = COGL_BUFFER (array); buffer = COGL_BUFFER (attribute_buffer);
cogl_buffer_set_update_hint (buffer, COGL_BUFFER_UPDATE_HINT_STATIC); cogl_buffer_set_update_hint (buffer, COGL_BUFFER_UPDATE_HINT_STATIC);
vout = _cogl_buffer_map_for_fill_or_fallback (buffer); vout = _cogl_buffer_map_for_fill_or_fallback (buffer);
@ -1182,7 +1182,7 @@ upload_vertices (const CoglJournalEntry *entries,
_cogl_buffer_unmap_for_fill_or_fallback (buffer); _cogl_buffer_unmap_for_fill_or_fallback (buffer);
return array; return attribute_buffer;
} }
void void
@ -1340,7 +1340,7 @@ _cogl_journal_flush (CoglJournal *journal,
/* We upload the vertices after the clip stack pass in case it /* We upload the vertices after the clip stack pass in case it
modifies the entries */ modifies the entries */
state.vertex_array = upload_vertices (&g_array_index (journal->entries, state.attribute_buffer = upload_vertices (&g_array_index (journal->entries,
CoglJournalEntry, 0), CoglJournalEntry, 0),
journal->entries->len, journal->entries->len,
journal->needed_vbo_len, journal->needed_vbo_len,
@ -1380,7 +1380,7 @@ _cogl_journal_flush (CoglJournal *journal,
cogl_object_unref (g_array_index (state.attributes, CoglAttribute *, i)); cogl_object_unref (g_array_index (state.attributes, CoglAttribute *, i));
g_array_set_size (state.attributes, 0); g_array_set_size (state.attributes, 0);
cogl_object_unref (state.vertex_array); cogl_object_unref (state.attribute_buffer);
_cogl_journal_discard (journal); _cogl_journal_discard (journal);

View File

@ -79,14 +79,14 @@ struct _CoglPathData
floatVec2 path_nodes_min; floatVec2 path_nodes_min;
floatVec2 path_nodes_max; floatVec2 path_nodes_max;
CoglVertexArray *fill_vbo; CoglAttributeBuffer *fill_attribute_buffer;
CoglIndices *fill_vbo_indices; CoglIndices *fill_vbo_indices;
unsigned int fill_vbo_n_indices; unsigned int fill_vbo_n_indices;
CoglAttribute *fill_vbo_attributes[COGL_PATH_N_ATTRIBUTES + 1]; CoglAttribute *fill_attributes[COGL_PATH_N_ATTRIBUTES + 1];
CoglVertexArray *stroke_vbo; CoglAttributeBuffer *stroke_attribute_buffer;
CoglAttribute **stroke_vbo_attributes; CoglAttribute **stroke_attributes;
unsigned int stroke_vbo_n_attributes; unsigned int stroke_n_attributes;
/* This is used as an optimisation for when the path contains a /* This is used as an optimisation for when the path contains a
single contour specified using cogl2_path_rectangle. Cogl is more single contour specified using cogl2_path_rectangle. Cogl is more

View File

@ -29,7 +29,7 @@
#define __COGL_PRIMITIVE_PRIVATE_H #define __COGL_PRIMITIVE_PRIVATE_H
#include "cogl-object-private.h" #include "cogl-object-private.h"
#include "cogl-vertex-array-private.h" #include "cogl-attribute-buffer-private.h"
struct _CoglPrimitive struct _CoglPrimitive
{ {

View File

@ -124,11 +124,11 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
int n_vertices, int n_vertices,
const CoglVertexP2 *data) const CoglVertexP2 *data)
{ {
CoglVertexArray *array = CoglAttributeBuffer *attribute_buffer =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2), data); cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2), data);
CoglAttribute *attributes[2]; CoglAttribute *attributes[2];
attributes[0] = cogl_attribute_new (array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglVertexP2), sizeof (CoglVertexP2),
offsetof (CoglVertexP2, x), offsetof (CoglVertexP2, x),
@ -136,7 +136,7 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = NULL; attributes[1] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices, return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes); attributes);
@ -147,11 +147,11 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
int n_vertices, int n_vertices,
const CoglVertexP3 *data) const CoglVertexP3 *data)
{ {
CoglVertexArray *array = CoglAttributeBuffer *attribute_buffer =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3), data); cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3), data);
CoglAttribute *attributes[2]; CoglAttribute *attributes[2];
attributes[0] = cogl_attribute_new (array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglVertexP3), sizeof (CoglVertexP3),
offsetof (CoglVertexP3, x), offsetof (CoglVertexP3, x),
@ -159,7 +159,7 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = NULL; attributes[1] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices, return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes); attributes);
@ -170,17 +170,17 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
int n_vertices, int n_vertices,
const CoglVertexP2C4 *data) const CoglVertexP2C4 *data)
{ {
CoglVertexArray *array = CoglAttributeBuffer *attribute_buffer =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2C4), data); cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2C4), data);
CoglAttribute *attributes[3]; CoglAttribute *attributes[3];
attributes[0] = cogl_attribute_new (array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglVertexP2C4), sizeof (CoglVertexP2C4),
offsetof (CoglVertexP2C4, x), offsetof (CoglVertexP2C4, x),
2, 2,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array, attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_color_in", "cogl_color_in",
sizeof (CoglVertexP2C4), sizeof (CoglVertexP2C4),
offsetof (CoglVertexP2C4, r), offsetof (CoglVertexP2C4, r),
@ -188,7 +188,7 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
attributes[2] = NULL; attributes[2] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices, return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes); attributes);
@ -199,17 +199,17 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
int n_vertices, int n_vertices,
const CoglVertexP3C4 *data) const CoglVertexP3C4 *data)
{ {
CoglVertexArray *array = CoglAttributeBuffer *attribute_buffer =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3C4), data); cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3C4), data);
CoglAttribute *attributes[3]; CoglAttribute *attributes[3];
attributes[0] = cogl_attribute_new (array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglVertexP3C4), sizeof (CoglVertexP3C4),
offsetof (CoglVertexP3C4, x), offsetof (CoglVertexP3C4, x),
3, 3,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array, attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_color_in", "cogl_color_in",
sizeof (CoglVertexP3C4), sizeof (CoglVertexP3C4),
offsetof (CoglVertexP3C4, r), offsetof (CoglVertexP3C4, r),
@ -217,7 +217,7 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
attributes[2] = NULL; attributes[2] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices, return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes); attributes);
@ -228,17 +228,17 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
int n_vertices, int n_vertices,
const CoglVertexP2T2 *data) const CoglVertexP2T2 *data)
{ {
CoglVertexArray *array = CoglAttributeBuffer *attribute_buffer =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2), data); cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2T2), data);
CoglAttribute *attributes[3]; CoglAttribute *attributes[3];
attributes[0] = cogl_attribute_new (array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglVertexP2T2), sizeof (CoglVertexP2T2),
offsetof (CoglVertexP2T2, x), offsetof (CoglVertexP2T2, x),
2, 2,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array, attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in", "cogl_tex_coord0_in",
sizeof (CoglVertexP2T2), sizeof (CoglVertexP2T2),
offsetof (CoglVertexP2T2, s), offsetof (CoglVertexP2T2, s),
@ -246,7 +246,7 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[2] = NULL; attributes[2] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices, return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes); attributes);
@ -257,17 +257,17 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
int n_vertices, int n_vertices,
const CoglVertexP3T2 *data) const CoglVertexP3T2 *data)
{ {
CoglVertexArray *array = CoglAttributeBuffer *attribute_buffer =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2), data); cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3T2), data);
CoglAttribute *attributes[3]; CoglAttribute *attributes[3];
attributes[0] = cogl_attribute_new (array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglVertexP3T2), sizeof (CoglVertexP3T2),
offsetof (CoglVertexP3T2, x), offsetof (CoglVertexP3T2, x),
3, 3,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array, attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in", "cogl_tex_coord0_in",
sizeof (CoglVertexP3T2), sizeof (CoglVertexP3T2),
offsetof (CoglVertexP3T2, s), offsetof (CoglVertexP3T2, s),
@ -275,7 +275,7 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[2] = NULL; attributes[2] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices, return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes); attributes);
@ -286,23 +286,23 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
int n_vertices, int n_vertices,
const CoglVertexP2T2C4 *data) const CoglVertexP2T2C4 *data)
{ {
CoglVertexArray *array = CoglAttributeBuffer *attribute_buffer =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP2T2C4), data); cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP2T2C4), data);
CoglAttribute *attributes[4]; CoglAttribute *attributes[4];
attributes[0] = cogl_attribute_new (array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglVertexP2T2C4), sizeof (CoglVertexP2T2C4),
offsetof (CoglVertexP2T2C4, x), offsetof (CoglVertexP2T2C4, x),
2, 2,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array, attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in", "cogl_tex_coord0_in",
sizeof (CoglVertexP2T2C4), sizeof (CoglVertexP2T2C4),
offsetof (CoglVertexP2T2C4, s), offsetof (CoglVertexP2T2C4, s),
2, 2,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[2] = cogl_attribute_new (array, attributes[2] = cogl_attribute_new (attribute_buffer,
"cogl_color_in", "cogl_color_in",
sizeof (CoglVertexP2T2C4), sizeof (CoglVertexP2T2C4),
offsetof (CoglVertexP2T2C4, r), offsetof (CoglVertexP2T2C4, r),
@ -310,7 +310,7 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
attributes[3] = NULL; attributes[3] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices, return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes); attributes);
@ -321,23 +321,23 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode,
int n_vertices, int n_vertices,
const CoglVertexP3T2C4 *data) const CoglVertexP3T2C4 *data)
{ {
CoglVertexArray *array = CoglAttributeBuffer *attribute_buffer =
cogl_vertex_array_new (n_vertices * sizeof (CoglVertexP3T2C4), data); cogl_attribute_buffer_new (n_vertices * sizeof (CoglVertexP3T2C4), data);
CoglAttribute *attributes[4]; CoglAttribute *attributes[4];
attributes[0] = cogl_attribute_new (array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglVertexP3T2C4), sizeof (CoglVertexP3T2C4),
offsetof (CoglVertexP3T2C4, x), offsetof (CoglVertexP3T2C4, x),
3, 3,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[1] = cogl_attribute_new (array, attributes[1] = cogl_attribute_new (attribute_buffer,
"cogl_tex_coord0_in", "cogl_tex_coord0_in",
sizeof (CoglVertexP3T2C4), sizeof (CoglVertexP3T2C4),
offsetof (CoglVertexP3T2C4, s), offsetof (CoglVertexP3T2C4, s),
2, 2,
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
attributes[2] = cogl_attribute_new (array, attributes[2] = cogl_attribute_new (attribute_buffer,
"cogl_color_in", "cogl_color_in",
sizeof (CoglVertexP3T2C4), sizeof (CoglVertexP3T2C4),
offsetof (CoglVertexP3T2C4, r), offsetof (CoglVertexP3T2C4, r),
@ -345,7 +345,7 @@ cogl_primitive_new_p3t2c4 (CoglVerticesMode mode,
COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE); COGL_ATTRIBUTE_TYPE_UNSIGNED_BYTE);
attributes[3] = NULL; attributes[3] = NULL;
cogl_object_unref (array); cogl_object_unref (attribute_buffer);
return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices, return _cogl_primitive_new_with_attributes_array_unref (mode, n_vertices,
attributes); attributes);

View File

@ -245,7 +245,7 @@ cogl_primitive_new_with_attributes_array (CoglVerticesMode mode,
* *
* Provides a convenient way to describe a primitive, such as a single * Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the * triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position * necessary #CoglAttributeBuffer storage, describe the position
* attribute with a #CoglAttribute and upload your data. * attribute with a #CoglAttribute and upload your data.
* *
* For example to draw a convex polygon you can do: * For example to draw a convex polygon you can do:
@ -289,7 +289,7 @@ cogl_primitive_new_p2 (CoglVerticesMode mode,
* *
* Provides a convenient way to describe a primitive, such as a single * Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the * triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position * necessary #CoglAttributeBuffer storage, describe the position
* attribute with a #CoglAttribute and upload your data. * attribute with a #CoglAttribute and upload your data.
* *
* For example to draw a convex polygon you can do: * For example to draw a convex polygon you can do:
@ -333,7 +333,7 @@ cogl_primitive_new_p3 (CoglVerticesMode mode,
* *
* Provides a convenient way to describe a primitive, such as a single * Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the * triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position * necessary #CoglAttributeBuffer storage, describe the position
* and color attributes with #CoglAttribute<!-- -->s and upload * and color attributes with #CoglAttribute<!-- -->s and upload
* your data. * your data.
* *
@ -379,7 +379,7 @@ cogl_primitive_new_p2c4 (CoglVerticesMode mode,
* *
* Provides a convenient way to describe a primitive, such as a single * Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the * triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position * necessary #CoglAttributeBuffer storage, describe the position
* and color attributes with #CoglAttribute<!-- -->s and upload * and color attributes with #CoglAttribute<!-- -->s and upload
* your data. * your data.
* *
@ -425,7 +425,7 @@ cogl_primitive_new_p3c4 (CoglVerticesMode mode,
* *
* Provides a convenient way to describe a primitive, such as a single * Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the * triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position and * necessary #CoglAttributeBuffer storage, describe the position and
* texture coordinate attributes with #CoglAttribute<!-- -->s and * texture coordinate attributes with #CoglAttribute<!-- -->s and
* upload your data. * upload your data.
* *
@ -471,7 +471,7 @@ cogl_primitive_new_p2t2 (CoglVerticesMode mode,
* *
* Provides a convenient way to describe a primitive, such as a single * Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the * triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position and * necessary #CoglAttributeBuffer storage, describe the position and
* texture coordinate attributes with #CoglAttribute<!-- -->s and * texture coordinate attributes with #CoglAttribute<!-- -->s and
* upload your data. * upload your data.
* *
@ -517,7 +517,7 @@ cogl_primitive_new_p3t2 (CoglVerticesMode mode,
* *
* Provides a convenient way to describe a primitive, such as a single * Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the * triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position, texture * necessary #CoglAttributeBuffer storage, describe the position, texture
* coordinate and color attributes with #CoglAttribute<!-- -->s and * coordinate and color attributes with #CoglAttribute<!-- -->s and
* upload your data. * upload your data.
* *
@ -563,7 +563,7 @@ cogl_primitive_new_p2t2c4 (CoglVerticesMode mode,
* *
* Provides a convenient way to describe a primitive, such as a single * Provides a convenient way to describe a primitive, such as a single
* triangle strip or a triangle fan, that will internally allocate the * triangle strip or a triangle fan, that will internally allocate the
* necessary #CoglVertexArray storage, describe the position, texture * necessary #CoglAttributeBuffer storage, describe the position, texture
* coordinate and color attributes with #CoglAttribute<!-- -->s and * coordinate and color attributes with #CoglAttribute<!-- -->s and
* upload your data. * upload your data.
* *

View File

@ -933,11 +933,11 @@ _cogl_rectangle_immediate (float x_1,
x_2, y_1, x_2, y_1,
x_2, y_2 x_2, y_2
}; };
CoglVertexArray *vertex_array; CoglAttributeBuffer *attribute_buffer;
CoglAttribute *attributes[2]; CoglAttribute *attributes[2];
vertex_array = cogl_vertex_array_new (sizeof (vertices), vertices); attribute_buffer = cogl_attribute_buffer_new (sizeof (vertices), vertices);
attributes[0] = cogl_attribute_new (vertex_array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (float) * 2, /* stride */ sizeof (float) * 2, /* stride */
0, /* offset */ 0, /* offset */
@ -955,7 +955,7 @@ _cogl_rectangle_immediate (float x_1,
cogl_object_unref (attributes[0]); cogl_object_unref (attributes[0]);
cogl_object_unref (vertex_array); cogl_object_unref (attribute_buffer);
} }
typedef struct _AppendTexCoordsState typedef struct _AppendTexCoordsState
@ -1050,7 +1050,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
int i; int i;
unsigned int stride; unsigned int stride;
gsize stride_bytes; gsize stride_bytes;
CoglVertexArray *vertex_array; CoglAttributeBuffer *attribute_buffer;
float *v; float *v;
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
@ -1080,9 +1080,10 @@ cogl_polygon (const CoglTextureVertex *vertices,
* but still support any number of vertices */ * but still support any number of vertices */
g_array_set_size (ctx->polygon_vertices, n_vertices * stride); g_array_set_size (ctx->polygon_vertices, n_vertices * stride);
vertex_array = cogl_vertex_array_new (n_vertices * stride_bytes, NULL); attribute_buffer =
cogl_attribute_buffer_new (n_vertices * stride_bytes, NULL);
attributes[0] = cogl_attribute_new (vertex_array, attributes[0] = cogl_attribute_new (attribute_buffer,
"cogl_position_in", "cogl_position_in",
stride_bytes, stride_bytes,
0, 0,
@ -1104,7 +1105,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
char *name = i < 8 ? (char *)names[i] : char *name = i < 8 ? (char *)names[i] :
g_strdup_printf ("cogl_tex_coord%d_in", i); g_strdup_printf ("cogl_tex_coord%d_in", i);
attributes[i + 1] = cogl_attribute_new (vertex_array, attributes[i + 1] = cogl_attribute_new (attribute_buffer,
name, name,
stride_bytes, stride_bytes,
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
@ -1116,7 +1117,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
if (use_color) if (use_color)
{ {
attributes[n_attributes - 1] = attributes[n_attributes - 1] =
cogl_attribute_new (vertex_array, cogl_attribute_new (attribute_buffer,
"cogl_color_in", "cogl_color_in",
stride_bytes, stride_bytes,
/* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */ /* NB: [X,Y,Z,TX,TY...,R,G,B,A,...] */
@ -1159,7 +1160,7 @@ cogl_polygon (const CoglTextureVertex *vertices,
} }
v = (float *)ctx->polygon_vertices->data; v = (float *)ctx->polygon_vertices->data;
cogl_buffer_set_data (COGL_BUFFER (vertex_array), cogl_buffer_set_data (COGL_BUFFER (attribute_buffer),
0, 0,
v, v,
ctx->polygon_vertices->len * sizeof (float)); ctx->polygon_vertices->len * sizeof (float));

View File

@ -124,8 +124,8 @@ typedef struct _CoglVertexBufferVBO
{ {
CoglVertexBufferVBOFlags flags; CoglVertexBufferVBOFlags flags;
CoglVertexArray *array; CoglAttributeBuffer *attribute_buffer;
size_t array_bytes; size_t buffer_bytes;
GList *attributes; GList *attributes;
} CoglVertexBufferVBO; } CoglVertexBufferVBO;

View File

@ -833,8 +833,8 @@ filter_strided_attribute (CoglVertexBufferAttrib *attribute,
new_cogl_vbo->attributes = new_cogl_vbo->attributes =
g_list_prepend (new_cogl_vbo->attributes, attribute); g_list_prepend (new_cogl_vbo->attributes, attribute);
/* Any one of the interleved attributes will have the same span_bytes */ /* Any one of the interleved attributes will have the same span_bytes */
new_cogl_vbo->array = NULL; new_cogl_vbo->attribute_buffer = NULL;
new_cogl_vbo->array_bytes = attribute->span_bytes; new_cogl_vbo->buffer_bytes = attribute->span_bytes;
new_cogl_vbo->flags = COGL_VERTEX_BUFFER_VBO_FLAG_STRIDED; new_cogl_vbo->flags = COGL_VERTEX_BUFFER_VBO_FLAG_STRIDED;
if (attribute->flags & COGL_VERTEX_BUFFER_ATTRIB_FLAG_INFREQUENT_RESUBMIT) if (attribute->flags & COGL_VERTEX_BUFFER_ATTRIB_FLAG_INFREQUENT_RESUBMIT)
@ -942,7 +942,7 @@ cogl_vertex_buffer_vbo_free (CoglVertexBufferVBO *cogl_vbo)
g_list_free (cogl_vbo->attributes); g_list_free (cogl_vbo->attributes);
if (cogl_vbo->flags & COGL_VERTEX_BUFFER_VBO_FLAG_SUBMITTED) if (cogl_vbo->flags & COGL_VERTEX_BUFFER_VBO_FLAG_SUBMITTED)
cogl_object_unref (cogl_vbo->array); cogl_object_unref (cogl_vbo->attribute_buffer);
g_slice_free (CoglVertexBufferVBO, cogl_vbo); g_slice_free (CoglVertexBufferVBO, cogl_vbo);
} }
@ -988,7 +988,7 @@ upload_multipack_vbo_via_map_buffer (CoglVertexBufferVBO *cogl_vbo)
_COGL_GET_CONTEXT (ctx, FALSE); _COGL_GET_CONTEXT (ctx, FALSE);
buf = cogl_buffer_map (COGL_BUFFER (cogl_vbo->array), buf = cogl_buffer_map (COGL_BUFFER (cogl_vbo->attribute_buffer),
COGL_BUFFER_ACCESS_WRITE, COGL_BUFFER_ACCESS_WRITE,
COGL_BUFFER_MAP_HINT_DISCARD); COGL_BUFFER_MAP_HINT_DISCARD);
if (!buf) if (!buf)
@ -1009,7 +1009,7 @@ upload_multipack_vbo_via_map_buffer (CoglVertexBufferVBO *cogl_vbo)
offset += attribute_size; offset += attribute_size;
} }
cogl_buffer_unmap (COGL_BUFFER (cogl_vbo->array)); cogl_buffer_unmap (COGL_BUFFER (cogl_vbo->attribute_buffer));
return TRUE; return TRUE;
} }
@ -1028,7 +1028,7 @@ upload_multipack_vbo_via_buffer_sub_data (CoglVertexBufferVBO *cogl_vbo)
PAD_FOR_ALIGNMENT (offset, type_size); PAD_FOR_ALIGNMENT (offset, type_size);
cogl_buffer_set_data (COGL_BUFFER (cogl_vbo->array), cogl_buffer_set_data (COGL_BUFFER (cogl_vbo->attribute_buffer),
offset, offset,
attribute->u.pointer, attribute->u.pointer,
attribute_size); attribute_size);
@ -1050,15 +1050,15 @@ upload_attributes (CoglVertexBufferVBO *cogl_vbo)
usage = COGL_BUFFER_UPDATE_HINT_DYNAMIC; usage = COGL_BUFFER_UPDATE_HINT_DYNAMIC;
else else
usage = COGL_BUFFER_UPDATE_HINT_STATIC; usage = COGL_BUFFER_UPDATE_HINT_STATIC;
cogl_buffer_set_update_hint (COGL_BUFFER (cogl_vbo->array), usage); cogl_buffer_set_update_hint (COGL_BUFFER (cogl_vbo->attribute_buffer), usage);
if (cogl_vbo->flags & COGL_VERTEX_BUFFER_VBO_FLAG_STRIDED) if (cogl_vbo->flags & COGL_VERTEX_BUFFER_VBO_FLAG_STRIDED)
{ {
const void *pointer = prep_strided_vbo_for_upload (cogl_vbo); const void *pointer = prep_strided_vbo_for_upload (cogl_vbo);
cogl_buffer_set_data (COGL_BUFFER (cogl_vbo->array), cogl_buffer_set_data (COGL_BUFFER (cogl_vbo->attribute_buffer),
0, /* offset */ 0, /* offset */
pointer, pointer,
cogl_vbo->array_bytes); cogl_vbo->buffer_bytes);
} }
else /* MULTIPACK */ else /* MULTIPACK */
{ {
@ -1107,10 +1107,11 @@ cogl_vertex_buffer_vbo_resolve (CoglVertexBuffer *buffer,
/* See if we can re-use this now empty VBO: */ /* See if we can re-use this now empty VBO: */
if (!found_target_vbo if (!found_target_vbo
&& conflict_vbo->array_bytes == new_cogl_vbo->array_bytes) && conflict_vbo->buffer_bytes == new_cogl_vbo->buffer_bytes)
{ {
found_target_vbo = TRUE; found_target_vbo = TRUE;
new_cogl_vbo->array = cogl_object_ref (conflict_vbo->array); new_cogl_vbo->attribute_buffer =
cogl_object_ref (conflict_vbo->attribute_buffer);
cogl_vertex_buffer_vbo_free (conflict_vbo); cogl_vertex_buffer_vbo_free (conflict_vbo);
upload_attributes (new_cogl_vbo); upload_attributes (new_cogl_vbo);
@ -1132,8 +1133,8 @@ cogl_vertex_buffer_vbo_resolve (CoglVertexBuffer *buffer,
if (!found_target_vbo) if (!found_target_vbo)
{ {
new_cogl_vbo->array = cogl_vertex_array_new (new_cogl_vbo->array_bytes, new_cogl_vbo->attribute_buffer =
NULL); cogl_attribute_buffer_new (new_cogl_vbo->buffer_bytes, NULL);
upload_attributes (new_cogl_vbo); upload_attributes (new_cogl_vbo);
*final_vbos = g_list_prepend (*final_vbos, new_cogl_vbo); *final_vbos = g_list_prepend (*final_vbos, new_cogl_vbo);
@ -1181,7 +1182,7 @@ update_primitive_attributes (CoglVertexBuffer *buffer)
if (G_UNLIKELY (!attribute->attribute)) if (G_UNLIKELY (!attribute->attribute))
{ {
attribute->attribute = attribute->attribute =
cogl_attribute_new (cogl_vbo->array, cogl_attribute_new (cogl_vbo->attribute_buffer,
attribute->name_without_detail, attribute->name_without_detail,
attribute->stride, attribute->stride,
attribute->u.vbo_offset, attribute->u.vbo_offset,
@ -1346,8 +1347,8 @@ cogl_vertex_buffer_submit_real (CoglVertexBuffer *buffer)
*/ */
new_multipack_vbo = g_slice_alloc (sizeof (CoglVertexBufferVBO)); new_multipack_vbo = g_slice_alloc (sizeof (CoglVertexBufferVBO));
new_multipack_vbo->array = NULL; new_multipack_vbo->attribute_buffer = NULL;
new_multipack_vbo->array_bytes = 0; new_multipack_vbo->buffer_bytes = 0;
new_multipack_vbo->flags = new_multipack_vbo->flags =
COGL_VERTEX_BUFFER_VBO_FLAG_MULTIPACK COGL_VERTEX_BUFFER_VBO_FLAG_MULTIPACK
| COGL_VERTEX_BUFFER_VBO_FLAG_INFREQUENT_RESUBMIT; | COGL_VERTEX_BUFFER_VBO_FLAG_INFREQUENT_RESUBMIT;
@ -1400,8 +1401,8 @@ cogl_vertex_buffer_submit_real (CoglVertexBuffer *buffer)
cogl_vbo->attributes = NULL; cogl_vbo->attributes = NULL;
cogl_vbo->attributes = g_list_prepend (cogl_vbo->attributes, cogl_vbo->attributes = g_list_prepend (cogl_vbo->attributes,
attribute); attribute);
cogl_vbo->array = NULL; cogl_vbo->attribute_buffer = NULL;
cogl_vbo->array_bytes = attribute->span_bytes; cogl_vbo->buffer_bytes = attribute->span_bytes;
new_vbos = g_list_prepend (new_vbos, cogl_vbo); new_vbos = g_list_prepend (new_vbos, cogl_vbo);
} }
else else
@ -1423,9 +1424,9 @@ cogl_vertex_buffer_submit_real (CoglVertexBuffer *buffer)
* is based on the adjacent attribute. * is based on the adjacent attribute.
*/ */
PAD_FOR_ALIGNMENT (new_multipack_vbo->array_bytes, type_size); PAD_FOR_ALIGNMENT (new_multipack_vbo->buffer_bytes, type_size);
new_multipack_vbo->array_bytes += attribute->span_bytes; new_multipack_vbo->buffer_bytes += attribute->span_bytes;
} }
} }

View File

@ -81,7 +81,7 @@ typedef struct _CoglFramebuffer CoglFramebuffer;
#include <cogl/cogl-quaternion.h> #include <cogl/cogl-quaternion.h>
#include <cogl/cogl-texture-3d.h> #include <cogl/cogl-texture-3d.h>
#include <cogl/cogl-index-array.h> #include <cogl/cogl-index-array.h>
#include <cogl/cogl-vertex-array.h> #include <cogl/cogl-attribute-buffer.h>
#include <cogl/cogl-indices.h> #include <cogl/cogl-indices.h>
#include <cogl/cogl-attribute.h> #include <cogl/cogl-attribute.h>
#include <cogl/cogl-primitive.h> #include <cogl/cogl-primitive.h>

View File

@ -52,8 +52,8 @@
static void _cogl_path_free (CoglPath *path); static void _cogl_path_free (CoglPath *path);
static void _cogl_path_build_fill_vbo (CoglPath *path); static void _cogl_path_build_fill_attribute_buffer (CoglPath *path);
static void _cogl_path_build_stroke_vbo (CoglPath *path); static void _cogl_path_build_stroke_attribute_buffer (CoglPath *path);
COGL_OBJECT_DEFINE (Path, path); COGL_OBJECT_DEFINE (Path, path);
@ -62,27 +62,27 @@ _cogl_path_data_clear_vbos (CoglPathData *data)
{ {
int i; int i;
if (data->fill_vbo) if (data->fill_attribute_buffer)
{ {
cogl_object_unref (data->fill_vbo); cogl_object_unref (data->fill_attribute_buffer);
cogl_object_unref (data->fill_vbo_indices); cogl_object_unref (data->fill_vbo_indices);
for (i = 0; i < COGL_PATH_N_ATTRIBUTES; i++) for (i = 0; i < COGL_PATH_N_ATTRIBUTES; i++)
cogl_object_unref (data->fill_vbo_attributes[i]); cogl_object_unref (data->fill_attributes[i]);
data->fill_vbo = NULL; data->fill_attribute_buffer = NULL;
} }
if (data->stroke_vbo) if (data->stroke_attribute_buffer)
{ {
cogl_object_unref (data->stroke_vbo); cogl_object_unref (data->stroke_attribute_buffer);
for (i = 0; i < data->stroke_vbo_n_attributes; i++) for (i = 0; i < data->stroke_n_attributes; i++)
cogl_object_unref (data->stroke_vbo_attributes[i]); cogl_object_unref (data->stroke_attributes[i]);
g_free (data->stroke_vbo_attributes); g_free (data->stroke_attributes);
data->stroke_vbo = NULL; data->stroke_attribute_buffer = NULL;
} }
} }
@ -118,13 +118,13 @@ _cogl_path_modify (CoglPath *path)
old_data->path_nodes->data, old_data->path_nodes->data,
old_data->path_nodes->len); old_data->path_nodes->len);
path->data->fill_vbo = COGL_INVALID_HANDLE; path->data->fill_attribute_buffer = NULL;
path->data->ref_count = 1; path->data->ref_count = 1;
_cogl_path_data_unref (old_data); _cogl_path_data_unref (old_data);
} }
/* The path is altered so the vbo will now be invalid */ /* The path is altered so the vbo will now be invalid */
else if (path->data->fill_vbo) else if (path->data->fill_attribute_buffer)
_cogl_path_data_clear_vbos (path->data); _cogl_path_data_clear_vbos (path->data);
} }
@ -228,7 +228,7 @@ _cogl_path_stroke_nodes (CoglPath *path)
source = copy; source = copy;
} }
_cogl_path_build_stroke_vbo (path); _cogl_path_build_stroke_attribute_buffer (path);
cogl_push_source (source); cogl_push_source (source);
@ -240,7 +240,7 @@ _cogl_path_stroke_nodes (CoglPath *path)
cogl_draw_attributes (COGL_VERTICES_MODE_LINE_STRIP, cogl_draw_attributes (COGL_VERTICES_MODE_LINE_STRIP,
0, node->path_size, 0, node->path_size,
data->stroke_vbo_attributes[path_num], data->stroke_attributes[path_num],
NULL); NULL);
path_num++; path_num++;
@ -341,14 +341,14 @@ _cogl_path_fill_nodes (CoglPath *path)
} }
} }
_cogl_path_build_fill_vbo (path); _cogl_path_build_fill_attribute_buffer (path);
_cogl_draw_indexed_attributes_array _cogl_draw_indexed_attributes_array
(COGL_VERTICES_MODE_TRIANGLES, (COGL_VERTICES_MODE_TRIANGLES,
0, /* first_vertex */ 0, /* first_vertex */
path->data->fill_vbo_n_indices, path->data->fill_vbo_n_indices,
path->data->fill_vbo_indices, path->data->fill_vbo_indices,
path->data->fill_vbo_attributes, path->data->fill_attributes,
COGL_DRAW_SKIP_JOURNAL_FLUSH | COGL_DRAW_SKIP_JOURNAL_FLUSH |
COGL_DRAW_SKIP_PIPELINE_VALIDATION | COGL_DRAW_SKIP_PIPELINE_VALIDATION |
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH); COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH);
@ -1009,8 +1009,8 @@ cogl2_path_new (void)
data->fill_rule = COGL_PATH_FILL_RULE_EVEN_ODD; data->fill_rule = COGL_PATH_FILL_RULE_EVEN_ODD;
data->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode)); data->path_nodes = g_array_new (FALSE, FALSE, sizeof (CoglPathNode));
data->last_path = 0; data->last_path = 0;
data->fill_vbo = COGL_INVALID_HANDLE; data->fill_attribute_buffer = NULL;
data->stroke_vbo = NULL; data->stroke_attribute_buffer = NULL;
data->is_rectangle = FALSE; data->is_rectangle = FALSE;
return _cogl_path_object_new (path); return _cogl_path_object_new (path);
@ -1389,7 +1389,7 @@ _cogl_path_tesselator_combine (double coords[3],
} }
static void static void
_cogl_path_build_fill_vbo (CoglPath *path) _cogl_path_build_fill_attribute_buffer (CoglPath *path)
{ {
CoglPathTesselator tess; CoglPathTesselator tess;
unsigned int path_start = 0; unsigned int path_start = 0;
@ -1397,7 +1397,7 @@ _cogl_path_build_fill_vbo (CoglPath *path)
int i; int i;
/* If we've already got a vbo then we don't need to do anything */ /* If we've already got a vbo then we don't need to do anything */
if (data->fill_vbo) if (data->fill_attribute_buffer)
return; return;
tess.primitive_type = FALSE; tess.primitive_type = FALSE;
@ -1480,27 +1480,28 @@ _cogl_path_build_fill_vbo (CoglPath *path)
gluDeleteTess (tess.glu_tess); gluDeleteTess (tess.glu_tess);
data->fill_vbo = cogl_vertex_array_new (sizeof (CoglPathTesselatorVertex) * data->fill_attribute_buffer =
tess.vertices->len, cogl_attribute_buffer_new (sizeof (CoglPathTesselatorVertex) *
tess.vertices->data); tess.vertices->len,
tess.vertices->data);
g_array_free (tess.vertices, TRUE); g_array_free (tess.vertices, TRUE);
data->fill_vbo_attributes[0] = data->fill_attributes[0] =
cogl_attribute_new (data->fill_vbo, cogl_attribute_new (data->fill_attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (CoglPathTesselatorVertex), sizeof (CoglPathTesselatorVertex),
G_STRUCT_OFFSET (CoglPathTesselatorVertex, x), G_STRUCT_OFFSET (CoglPathTesselatorVertex, x),
2, /* n_components */ 2, /* n_components */
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
data->fill_vbo_attributes[1] = data->fill_attributes[1] =
cogl_attribute_new (data->fill_vbo, cogl_attribute_new (data->fill_attribute_buffer,
"cogl_tex_coord0_in", "cogl_tex_coord0_in",
sizeof (CoglPathTesselatorVertex), sizeof (CoglPathTesselatorVertex),
G_STRUCT_OFFSET (CoglPathTesselatorVertex, s), G_STRUCT_OFFSET (CoglPathTesselatorVertex, s),
2, /* n_components */ 2, /* n_components */
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
/* NULL terminator */ /* NULL terminator */
data->fill_vbo_attributes[2] = NULL; data->fill_attributes[2] = NULL;
data->fill_vbo_indices = cogl_indices_new (tess.indices_type, data->fill_vbo_indices = cogl_indices_new (tess.indices_type,
tess.indices->data, tess.indices->data,
@ -1510,25 +1511,26 @@ _cogl_path_build_fill_vbo (CoglPath *path)
} }
static void static void
_cogl_path_build_stroke_vbo (CoglPath *path) _cogl_path_build_stroke_attribute_buffer (CoglPath *path)
{ {
CoglPathData *data = path->data; CoglPathData *data = path->data;
CoglBuffer *buffer;
unsigned int n_attributes = 0; unsigned int n_attributes = 0;
unsigned int path_start; unsigned int path_start;
CoglPathNode *node; CoglPathNode *node;
floatVec2 *vbo_p; floatVec2 *buffer_p;
unsigned int i; unsigned int i;
/* If we've already got a cached vbo then we don't need to do anything */ /* If we've already got a cached vbo then we don't need to do anything */
if (data->stroke_vbo) if (data->stroke_attribute_buffer)
return; return;
data->stroke_vbo = cogl_vertex_array_new (data->path_nodes->len * data->stroke_attribute_buffer =
sizeof (floatVec2), cogl_attribute_buffer_new (data->path_nodes->len * sizeof (floatVec2),
NULL); NULL);
vbo_p = buffer = COGL_BUFFER (data->stroke_attribute_buffer);
_cogl_buffer_map_for_fill_or_fallback (COGL_BUFFER (data->stroke_vbo)); buffer_p = _cogl_buffer_map_for_fill_or_fallback (buffer);
/* Copy the vertices in and count the number of sub paths. Each sub /* Copy the vertices in and count the number of sub paths. Each sub
path will form a separate attribute so we can paint the disjoint path will form a separate attribute so we can paint the disjoint
@ -1541,16 +1543,16 @@ _cogl_path_build_stroke_vbo (CoglPath *path)
for (i = 0; i < node->path_size; i++) for (i = 0; i < node->path_size; i++)
{ {
vbo_p[path_start + i].x = node[i].x; buffer_p[path_start + i].x = node[i].x;
vbo_p[path_start + i].y = node[i].y; buffer_p[path_start + i].y = node[i].y;
} }
n_attributes++; n_attributes++;
} }
_cogl_buffer_unmap_for_fill_or_fallback (COGL_BUFFER (data->stroke_vbo)); _cogl_buffer_unmap_for_fill_or_fallback (buffer);
data->stroke_vbo_attributes = g_new (CoglAttribute *, n_attributes); data->stroke_attributes = g_new (CoglAttribute *, n_attributes);
/* Now we can loop the sub paths again to create the attributes */ /* Now we can loop the sub paths again to create the attributes */
for (i = 0, path_start = 0; for (i = 0, path_start = 0;
@ -1559,8 +1561,8 @@ _cogl_path_build_stroke_vbo (CoglPath *path)
{ {
node = &g_array_index (data->path_nodes, CoglPathNode, path_start); node = &g_array_index (data->path_nodes, CoglPathNode, path_start);
data->stroke_vbo_attributes[i] = data->stroke_attributes[i] =
cogl_attribute_new (data->stroke_vbo, cogl_attribute_new (data->stroke_attribute_buffer,
"cogl_position_in", "cogl_position_in",
sizeof (floatVec2), sizeof (floatVec2),
path_start * sizeof (floatVec2), path_start * sizeof (floatVec2),
@ -1568,5 +1570,5 @@ _cogl_path_build_stroke_vbo (CoglPath *path)
COGL_ATTRIBUTE_TYPE_FLOAT); COGL_ATTRIBUTE_TYPE_FLOAT);
} }
data->stroke_vbo_n_attributes = n_attributes; data->stroke_n_attributes = n_attributes;
} }