From 32d45b0081859fecf94f3766a5389c0105023f58 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 4 Aug 2016 19:14:51 +0100 Subject: [PATCH] gsk: Pass the appropriate value for the n_quads argument Instead of passing the size of the buffer, we should pass the number of quads; we know what the size of a single quad structure is, so we can do the multiplication internally when creating the VAO. This allows us to print the quads for debugging purposes. --- gsk/gskgldriver.c | 17 ++++++++++++++++- gsk/gskglrenderer.c | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gsk/gskgldriver.c b/gsk/gskgldriver.c index 443a0ad840..a6345259c7 100644 --- a/gsk/gskgldriver.c +++ b/gsk/gskgldriver.c @@ -365,7 +365,7 @@ gsk_gl_driver_create_vao_for_quad (GskGLDriver *driver, glGenBuffers (1, &buffer_id); glBindBuffer (GL_ARRAY_BUFFER, buffer_id); - glBufferData (GL_ARRAY_BUFFER, n_quads, quads, GL_STATIC_DRAW); + glBufferData (GL_ARRAY_BUFFER, sizeof (GskQuadVertex) * n_quads, quads, GL_STATIC_DRAW); glEnableVertexAttribArray (position_id); glVertexAttribPointer (position_id, 2, GL_FLOAT, GL_FALSE, @@ -387,6 +387,21 @@ gsk_gl_driver_create_vao_for_quad (GskGLDriver *driver, v->uv_id = uv_id; g_hash_table_insert (driver->vaos, GINT_TO_POINTER (vao_id), v); +#ifdef G_ENABLE_DEBUG + if (GSK_DEBUG_CHECK (OPENGL)) + { + int i; + g_print ("New VAO(%d) for quad[%d] : {\n", v->vao_id, n_quads); + for (i = 0; i < n_quads; i++) + { + g_print (" { x:%.2f, y:%.2f } { u:%.2f, v:%.2f }\n", + quads[i].position[0], quads[i].position[1], + quads[i].uv[0], quads[i].uv[1]); + } + g_print ("}\n"); + } +#endif + return vao_id; } diff --git a/gsk/gskglrenderer.c b/gsk/gskglrenderer.c index 1e3dcd2e3d..7d16ee1f12 100644 --- a/gsk/gskglrenderer.c +++ b/gsk/gskglrenderer.c @@ -716,7 +716,7 @@ gsk_gl_renderer_add_render_item (GskGLRenderer *self, gsk_gl_driver_create_vao_for_quad (self->gl_driver, item.render_data.position_location, item.render_data.uv_location, - sizeof (GskQuadVertex) * N_VERTICES, + N_VERTICES, vertex_data); }