Clutter Wiki

Views
From ClutterProject
Jump to: navigation, search

CoglVertices

Groups a collection of attributes, optionally an indices array, a draw mode, a vertex/index offset and defines the number of vertices so it wraps up enough information to be retained (e.g. in a renderlist or journal) and drawn later.

cogl_vertices_new (mode, n_vertices, attribute, attribute, NULL);
cogl_vertices_new_with_indices (vertices, mode, n_vertices, indices, attribute, attribute, NULL);
cogl_vertices_set_attributes (vertices, attribute, attribute, NULL);
typedef struct 
{
   float x, y, z;
   float s, t;
   guint8 r, g, b, a;
} CoglV3T2C4;

cogl_vertices_new_with_v3t2c4_attributes (mode, n_vertices, data);
cogl_vertices_set_data (vertices, 0, sizeof (my_vertices), my_vertices);
  • A convenience - only allowed when all the attributes belong to the same vertex array
cogl_vertices_set_indices (vertices, indices, min_index, max_index);
cogl_vertices_set_draw_range (vertices, first_vertex, n_vertices);
  • An error to call this if indices have been associated with the vertices?
cogl_vertices_set_indexed_draw_range (vertices, first_vertex, n_vertices, min_index, max_index);
  • This variant should be encouraged when indices are in use so the driver can use the smallest data type required to process the indices.
  • XXX: actually is this necessary? I guess the min/max index is only used by OpenGL for client side indices when there is an implied copy and thus an opportunity to convert to a smaller data type.
cogl_vertices_draw (vertices);

Do we need more ways to query and manipulate the attributes like:

cogl_vertices_foreach_attribute (vertices, attribute_callback, user_data);
cogl_vertices_find_attribute (vertices, name);
cogl_vertices_remove_attribute (vertices, attribute);
cogl_vertices_add_attribute (vertices, attribute);
  • This would implicitly remove any previously added attribute with the same name

Simplest drawing example

CoglV2C4Vertex vertices[] = 
{
    .....
};

CoglVertices *vertices =
  cogl_vertices_new_with_v2c4_attributes (COGL_DRAW_MODE_TRIANGLES, G_N_ELEMENTS (vertices), vertices);
cogl_vertices_draw ();
Personal tools