1
0
Fork 0

Allow using array of vertices even without textures

It's often nice to be able to draw a batch of vertices, even if these
have no texture coordinates. This add a cogl_rectangles, similar to
cogl_rectangles_with_texture_coords, only without.
This commit is contained in:
Johan Bilien 2009-03-20 19:22:23 +00:00 committed by Robert Bragg
parent 5a06f1d1d0
commit 13e5bd9e8b
3 changed files with 60 additions and 0 deletions

View file

@ -477,6 +477,27 @@ void cogl_rectangle_with_multitexture_coords (float x1,
void cogl_rectangles_with_texture_coords (const float *verts,
guint n_rects);
/**
* cogl_rectangles:
* @verts: an array of vertices
* @n_rects: number of rectangles to draw
*
* Draws a series of rectangles in the same way that
* cogl_rectangle() does. In some situations it can give a
* significant performance boost to use this function rather than
* calling cogl_rectangle() separately for each rectangle.
*
* @verts should point to an array of #float<!-- -->s with
* @n_rects * 8 elements. Each group of 4 values corresponds to the
* parameters x1, y1, x2, and y2, and have the same
* meaning as in cogl_rectangle().
*
* Since: 1.0
*/
void cogl_rectangles (const float *verts,
guint n_rects);
/**
* cogl_polygon:
* @vertices: An array of #CoglTextureVertex structs

View file

@ -2749,6 +2749,26 @@ _cogl_rectangles_with_multitexture_coords (
_cogl_journal_flush ();
}
void
cogl_rectangles (const float *verts,
guint n_rects)
{
struct _CoglMutiTexturedRect rects[n_rects];
int i;
for (i = 0; i < n_rects; i++)
{
rects[i].x_1 = verts[i * 4];
rects[i].y_1 = verts[i * 4 + 1];
rects[i].x_2 = verts[i * 4 + 2];
rects[i].y_2 = verts[i * 4 + 3];
rects[i].tex_coords = NULL;
rects[i].tex_coords_len = 0;
}
_cogl_rectangles_with_multitexture_coords (rects, n_rects);
}
void
cogl_rectangles_with_texture_coords (const float *verts,
guint n_rects)

View file

@ -2843,6 +2843,25 @@ _cogl_rectangles_with_multitexture_coords (
_cogl_journal_flush ();
}
void
cogl_rectangles (const float *verts,
guint n_rects)
{
struct _CoglMutiTexturedRect rects[n_rects];
int i;
for (i = 0; i < n_rects; i++)
{
rects[i].x_1 = verts[i * 4];
rects[i].y_1 = verts[i * 4 + 1];
rects[i].x_2 = verts[i * 4 + 2];
rects[i].y_2 = verts[i * 4 + 3];
rects[i].tex_coords = NULL;
rects[i].tex_coords_len = 0;
}
_cogl_rectangles_with_multitexture_coords (rects, n_rects);
}
void
cogl_rectangles_with_texture_coords (const float *verts,