CoglIndices * cogl_indices_new (CoglContext *context, CoglIndicesType type, const void *indices_data, int n_indices) { size_t buffer_bytes = sizeof_indices_type (type) * n_indices; CoglIndexBuffer *index_buffer = cogl_index_buffer_new (context, buffer_bytes); CoglBuffer *buffer = COGL_BUFFER (index_buffer); CoglIndices *indices; CoglError *ignore_error = NULL; cogl_buffer_set_data (buffer, 0, indices_data, buffer_bytes, &ignore_error); if (ignore_error) { cogl_error_free (ignore_error); cogl_object_unref (index_buffer); return NULL; } indices = cogl_indices_new_for_buffer (type, index_buffer, 0); cogl_object_unref (index_buffer); return indices; }
CoglIndices * cogl_indices_new (CoglIndicesType type, const void *indices_data, int n_indices) { size_t buffer_bytes = sizeof_indices_type (type) * n_indices; CoglIndexBuffer *index_buffer = cogl_index_buffer_new (buffer_bytes); CoglBuffer *buffer = COGL_BUFFER (index_buffer); CoglIndices *indices; cogl_buffer_set_data (buffer, 0, indices_data, buffer_bytes); indices = cogl_indices_new_for_buffer (type, index_buffer, 0); cogl_object_unref (index_buffer); return indices; }