[cogl-vertex-buffer] Add cogl_vertex_buffer_indices_get_for_quads
This function can be used as an efficient way of drawing groups of quads without using GL_QUADS. It generates a VBO containing the indices needed to render using pairs of GL_TRIANGLES. The VBO is globally cached so that it only needs to be uploaded whenever more indices are requested than ever before.
This commit is contained in:
@@ -129,6 +129,10 @@ cogl_create_context ()
|
||||
_cogl_material_get_cogl_enable_flags (_context->source_material);
|
||||
cogl_enable (enable_flags);
|
||||
|
||||
_context->quad_indices_byte = COGL_INVALID_HANDLE;
|
||||
_context->quad_indices_short = COGL_INVALID_HANDLE;
|
||||
_context->quad_indices_short_len = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -165,6 +169,11 @@ _cogl_destroy_context ()
|
||||
if (_context->current_layers)
|
||||
g_array_free (_context->current_layers, TRUE);
|
||||
|
||||
if (_context->quad_indices_byte)
|
||||
cogl_handle_unref (_context->quad_indices_byte);
|
||||
if (_context->quad_indices_short)
|
||||
cogl_handle_unref (_context->quad_indices_short);
|
||||
|
||||
g_free (_context);
|
||||
}
|
||||
|
||||
|
@@ -104,6 +104,12 @@ typedef struct
|
||||
floatVec2 path_nodes_max;
|
||||
CoglHandle stencil_material;
|
||||
|
||||
/* Pre-generated VBOs containing indices to generate GL_TRIANGLES
|
||||
out of a vertex array of quads */
|
||||
CoglHandle quad_indices_byte;
|
||||
guint quad_indices_short_len;
|
||||
CoglHandle quad_indices_short;
|
||||
|
||||
#ifdef HAVE_COGL_GLES2
|
||||
CoglGles2Wrapper gles2;
|
||||
|
||||
@@ -111,7 +117,6 @@ typedef struct
|
||||
supported */
|
||||
GLint viewport_store[4];
|
||||
#endif
|
||||
|
||||
} CoglContext;
|
||||
|
||||
CoglContext *
|
||||
|
Reference in New Issue
Block a user