2009-04-27 10:48:12 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
|
|
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008,2009 Intel Corporation.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2010-03-01 07:56:10 -05:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2009-04-27 10:48:12 -04:00
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Robert Bragg <robert@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
2008-12-11 15:08:15 -05:00
|
|
|
#ifndef __COGL_MATRIX_H
|
|
|
|
#define __COGL_MATRIX_H
|
|
|
|
|
2008-12-22 11:16:07 -05:00
|
|
|
#include <glib.h>
|
2010-04-01 15:06:30 -04:00
|
|
|
#include "cogl-types.h"
|
2008-12-22 11:16:07 -05:00
|
|
|
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:cogl-matrix
|
2009-11-19 08:33:26 -05:00
|
|
|
* @short_description: Fuctions for initializing and manipulating 4x4 matrices
|
2008-12-22 11:16:07 -05:00
|
|
|
*
|
2009-02-06 06:16:42 -05:00
|
|
|
* Matrices are used in Cogl to describe affine model-view transforms, texture
|
|
|
|
* transforms, and projective transforms. This exposes a utility API that can
|
|
|
|
* be used for direct manipulation of these matrices.
|
2008-12-22 11:16:07 -05:00
|
|
|
*/
|
|
|
|
|
2009-07-01 07:34:54 -04:00
|
|
|
typedef struct _CoglMatrix CoglMatrix;
|
2008-12-22 11:16:07 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* CoglMatrix:
|
|
|
|
*
|
|
|
|
* A CoglMatrix holds a 4x4 transform matrix. This is a single precision,
|
|
|
|
* column-major matrix which means it is compatible with what OpenGL expects.
|
|
|
|
*
|
2009-02-06 06:16:42 -05:00
|
|
|
* A CoglMatrix can represent transforms such as, rotations, scaling,
|
2008-12-22 11:16:07 -05:00
|
|
|
* translation, sheering, and linear projections. You can combine these
|
|
|
|
* transforms by multiplying multiple matrices in the order you want them
|
|
|
|
* applied.
|
|
|
|
*
|
|
|
|
* The transformation of a vertex (x, y, z, w) by a CoglMatrix is given by:
|
2009-06-10 07:50:45 -04:00
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* x_new = xx * x + xy * y + xz * z + xw * w
|
|
|
|
* y_new = yx * x + yy * y + yz * z + yw * w
|
|
|
|
* z_new = zx * x + zy * y + zz * z + zw * w
|
|
|
|
* w_new = wx * x + wy * y + wz * z + ww * w
|
|
|
|
* ]|
|
|
|
|
*
|
2008-12-22 11:16:07 -05:00
|
|
|
* Where w is normally 1
|
2009-02-25 11:23:09 -05:00
|
|
|
*
|
2009-06-10 07:50:45 -04:00
|
|
|
* <note>You must consider the members of the CoglMatrix structure read only,
|
2009-02-25 11:23:09 -05:00
|
|
|
* and all matrix modifications must be done via the cogl_matrix API. This
|
|
|
|
* allows Cogl to annotate the matrices internally. Violation of this will give
|
|
|
|
* undefined results. If you need to initialize a matrix with a constant other
|
2009-06-10 07:50:45 -04:00
|
|
|
* than the identity matrix you can use cogl_matrix_init_from_array().</note>
|
2008-12-22 11:16:07 -05:00
|
|
|
*/
|
2009-07-01 07:34:54 -04:00
|
|
|
struct _CoglMatrix
|
|
|
|
{
|
2010-04-12 07:06:03 -04:00
|
|
|
/* column 0 */
|
|
|
|
float xx;
|
|
|
|
float yx;
|
|
|
|
float zx;
|
|
|
|
float wx;
|
2008-12-11 15:08:15 -05:00
|
|
|
|
2010-04-12 07:06:03 -04:00
|
|
|
/* column 1 */
|
|
|
|
float xy;
|
|
|
|
float yy;
|
|
|
|
float zy;
|
|
|
|
float wy;
|
2008-12-11 15:08:15 -05:00
|
|
|
|
2010-04-12 07:06:03 -04:00
|
|
|
/* column 2 */
|
|
|
|
float xz;
|
|
|
|
float yz;
|
|
|
|
float zz;
|
|
|
|
float wz;
|
2008-12-11 15:08:15 -05:00
|
|
|
|
2010-04-12 07:06:03 -04:00
|
|
|
/* column 3 */
|
|
|
|
float xw;
|
|
|
|
float yw;
|
|
|
|
float zw;
|
|
|
|
float ww;
|
2008-12-11 15:08:15 -05:00
|
|
|
|
2010-04-12 10:16:58 -04:00
|
|
|
/*< private >*/
|
|
|
|
|
2010-04-12 07:06:03 -04:00
|
|
|
/* Note: we may want to extend this later with private flags
|
|
|
|
* and a cache of the inverse transform matrix. */
|
2010-04-01 15:06:30 -04:00
|
|
|
float COGL_PRIVATE (inv)[16];
|
|
|
|
unsigned long COGL_PRIVATE (type);
|
|
|
|
unsigned long COGL_PRIVATE (flags);
|
|
|
|
unsigned long COGL_PRIVATE (_padding3);
|
2009-07-01 07:34:54 -04:00
|
|
|
};
|
2008-12-11 15:08:15 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_init_identity:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
*
|
2008-12-22 11:16:07 -05:00
|
|
|
* Resets matrix to the identity matrix:
|
2009-11-19 08:33:26 -05:00
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* .xx=1; .xy=0; .xz=0; .xw=0;
|
|
|
|
* .yx=0; .yy=1; .yz=0; .yw=0;
|
|
|
|
* .zx=0; .zy=0; .zz=1; .zw=0;
|
|
|
|
* .wx=0; .wy=0; .wz=0; .ww=1;
|
|
|
|
* ]|
|
2008-12-11 15:08:15 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_init_identity (CoglMatrix *matrix);
|
2008-12-11 15:08:15 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_multiply:
|
|
|
|
* @result: The address of a 4x4 matrix to store the result in
|
|
|
|
* @a: A 4x4 transformation matrix
|
|
|
|
* @b: A 4x4 transformation matrix
|
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Multiplies the two supplied matrices together and stores
|
|
|
|
* the resulting matrix inside @result
|
2008-12-11 15:08:15 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_multiply (CoglMatrix *result,
|
|
|
|
const CoglMatrix *a,
|
|
|
|
const CoglMatrix *b);
|
2008-12-11 15:08:15 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_rotate:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @angle: The angle you want to rotate in degrees
|
|
|
|
* @x: X component of your rotation vector
|
|
|
|
* @y: Y component of your rotation vector
|
|
|
|
* @z: Z component of your rotation vector
|
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Multiplies @matrix with a rotation matrix that applies a rotation
|
|
|
|
* of @angle degrees around the specified 3D vector.
|
2008-12-11 15:08:15 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_rotate (CoglMatrix *matrix,
|
|
|
|
float angle,
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
float z);
|
2008-12-11 15:08:15 -05:00
|
|
|
|
2010-02-09 09:41:37 -05:00
|
|
|
/**
|
|
|
|
* cogl_matrix_translate:
|
2008-12-11 15:08:15 -05:00
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @x: The X translation you want to apply
|
|
|
|
* @y: The Y translation you want to apply
|
|
|
|
* @z: The Z translation you want to apply
|
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Multiplies @matrix with a transform matrix that translates along
|
|
|
|
* the X, Y and Z axis.
|
2008-12-11 15:08:15 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_translate (CoglMatrix *matrix,
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
float z);
|
2008-12-11 15:08:15 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_scale:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @sx: The X scale factor
|
|
|
|
* @sy: The Y scale factor
|
|
|
|
* @sz: The Z scale factor
|
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Multiplies @matrix with a transform matrix that scales along the X,
|
|
|
|
* Y and Z axis.
|
2008-12-11 15:08:15 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_scale (CoglMatrix *matrix,
|
|
|
|
float sx,
|
|
|
|
float sy,
|
|
|
|
float sz);
|
2008-12-11 15:08:15 -05:00
|
|
|
|
2009-02-24 13:51:25 -05:00
|
|
|
/**
|
|
|
|
* cogl_matrix_frustum:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @left: coord of left vertical clipping plane
|
|
|
|
* @right: coord of right vertical clipping plane
|
|
|
|
* @bottom: coord of bottom horizontal clipping plane
|
|
|
|
* @top: coord of top horizontal clipping plane
|
2009-06-10 07:50:45 -04:00
|
|
|
* @z_near: positive distance to near depth clipping plane
|
|
|
|
* @z_far: positive distance to far depth clipping plane
|
2009-02-24 13:51:25 -05:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Multiplies @matrix by the given frustum perspective matrix.
|
2009-02-24 13:51:25 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_frustum (CoglMatrix *matrix,
|
|
|
|
float left,
|
|
|
|
float right,
|
|
|
|
float bottom,
|
|
|
|
float top,
|
|
|
|
float z_near,
|
|
|
|
float z_far);
|
2009-02-24 13:51:25 -05:00
|
|
|
|
2009-02-18 13:54:54 -05:00
|
|
|
/**
|
2009-05-26 06:33:54 -04:00
|
|
|
* cogl_matrix_perspective:
|
2009-02-18 13:54:54 -05:00
|
|
|
* @matrix: A 4x4 transformation matrix
|
2009-05-26 06:33:54 -04:00
|
|
|
* @fov_y: A field of view angle for the Y axis
|
|
|
|
* @aspect: The ratio of width to height determining the field of view angle
|
2009-11-19 08:33:26 -05:00
|
|
|
* for the x axis.
|
|
|
|
* @z_near: The distance to the near clip plane. Never pass 0 and always pass
|
|
|
|
* a positive number.
|
2009-05-26 06:33:54 -04:00
|
|
|
* @z_far: The distance to the far clip plane. (Should always be positive)
|
2009-02-18 13:54:54 -05:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Multiplies @matrix by the described perspective matrix
|
2009-05-26 06:33:54 -04:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* <note>You should be careful not to have to great a @z_far / @z_near ratio
|
2009-05-26 06:33:54 -04:00
|
|
|
* since that will reduce the effectiveness of depth testing since there wont
|
2009-11-19 08:33:26 -05:00
|
|
|
* be enough precision to identify the depth of objects near to each
|
|
|
|
* other.</note>
|
2009-02-18 13:54:54 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_perspective (CoglMatrix *matrix,
|
|
|
|
float fov_y,
|
|
|
|
float aspect,
|
|
|
|
float z_near,
|
|
|
|
float z_far);
|
2009-05-26 06:33:54 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_ortho:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @left: The coordinate for the left clipping plane
|
|
|
|
* @right: The coordinate for the right clipping plane
|
|
|
|
* @bottom: The coordinate for the bottom clipping plane
|
|
|
|
* @top: The coordinate for the top clipping plane
|
2009-06-04 06:48:51 -04:00
|
|
|
* @z_near: The coordinate for the near clipping plane (may be negative if
|
2009-11-19 08:33:26 -05:00
|
|
|
* the plane is behind the viewer)
|
2009-06-04 06:48:51 -04:00
|
|
|
* @z_far: The coordinate for the far clipping plane (may be negative if
|
2009-11-19 08:33:26 -05:00
|
|
|
* the plane is behind the viewer)
|
2009-05-26 06:33:54 -04:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Multiplies @matrix by a parallel projection matrix.
|
2009-05-26 06:33:54 -04:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_ortho (CoglMatrix *matrix,
|
|
|
|
float left,
|
|
|
|
float right,
|
|
|
|
float bottom,
|
|
|
|
float top,
|
|
|
|
float z_near,
|
|
|
|
float z_far);
|
2009-02-18 13:54:54 -05:00
|
|
|
|
|
|
|
/**
|
2009-02-25 11:23:09 -05:00
|
|
|
* cogl_matrix_init_from_array:
|
2009-02-18 13:54:54 -05:00
|
|
|
* @matrix: A 4x4 transformation matrix
|
2009-02-25 11:23:09 -05:00
|
|
|
* @array: A linear array of 16 floats (column-major order)
|
2009-02-18 13:54:54 -05:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Initializes @matrix with the contents of @array
|
2009-02-18 13:54:54 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_init_from_array (CoglMatrix *matrix,
|
|
|
|
const float *array);
|
2009-02-18 13:54:54 -05:00
|
|
|
|
|
|
|
/**
|
2009-02-25 11:23:09 -05:00
|
|
|
* cogl_matrix_get_array:
|
2009-02-18 13:54:54 -05:00
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Casts @matrix to a float array which can be directly passed to OpenGL.
|
2009-06-10 07:50:45 -04:00
|
|
|
*
|
|
|
|
* Return value: a pointer to the float array
|
2009-02-18 13:54:54 -05:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
G_CONST_RETURN float *
|
|
|
|
cogl_matrix_get_array (const CoglMatrix *matrix);
|
2009-02-18 13:54:54 -05:00
|
|
|
|
2010-04-26 04:55:50 -04:00
|
|
|
/**
|
|
|
|
* cogl_matrix_equal:
|
|
|
|
* @v1: A 4x4 transformation matrix
|
|
|
|
* @v2: A 4x4 transformation matrix
|
|
|
|
*
|
|
|
|
* Compares two matrices to see if they represent the same
|
|
|
|
* transformation. Although internally the matrices may have different
|
|
|
|
* annotations associated with them and may potentially have a cached
|
|
|
|
* inverse matrix these are not considered in the comparison.
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
cogl_matrix_equal (gconstpointer v1, gconstpointer v2);
|
|
|
|
|
2009-10-26 13:51:34 -04:00
|
|
|
/**
|
|
|
|
* cogl_matrix_get_inverse:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
2009-11-19 08:33:26 -05:00
|
|
|
* @inverse: (out): The destination for a 4x4 inverse transformation matrix
|
2009-10-26 13:51:34 -04:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Gets the inverse transform of a given matrix and uses it to initialize
|
|
|
|
* a new #CoglMatrix.
|
2009-10-26 13:51:34 -04:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* <note>Although the first parameter is annotated as const to indicate
|
2009-10-26 13:51:34 -04:00
|
|
|
* that the transform it represents isn't modified this function may
|
2009-11-19 08:33:26 -05:00
|
|
|
* technically save a copy of the inverse transform within the given
|
|
|
|
* #CoglMatrix so that subsequent requests for the inverse transform may
|
|
|
|
* avoid costly inversion calculations.</note>
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the inverse was successfully calculated or %FALSE
|
|
|
|
* for degenerate transformations that can't be inverted (in this case the
|
|
|
|
* @inverse matrix will simply be initialized with the identity matrix)
|
2009-10-26 13:51:34 -04:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Since: 1.2
|
2009-10-26 13:51:34 -04:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
gboolean
|
|
|
|
cogl_matrix_get_inverse (const CoglMatrix *matrix,
|
|
|
|
CoglMatrix *inverse);
|
2009-10-26 13:51:34 -04:00
|
|
|
|
2009-05-26 06:33:54 -04:00
|
|
|
/**
|
|
|
|
* cogl_matrix_transform_point:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
2010-09-03 11:10:44 -04:00
|
|
|
* @x: (inout): The X component of your points position
|
|
|
|
* @y: (inout): The Y component of your points position
|
|
|
|
* @z: (inout): The Z component of your points position
|
|
|
|
* @w: (inout): The W component of your points position
|
2009-05-26 06:33:54 -04:00
|
|
|
*
|
2009-11-19 08:33:26 -05:00
|
|
|
* Transforms a point whos position is given and returned as four float
|
|
|
|
* components.
|
2009-05-26 06:33:54 -04:00
|
|
|
*/
|
cogl: improves header and coding style consistency
We've had complaints that our Cogl code/headers are a bit "special" so
this is a first pass at tidying things up by giving them some
consistency. These changes are all consistent with how new code in Cogl
is being written, but the style isn't consistently applied across all
code yet.
There are two parts to this patch; but since each one required a large
amount of effort to maintain tidy indenting it made sense to combine the
changes to reduce the time spent re indenting the same lines.
The first change is to use a consistent style for declaring function
prototypes in headers. Cogl headers now consistently use this style for
prototypes:
return_type
cogl_function_name (CoglType arg0,
CoglType arg1);
Not everyone likes this style, but it seems that most of the currently
active Cogl developers agree on it.
The second change is to constrain the use of redundant glib data types
in Cogl. Uses of gint, guint, gfloat, glong, gulong and gchar have all
been replaced with int, unsigned int, float, long, unsigned long and char
respectively. When talking about pixel data; use of guchar has been
replaced with guint8, otherwise unsigned char can be used.
The glib types that we continue to use for portability are gboolean,
gint{8,16,32,64}, guint{8,16,32,64} and gsize.
The general intention is that Cogl should look palatable to the widest
range of C programmers including those outside the Gnome community so
- especially for the public API - we want to minimize the number of
foreign looking typedefs.
2010-02-09 20:57:32 -05:00
|
|
|
void
|
|
|
|
cogl_matrix_transform_point (const CoglMatrix *matrix,
|
|
|
|
float *x,
|
|
|
|
float *y,
|
|
|
|
float *z,
|
|
|
|
float *w);
|
2009-05-26 06:33:54 -04:00
|
|
|
|
2008-12-22 11:16:07 -05:00
|
|
|
G_END_DECLS
|
|
|
|
|
2008-12-11 15:08:15 -05:00
|
|
|
#endif /* __COGL_MATRIX_H */
|
|
|
|
|