Allow using array of vertices even without textures
authorJohan Bilien <jobi@litl.com>
Fri, 20 Mar 2009 19:22:23 +0000 (19:22 +0000)
committerRobert Bragg <robert@linux.intel.com>
Mon, 23 Mar 2009 12:41:41 +0000 (12:41 +0000)
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.

clutter/cogl/cogl-texture.h
clutter/cogl/gl/cogl-texture.c
clutter/cogl/gles/cogl-texture.c

index b35b22f..db23942 100644 (file)
@@ -478,6 +478,27 @@ 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
  * @n_vertices: The length of the vertices array
index 044badb..0c6a2a3 100644 (file)
@@ -2750,6 +2750,26 @@ _cogl_rectangles_with_multitexture_coords (
 }
 
 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)
 {
index 719975c..9a51812 100644 (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,