mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 08:30:42 -05:00
Use a GArray for the texture vertices in cogl_texture_polygon
Previously it was a dynamic array that was manually reallocated.
This commit is contained in:
parent
dfa730909c
commit
93ea1681bb
@ -57,8 +57,8 @@ cogl_create_context ()
|
||||
_context->path_nodes_size = 0;
|
||||
|
||||
_context->texture_handles = NULL;
|
||||
_context->texture_vertices_size = 0;
|
||||
_context->texture_vertices = NULL;
|
||||
_context->texture_vertices = g_array_new (FALSE, FALSE,
|
||||
sizeof (CoglTextureGLVertex));
|
||||
|
||||
_context->fbo_handles = NULL;
|
||||
_context->draw_buffer = COGL_WINDOW_BUFFER;
|
||||
@ -141,6 +141,9 @@ cogl_destroy_context ()
|
||||
if (_context->program_handles)
|
||||
g_array_free (_context->program_handles, TRUE);
|
||||
|
||||
if (_context->texture_vertices)
|
||||
g_array_free (_context->texture_vertices, TRUE);
|
||||
|
||||
g_free (_context);
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,7 @@ typedef struct
|
||||
|
||||
/* Textures */
|
||||
GArray *texture_handles;
|
||||
CoglTextureGLVertex *texture_vertices;
|
||||
gulong texture_vertices_size;
|
||||
GArray *texture_vertices;
|
||||
|
||||
/* Framebuffer objects */
|
||||
GArray *fbo_handles;
|
||||
|
@ -2252,22 +2252,8 @@ cogl_texture_polygon (CoglHandle handle,
|
||||
/* Make sure there is enough space in the global texture vertex
|
||||
array. This is used so we can render the polygon with a single
|
||||
call to OpenGL but still support any number of vertices */
|
||||
if (ctx->texture_vertices_size < n_vertices)
|
||||
{
|
||||
guint nsize = ctx->texture_vertices_size;
|
||||
|
||||
if (nsize == 0)
|
||||
nsize = 1;
|
||||
do
|
||||
nsize *= 2;
|
||||
while (nsize < n_vertices);
|
||||
|
||||
ctx->texture_vertices_size = nsize;
|
||||
|
||||
ctx->texture_vertices = g_realloc (ctx->texture_vertices,
|
||||
nsize
|
||||
* sizeof (CoglTextureGLVertex));
|
||||
}
|
||||
g_array_set_size (ctx->texture_vertices, n_vertices);
|
||||
p = (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||
|
||||
/* Prepare GL state */
|
||||
enable_flags = (COGL_ENABLE_TEXTURE_2D
|
||||
@ -2282,14 +2268,12 @@ cogl_texture_polygon (CoglHandle handle,
|
||||
if (use_color)
|
||||
{
|
||||
enable_flags |= COGL_ENABLE_COLOR_ARRAY;
|
||||
GE( glColorPointer (4, GL_UNSIGNED_BYTE, sizeof (CoglTextureGLVertex),
|
||||
ctx->texture_vertices[0].c) );
|
||||
GE( glColorPointer (4, GL_UNSIGNED_BYTE,
|
||||
sizeof (CoglTextureGLVertex), p->c) );
|
||||
}
|
||||
|
||||
GE( glVertexPointer (3, GL_FLOAT, sizeof (CoglTextureGLVertex),
|
||||
ctx->texture_vertices[0].v) );
|
||||
GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex),
|
||||
ctx->texture_vertices[0].t) );
|
||||
GE( glVertexPointer (3, GL_FLOAT, sizeof (CoglTextureGLVertex), p->v ) );
|
||||
GE( glTexCoordPointer (2, GL_FLOAT, sizeof (CoglTextureGLVertex), p->t ) );
|
||||
|
||||
cogl_enable (enable_flags);
|
||||
|
||||
@ -2320,9 +2304,11 @@ cogl_texture_polygon (CoglHandle handle,
|
||||
|
||||
gl_handle = g_array_index (tex->slice_gl_handles, GLuint, tex_num++);
|
||||
|
||||
p = (CoglTextureGLVertex *) ctx->texture_vertices->data;
|
||||
|
||||
/* Convert the vertices into an array of GLfloats ready to pass to
|
||||
OpenGL */
|
||||
for (i = 0, p = ctx->texture_vertices; i < n_vertices; i++, p++)
|
||||
for (i = 0; i < n_vertices; i++, p++)
|
||||
{
|
||||
#define CFX_F COGL_FIXED_TO_FLOAT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user