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.
This commit is contained in:
Emmanuele Bassi 2016-08-04 19:14:51 +01:00
parent a0b2b3745f
commit 32d45b0081
2 changed files with 17 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);
}