2008-04-25 13:37:36 +00:00
|
|
|
/*
|
2009-04-27 14:48:12 +00:00
|
|
|
* Cogl
|
2008-04-25 13:37:36 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2008-04-25 13:37:36 +00:00
|
|
|
*
|
2009-04-27 14:48:12 +00:00
|
|
|
* Copyright (C) 2007,2008,2009 Intel Corporation.
|
2008-04-25 13:37:36 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person
|
|
|
|
* obtaining a copy of this software and associated documentation
|
|
|
|
* files (the "Software"), to deal in the Software without
|
|
|
|
* restriction, including without limitation the rights to use, copy,
|
|
|
|
* modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
|
|
* of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2008-04-25 13:37:36 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2008-04-25 13:37:36 +00:00
|
|
|
*
|
2014-02-22 01:28:54 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
2010-03-01 12:56:10 +00:00
|
|
|
*
|
|
|
|
*
|
2008-04-25 13:37:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __COGL_PRIMITIVES_H
|
|
|
|
#define __COGL_PRIMITIVES_H
|
|
|
|
|
2010-03-25 09:33:26 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2012-11-22 18:01:10 +00:00
|
|
|
COGL_BEGIN_DECLS
|
2010-03-25 09:33:26 +00:00
|
|
|
|
2010-02-10 22:30:37 +00:00
|
|
|
/**
|
|
|
|
* SECTION:cogl-primitives
|
|
|
|
* @short_description: Functions that draw various primitive 3D shapes
|
|
|
|
*
|
|
|
|
* The primitives API provides utilities for drawing some
|
|
|
|
* common 3D shapes in a more convenient way than the CoglVertexBuffer
|
|
|
|
* API provides.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_rectangle:
|
|
|
|
* @x_1: X coordinate of the top-left corner
|
|
|
|
* @y_1: Y coordinate of the top-left corner
|
|
|
|
* @x_2: X coordinate of the bottom-right corner
|
|
|
|
* @y_2: Y coordinate of the bottom-right corner
|
|
|
|
*
|
|
|
|
* Fills a rectangle at the given coordinates with the current source material
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
cogl_rectangle (float x_1,
|
|
|
|
float y_1,
|
|
|
|
float x_2,
|
|
|
|
float y_2);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_rectangle_with_texture_coords:
|
|
|
|
* @x1: x coordinate upper left on screen.
|
|
|
|
* @y1: y coordinate upper left on screen.
|
|
|
|
* @x2: x coordinate lower right on screen.
|
|
|
|
* @y2: y coordinate lower right on screen.
|
|
|
|
* @tx1: x part of texture coordinate to use for upper left pixel
|
|
|
|
* @ty1: y part of texture coordinate to use for upper left pixel
|
|
|
|
* @tx2: x part of texture coordinate to use for lower right pixel
|
|
|
|
* @ty2: y part of texture coordinate to use for left pixel
|
|
|
|
*
|
|
|
|
* Draw a rectangle using the current material and supply texture coordinates
|
|
|
|
* to be used for the first texture layer of the material. To draw the entire
|
|
|
|
* texture pass in @tx1=0.0 @ty1=0.0 @tx2=1.0 @ty2=1.0.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_rectangle_with_texture_coords (float x1,
|
|
|
|
float y1,
|
|
|
|
float x2,
|
|
|
|
float y2,
|
|
|
|
float tx1,
|
|
|
|
float ty1,
|
|
|
|
float tx2,
|
|
|
|
float ty2);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_rectangle_with_multitexture_coords:
|
|
|
|
* @x1: x coordinate upper left on screen.
|
|
|
|
* @y1: y coordinate upper left on screen.
|
|
|
|
* @x2: x coordinate lower right on screen.
|
|
|
|
* @y2: y coordinate lower right on screen.
|
|
|
|
* @tex_coords: (in) (array) (transfer none): An array containing groups of
|
|
|
|
* 4 float values: [tx1, ty1, tx2, ty2] that are interpreted as two texture
|
|
|
|
* coordinates; one for the upper left texel, and one for the lower right
|
|
|
|
* texel. Each value should be between 0.0 and 1.0, where the coordinate
|
|
|
|
* (0.0, 0.0) represents the top left of the texture, and (1.0, 1.0) the
|
|
|
|
* bottom right.
|
|
|
|
* @tex_coords_len: The length of the tex_coords array. (e.g. for one layer
|
|
|
|
* and one group of texture coordinates, this would be 4)
|
|
|
|
*
|
|
|
|
* This function draws a rectangle using the current source material to
|
|
|
|
* texture or fill with. As a material may contain multiple texture layers
|
|
|
|
* this interface lets you supply texture coordinates for each layer of the
|
|
|
|
* material.
|
|
|
|
*
|
|
|
|
* The first pair of coordinates are for the first layer (with the smallest
|
|
|
|
* layer index) and if you supply less texture coordinates than there are
|
|
|
|
* layers in the current source material then default texture coordinates
|
|
|
|
* (0.0, 0.0, 1.0, 1.0) are generated.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_rectangle_with_multitexture_coords (float x1,
|
|
|
|
float y1,
|
|
|
|
float x2,
|
|
|
|
float y2,
|
|
|
|
const float *tex_coords,
|
|
|
|
int tex_coords_len);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_rectangles_with_texture_coords:
|
|
|
|
* @verts: (in) (array) (transfer none): an array of vertices
|
|
|
|
* @n_rects: number of rectangles to draw
|
|
|
|
*
|
|
|
|
* Draws a series of rectangles in the same way that
|
|
|
|
* cogl_rectangle_with_texture_coords() does. In some situations it can give a
|
|
|
|
* significant performance boost to use this function rather than
|
|
|
|
* calling cogl_rectangle_with_texture_coords() separately for each rectangle.
|
|
|
|
*
|
|
|
|
* @verts should point to an array of #float<!-- -->s with
|
|
|
|
* @n_rects * 8 elements. Each group of 8 values corresponds to the
|
|
|
|
* parameters x1, y1, x2, y2, tx1, ty1, tx2 and ty2 and have the same
|
|
|
|
* meaning as in cogl_rectangle_with_texture_coords().
|
|
|
|
*
|
|
|
|
* Since: 0.8.6
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_rectangles_with_texture_coords (const float *verts,
|
|
|
|
unsigned int n_rects);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_rectangles:
|
|
|
|
* @verts: (in) (array) (transfer none): 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 * 4 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,
|
|
|
|
unsigned int n_rects);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_polygon:
|
|
|
|
* @vertices: An array of #CoglTextureVertex structs
|
|
|
|
* @n_vertices: The length of the vertices array
|
|
|
|
* @use_color: %TRUE if the color member of #CoglTextureVertex should be used
|
|
|
|
*
|
|
|
|
* Draws a convex polygon using the current source material to fill / texture
|
|
|
|
* with according to the texture coordinates passed.
|
|
|
|
*
|
|
|
|
* If @use_color is %TRUE then the color will be changed for each vertex using
|
|
|
|
* the value specified in the color member of #CoglTextureVertex. This can be
|
|
|
|
* used for example to make the texture fade out by setting the alpha value of
|
|
|
|
* the color.
|
|
|
|
*
|
|
|
|
* All of the texture coordinates must be in the range [0,1] and repeating the
|
|
|
|
* texture is not supported.
|
|
|
|
*
|
|
|
|
* Because of the way this function is implemented it will currently
|
|
|
|
* only work if either the texture is not sliced or the backend is not
|
|
|
|
* OpenGL ES and the minifying and magnifying functions are both set
|
|
|
|
* to COGL_MATERIAL_FILTER_NEAREST.
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_polygon (const CoglTextureVertex *vertices,
|
|
|
|
unsigned int n_vertices,
|
Switch use of primitive glib types to c99 equivalents
The coding style has for a long time said to avoid using redundant glib
data types such as gint or gchar etc because we feel that they make the
code look unnecessarily foreign to developers coming from outside of the
Gnome developer community.
Note: When we tried to find the historical rationale for the types we
just found that they were apparently only added for consistent syntax
highlighting which didn't seem that compelling.
Up until now we have been continuing to use some of the platform
specific type such as gint{8,16,32,64} and gsize but this patch switches
us over to using the standard c99 equivalents instead so we can further
ensure that our code looks familiar to the widest range of C developers
who might potentially contribute to Cogl.
So instead of using the gint{8,16,32,64} and guint{8,16,32,64} types this
switches all Cogl code to instead use the int{8,16,32,64}_t and
uint{8,16,32,64}_t c99 types instead.
Instead of gsize we now use size_t
For now we are not going to use the c99 _Bool type and instead we have
introduced a new CoglBool type to use instead of gboolean.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
(cherry picked from commit 5967dad2400d32ca6319cef6cb572e81bf2c15f0)
2012-04-16 20:56:40 +00:00
|
|
|
CoglBool use_color);
|
2008-04-25 13:37:36 +00:00
|
|
|
|
2012-11-22 18:01:10 +00:00
|
|
|
COGL_END_DECLS
|
2010-03-25 09:33:26 +00:00
|
|
|
|
2008-04-25 13:37:36 +00:00
|
|
|
#endif /* __COGL_PRIMITIVES_H */
|