4 * An object oriented GL/GLES Abstraction/Utility Layer
6 * Copyright (C) 2007,2008,2009 Intel Corporation.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef __COGL_PRIMITIVES_H
25 #define __COGL_PRIMITIVES_H
32 * SECTION:cogl-primitives
33 * @short_description: Functions that draw various primitive 3D shapes
35 * The primitives API provides utilities for drawing some
36 * common 3D shapes in a more convenient way than the CoglVertexBuffer
42 * @x_1: X coordinate of the top-left corner
43 * @y_1: Y coordinate of the top-left corner
44 * @x_2: X coordinate of the bottom-right corner
45 * @y_2: Y coordinate of the bottom-right corner
47 * Fills a rectangle at the given coordinates with the current source material
50 cogl_rectangle (float x_1,
56 * cogl_rectangle_with_texture_coords:
57 * @x1: x coordinate upper left on screen.
58 * @y1: y coordinate upper left on screen.
59 * @x2: x coordinate lower right on screen.
60 * @y2: y coordinate lower right on screen.
61 * @tx1: x part of texture coordinate to use for upper left pixel
62 * @ty1: y part of texture coordinate to use for upper left pixel
63 * @tx2: x part of texture coordinate to use for lower right pixel
64 * @ty2: y part of texture coordinate to use for left pixel
66 * Draw a rectangle using the current material and supply texture coordinates
67 * to be used for the first texture layer of the material. To draw the entire
68 * texture pass in @tx1=0.0 @ty1=0.0 @tx2=1.0 @ty2=1.0.
73 cogl_rectangle_with_texture_coords (float x1,
83 * cogl_rectangle_with_multitexture_coords:
84 * @x1: x coordinate upper left on screen.
85 * @y1: y coordinate upper left on screen.
86 * @x2: x coordinate lower right on screen.
87 * @y2: y coordinate lower right on screen.
88 * @tex_coords: (in) (array) (transfer none): An array containing groups of
89 * 4 float values: [tx1, ty1, tx2, ty2] that are interpreted as two texture
90 * coordinates; one for the upper left texel, and one for the lower right
91 * texel. Each value should be between 0.0 and 1.0, where the coordinate
92 * (0.0, 0.0) represents the top left of the texture, and (1.0, 1.0) the
94 * @tex_coords_len: The length of the tex_coords array. (e.g. for one layer
95 * and one group of texture coordinates, this would be 4)
97 * This function draws a rectangle using the current source material to
98 * texture or fill with. As a material may contain multiple texture layers
99 * this interface lets you supply texture coordinates for each layer of the
102 * The first pair of coordinates are for the first layer (with the smallest
103 * layer index) and if you supply less texture coordinates than there are
104 * layers in the current source material then default texture coordinates
105 * (0.0, 0.0, 1.0, 1.0) are generated.
110 cogl_rectangle_with_multitexture_coords (float x1,
114 const float *tex_coords,
118 * cogl_rectangles_with_texture_coords:
119 * @verts: (in) (array) (transfer none): an array of vertices
120 * @n_rects: number of rectangles to draw
122 * Draws a series of rectangles in the same way that
123 * cogl_rectangle_with_texture_coords() does. In some situations it can give a
124 * significant performance boost to use this function rather than
125 * calling cogl_rectangle_with_texture_coords() separately for each rectangle.
127 * @verts should point to an array of #float<!-- -->s with
128 * @n_rects * 8 elements. Each group of 8 values corresponds to the
129 * parameters x1, y1, x2, y2, tx1, ty1, tx2 and ty2 and have the same
130 * meaning as in cogl_rectangle_with_texture_coords().
135 cogl_rectangles_with_texture_coords (const float *verts,
136 unsigned int n_rects);
140 * @verts: (in) (array) (transfer none): an array of vertices
141 * @n_rects: number of rectangles to draw
143 * Draws a series of rectangles in the same way that
144 * cogl_rectangle() does. In some situations it can give a
145 * significant performance boost to use this function rather than
146 * calling cogl_rectangle() separately for each rectangle.
148 * @verts should point to an array of #float<!-- -->s with
149 * @n_rects * 4 elements. Each group of 4 values corresponds to the
150 * parameters x1, y1, x2, and y2, and have the same
151 * meaning as in cogl_rectangle().
156 cogl_rectangles (const float *verts,
157 unsigned int n_rects);
161 * @vertices: An array of #CoglTextureVertex structs
162 * @n_vertices: The length of the vertices array
163 * @use_color: %TRUE if the color member of #CoglTextureVertex should be used
165 * Draws a convex polygon using the current source material to fill / texture
166 * with according to the texture coordinates passed.
168 * If @use_color is %TRUE then the color will be changed for each vertex using
169 * the value specified in the color member of #CoglTextureVertex. This can be
170 * used for example to make the texture fade out by setting the alpha value of
173 * All of the texture coordinates must be in the range [0,1] and repeating the
174 * texture is not supported.
176 * Because of the way this function is implemented it will currently
177 * only work if either the texture is not sliced or the backend is not
178 * OpenGL ES and the minifying and magnifying functions are both set
179 * to COGL_MATERIAL_FILTER_NEAREST.
184 cogl_polygon (const CoglTextureVertex *vertices,
185 unsigned int n_vertices,
190 #endif /* __COGL_PRIMITIVES_H */