2009-04-27 10:48:12 -04:00
|
|
|
/*
|
|
|
|
* Cogl
|
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* A Low Level GPU Graphics and Utilities API
|
2009-04-27 10:48:12 -04:00
|
|
|
*
|
|
|
|
* Copyright (C) 2008,2009 Intel Corporation.
|
|
|
|
*
|
2014-02-21 20:28:54 -05: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:
|
2009-04-27 10:48:12 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05:00
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
2009-04-27 10:48:12 -04:00
|
|
|
*
|
2014-02-21 20:28:54 -05: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 07:56:10 -05:00
|
|
|
*
|
|
|
|
*
|
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
|
|
|
|
|
2013-04-28 11:49:12 -04:00
|
|
|
#include <cogl/cogl-defines.h>
|
|
|
|
|
2012-11-22 13:01:10 -05:00
|
|
|
#include <glib-object.h>
|
|
|
|
|
2013-03-22 17:18:53 -04:00
|
|
|
#include <cogl/cogl-types.h>
|
|
|
|
#include <cogl/cogl-macros.h>
|
2008-12-22 11:16:07 -05:00
|
|
|
|
2013-03-22 17:18:53 -04:00
|
|
|
#include <cogl/cogl-quaternion.h>
|
2013-09-02 11:02:42 -04:00
|
|
|
#include <glib-object.h>
|
2010-02-24 20:40:29 -05:00
|
|
|
|
2012-11-22 13:01:10 -05:00
|
|
|
COGL_BEGIN_DECLS
|
2008-12-22 11:16:07 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:cogl-matrix
|
2012-11-20 12:08:43 -05:00
|
|
|
* @short_description: Functions 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
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
};
|
2011-05-13 12:30:08 -04:00
|
|
|
COGL_STRUCT_SIZE_ASSERT (CoglMatrix, 128 + sizeof (unsigned long) * 3);
|
2008-12-11 15:08:15 -05:00
|
|
|
|
2013-09-02 11:02:42 -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
|
|
|
|
2012-05-03 07:26:11 -04:00
|
|
|
/**
|
|
|
|
* cogl_matrix_init_translation:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
2012-12-30 11:24:44 -05:00
|
|
|
* @tx: x coordinate of the translation vector
|
|
|
|
* @ty: y coordinate of the translation vector
|
|
|
|
* @tz: z coordinate of the translation vector
|
2012-05-03 07:26:11 -04:00
|
|
|
*
|
|
|
|
* Resets matrix to the (tx, ty, tz) translation matrix:
|
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* .xx=1; .xy=0; .xz=0; .xw=tx;
|
|
|
|
* .yx=0; .yy=1; .yz=0; .yw=ty;
|
|
|
|
* .zx=0; .zy=0; .zz=1; .zw=tz;
|
|
|
|
* .wx=0; .wy=0; .wz=0; .ww=1;
|
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* Since: 2.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_init_translation (CoglMatrix *matrix,
|
|
|
|
float tx,
|
|
|
|
float ty,
|
|
|
|
float tz);
|
|
|
|
|
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
|
2011-02-01 08:19:49 -05:00
|
|
|
* the resulting matrix inside @result.
|
|
|
|
*
|
|
|
|
* <note>It is possible to multiply the @a matrix in-place, so
|
|
|
|
* @result can be equal to @a but can't be equal to @b.</note>
|
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
|
|
|
|
2012-05-17 17:22:01 -04:00
|
|
|
/**
|
|
|
|
* cogl_matrix_rotate_quaternion:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @quaternion: A quaternion describing a rotation
|
|
|
|
*
|
|
|
|
* Multiplies @matrix with a rotation transformation described by the
|
|
|
|
* given #CoglQuaternion.
|
|
|
|
*
|
|
|
|
* Since: 2.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_rotate_quaternion (CoglMatrix *matrix,
|
|
|
|
const CoglQuaternion *quaternion);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_rotate_euler:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @euler: A euler describing a rotation
|
|
|
|
*
|
|
|
|
* Multiplies @matrix with a rotation transformation described by the
|
|
|
|
* given #CoglEuler.
|
|
|
|
*
|
|
|
|
* Since: 2.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_rotate_euler (CoglMatrix *matrix,
|
|
|
|
const CoglEuler *euler);
|
|
|
|
|
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
|
|
|
|
2011-07-08 21:43:17 -04:00
|
|
|
/**
|
|
|
|
* cogl_matrix_look_at:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @eye_position_x: The X coordinate to look from
|
|
|
|
* @eye_position_y: The Y coordinate to look from
|
|
|
|
* @eye_position_z: The Z coordinate to look from
|
|
|
|
* @object_x: The X coordinate of the object to look at
|
|
|
|
* @object_y: The Y coordinate of the object to look at
|
|
|
|
* @object_z: The Z coordinate of the object to look at
|
|
|
|
* @world_up_x: The X component of the world's up direction vector
|
|
|
|
* @world_up_y: The Y component of the world's up direction vector
|
|
|
|
* @world_up_z: The Z component of the world's up direction vector
|
|
|
|
*
|
|
|
|
* Applies a view transform @matrix that positions the camera at
|
|
|
|
* the coordinate (@eye_position_x, @eye_position_y, @eye_position_z)
|
|
|
|
* looking towards an object at the coordinate (@object_x, @object_y,
|
|
|
|
* @object_z). The top of the camera is aligned to the given world up
|
|
|
|
* vector, which is normally simply (0, 1, 0) to map up to the
|
|
|
|
* positive direction of the y axis.
|
|
|
|
*
|
|
|
|
* Because there is a lot of missleading documentation online for
|
|
|
|
* gluLookAt regarding the up vector we want to try and be a bit
|
|
|
|
* clearer here.
|
|
|
|
*
|
|
|
|
* The up vector should simply be relative to your world coordinates
|
|
|
|
* and does not need to change as you move the eye and object
|
|
|
|
* positions. Many online sources may claim that the up vector needs
|
|
|
|
* to be perpendicular to the vector between the eye and object
|
|
|
|
* position (partly because the man page is somewhat missleading) but
|
|
|
|
* that is not necessary for this function.
|
|
|
|
*
|
|
|
|
* <note>You should never look directly along the world-up
|
|
|
|
* vector.</note>
|
|
|
|
*
|
|
|
|
* <note>It is assumed you are using a typical projection matrix where
|
|
|
|
* your origin maps to the center of your viewport.</note>
|
|
|
|
*
|
|
|
|
* <note>Almost always when you use this function it should be the first
|
|
|
|
* transform applied to a new modelview transform</note>
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_look_at (CoglMatrix *matrix,
|
|
|
|
float eye_position_x,
|
|
|
|
float eye_position_y,
|
|
|
|
float eye_position_z,
|
|
|
|
float object_x,
|
|
|
|
float object_y,
|
|
|
|
float object_z,
|
|
|
|
float world_up_x,
|
|
|
|
float world_up_y,
|
|
|
|
float world_up_z);
|
|
|
|
|
2009-02-24 13:51:25 -05:00
|
|
|
/**
|
|
|
|
* cogl_matrix_frustum:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
2011-11-20 13:48:14 -05:00
|
|
|
* @left: X position of the left clipping plane where it
|
|
|
|
* intersects the near clipping plane
|
|
|
|
* @right: X position of the right clipping plane where it
|
|
|
|
* intersects the near clipping plane
|
|
|
|
* @bottom: Y position of the bottom clipping plane where it
|
|
|
|
* intersects the near clipping plane
|
|
|
|
* @top: Y position of the top clipping plane where it intersects
|
|
|
|
* the near clipping plane
|
|
|
|
* @z_near: The distance to the near clipping plane (Must be positive)
|
|
|
|
* @z_far: The distance to the far clipping plane (Must be positive)
|
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
|
2012-02-13 10:19:05 -05:00
|
|
|
* @fov_y: Vertical field of view angle in degrees.
|
2011-11-20 13:48:14 -05:00
|
|
|
* @aspect: The (width over height) aspect ratio for display
|
|
|
|
* @z_near: The distance to the near clipping plane (Must be positive,
|
|
|
|
* and must not be 0)
|
|
|
|
* @z_far: The distance to the far clipping plane (Must 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
|
|
|
*
|
2011-11-20 13:48:14 -05:00
|
|
|
* <note>You should be careful not to have to great a @z_far / @z_near
|
|
|
|
* ratio since that will reduce the effectiveness of depth testing
|
|
|
|
* since there wont 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
|
|
|
|
2011-11-18 09:07:17 -05:00
|
|
|
/**
|
|
|
|
* cogl_matrix_orthographic:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @x_1: The x coordinate for the first vertical clipping plane
|
|
|
|
* @y_1: The y coordinate for the first horizontal clipping plane
|
|
|
|
* @x_2: The x coordinate for the second vertical clipping plane
|
|
|
|
* @y_2: The y coordinate for the second horizontal clipping plane
|
|
|
|
* @near: The <emphasis>distance</emphasis> to the near clipping
|
|
|
|
* plane (will be <emphasis>negative</emphasis> if the plane is
|
|
|
|
* behind the viewer)
|
|
|
|
* @far: The <emphasis>distance</emphasis> to the far clipping
|
|
|
|
* plane (will be <emphasis>negative</emphasis> if the plane is
|
|
|
|
* behind the viewer)
|
|
|
|
*
|
|
|
|
* Multiplies @matrix by a parallel projection matrix.
|
|
|
|
*
|
|
|
|
* Since: 1.10
|
2012-01-15 14:54:42 -05:00
|
|
|
* Stability: unstable
|
2011-11-18 09:07:17 -05:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_orthographic (CoglMatrix *matrix,
|
|
|
|
float x_1,
|
|
|
|
float y_1,
|
|
|
|
float x_2,
|
|
|
|
float y_2,
|
|
|
|
float near,
|
|
|
|
float 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
|
2011-11-20 13:48:14 -05:00
|
|
|
* @near: The <emphasis>distance</emphasis> to the near clipping
|
|
|
|
* plane (will be <emphasis>negative</emphasis> if the plane is
|
|
|
|
* behind the viewer)
|
|
|
|
* @far: The <emphasis>distance</emphasis> to the far clipping
|
|
|
|
* plane (will be <emphasis>negative</emphasis> if 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.
|
2011-11-18 09:07:17 -05:00
|
|
|
*
|
|
|
|
* Deprecated: 1.10: Use cogl_matrix_orthographic()
|
2009-05-26 06:33:54 -04:00
|
|
|
*/
|
2013-07-24 05:44:56 -04:00
|
|
|
COGL_DEPRECATED_IN_1_10_FOR (cogl_matrix_orthographic)
|
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,
|
2011-11-20 13:48:14 -05:00
|
|
|
float near,
|
2013-07-24 05:44:56 -04:00
|
|
|
float far);
|
2009-02-18 13:54:54 -05:00
|
|
|
|
2011-02-08 10:21:41 -05:00
|
|
|
/**
|
|
|
|
* cogl_matrix_view_2d_in_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
|
|
|
|
* @z_near: The distance to the near clip plane. Never pass 0 and always pass
|
|
|
|
* a positive number.
|
|
|
|
* @z_2d: The distance to the 2D plane. (Should always be positive and
|
|
|
|
* be between @z_near and the z_far value that was passed to
|
|
|
|
* cogl_matrix_frustum())
|
|
|
|
* @width_2d: The width of the 2D coordinate system
|
|
|
|
* @height_2d: The height of the 2D coordinate system
|
|
|
|
*
|
|
|
|
* Multiplies @matrix by a view transform that maps the 2D coordinates
|
|
|
|
* (0,0) top left and (@width_2d,@height_2d) bottom right the full viewport
|
|
|
|
* size. Geometry at a depth of 0 will now lie on this 2D plane.
|
|
|
|
*
|
|
|
|
* Note: this doesn't multiply the matrix by any projection matrix,
|
|
|
|
* but it assumes you have a perspective projection as defined by
|
|
|
|
* passing the corresponding arguments to cogl_matrix_frustum().
|
|
|
|
|
|
|
|
* Toolkits such as Clutter that mix 2D and 3D drawing can use this to
|
|
|
|
* create a 2D coordinate system within a 3D perspective projected
|
|
|
|
* view frustum.
|
2012-01-15 14:54:42 -05:00
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
2011-02-08 10:21:41 -05:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_view_2d_in_frustum (CoglMatrix *matrix,
|
|
|
|
float left,
|
|
|
|
float right,
|
|
|
|
float bottom,
|
|
|
|
float top,
|
|
|
|
float z_near,
|
|
|
|
float z_2d,
|
|
|
|
float width_2d,
|
|
|
|
float height_2d);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_view_2d_in_perspective:
|
|
|
|
* @fov_y: A field of view angle for the Y axis
|
|
|
|
* @aspect: The ratio of width to height determining the field of view angle
|
|
|
|
* for the x axis.
|
|
|
|
* @z_near: The distance to the near clip plane. Never pass 0 and always pass
|
|
|
|
* a positive number.
|
|
|
|
* @z_2d: The distance to the 2D plane. (Should always be positive and
|
|
|
|
* be between @z_near and the z_far value that was passed to
|
|
|
|
* cogl_matrix_frustum())
|
|
|
|
* @width_2d: The width of the 2D coordinate system
|
|
|
|
* @height_2d: The height of the 2D coordinate system
|
|
|
|
*
|
|
|
|
* Multiplies @matrix by a view transform that maps the 2D coordinates
|
|
|
|
* (0,0) top left and (@width_2d,@height_2d) bottom right the full viewport
|
|
|
|
* size. Geometry at a depth of 0 will now lie on this 2D plane.
|
|
|
|
*
|
|
|
|
* Note: this doesn't multiply the matrix by any projection matrix,
|
|
|
|
* but it assumes you have a perspective projection as defined by
|
|
|
|
* passing the corresponding arguments to cogl_matrix_perspective().
|
|
|
|
*
|
|
|
|
* Toolkits such as Clutter that mix 2D and 3D drawing can use this to
|
|
|
|
* create a 2D coordinate system within a 3D perspective projected
|
|
|
|
* view frustum.
|
2012-01-15 14:54:42 -05:00
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
* Stability: unstable
|
2011-02-08 10:21:41 -05:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_view_2d_in_perspective (CoglMatrix *matrix,
|
|
|
|
float fov_y,
|
|
|
|
float aspect,
|
|
|
|
float z_near,
|
|
|
|
float z_2d,
|
|
|
|
float width_2d,
|
|
|
|
float height_2d);
|
|
|
|
|
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
|
|
|
*/
|
2011-06-09 11:21:15 -04:00
|
|
|
const float *
|
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
|
|
|
cogl_matrix_get_array (const CoglMatrix *matrix);
|
2009-02-18 13:54:54 -05:00
|
|
|
|
2010-02-24 20:40:29 -05:00
|
|
|
/**
|
|
|
|
* cogl_matrix_init_from_quaternion:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @quaternion: A #CoglQuaternion
|
|
|
|
*
|
|
|
|
* Initializes @matrix from a #CoglQuaternion rotation.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_init_from_quaternion (CoglMatrix *matrix,
|
2012-05-17 14:16:14 -04:00
|
|
|
const CoglQuaternion *quaternion);
|
2012-05-17 14:18:58 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_init_from_euler:
|
|
|
|
* @matrix: A 4x4 transformation matrix
|
|
|
|
* @euler: A #CoglEuler
|
|
|
|
*
|
|
|
|
* Initializes @matrix from a #CoglEuler rotation.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_init_from_euler (CoglMatrix *matrix,
|
|
|
|
const CoglEuler *euler);
|
2010-02-24 20:40:29 -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
|
|
|
|
*/
|
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 16:56:40 -04:00
|
|
|
CoglBool
|
|
|
|
cogl_matrix_equal (const void *v1, const void *v2);
|
2010-04-26 04:55:50 -04:00
|
|
|
|
2010-11-29 13:47:10 -05:00
|
|
|
/**
|
|
|
|
* cogl_matrix_copy:
|
|
|
|
* @matrix: A 4x4 transformation matrix you want to copy
|
|
|
|
*
|
|
|
|
* Allocates a new #CoglMatrix on the heap and initializes it with
|
|
|
|
* the same values as @matrix.
|
|
|
|
*
|
2013-09-03 10:41:16 -04:00
|
|
|
* Return value: (transfer full): A newly allocated #CoglMatrix which
|
|
|
|
* should be freed using cogl_matrix_free()
|
2010-11-29 13:47:10 -05:00
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
CoglMatrix *
|
|
|
|
cogl_matrix_copy (const CoglMatrix *matrix);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_free:
|
|
|
|
* @matrix: A 4x4 transformation matrix you want to free
|
|
|
|
*
|
|
|
|
* Frees a #CoglMatrix that was previously allocated via a call to
|
|
|
|
* cogl_matrix_copy().
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_free (CoglMatrix *matrix);
|
|
|
|
|
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
|
|
|
*/
|
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 16:56:40 -04:00
|
|
|
CoglBool
|
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
|
|
|
cogl_matrix_get_inverse (const CoglMatrix *matrix,
|
|
|
|
CoglMatrix *inverse);
|
2009-10-26 13:51:34 -04:00
|
|
|
|
2010-11-12 08:35:24 -05:00
|
|
|
/* FIXME: to be consistent with cogl_matrix_{transform,project}_points
|
|
|
|
* this could be renamed to cogl_matrix_project_point for Cogl 2.0...
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2010-11-12 08:35:24 -05:00
|
|
|
/**
|
|
|
|
* cogl_matrix_transform_points:
|
|
|
|
* @matrix: A transformation matrix
|
|
|
|
* @n_components: The number of position components for each input point.
|
|
|
|
* (either 2 or 3)
|
|
|
|
* @stride_in: The stride in bytes between input points.
|
|
|
|
* @points_in: A pointer to the first component of the first input point.
|
|
|
|
* @stride_out: The stride in bytes between output points.
|
|
|
|
* @points_out: A pointer to the first component of the first output point.
|
|
|
|
* @n_points: The number of points to transform.
|
|
|
|
*
|
|
|
|
* Transforms an array of input points and writes the result to
|
|
|
|
* another array of output points. The input points can either have 2
|
|
|
|
* or 3 components each. The output points always have 3 components.
|
|
|
|
* The output array can simply point to the input array to do the
|
|
|
|
* transform in-place.
|
|
|
|
*
|
|
|
|
* If you need to transform 4 component points see
|
|
|
|
* cogl_matrix_project_points().
|
|
|
|
*
|
|
|
|
* Here's an example with differing input/output strides:
|
|
|
|
* |[
|
|
|
|
* typedef struct {
|
|
|
|
* float x,y;
|
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 16:56:40 -04:00
|
|
|
* uint8_t r,g,b,a;
|
2010-11-12 08:35:24 -05:00
|
|
|
* float s,t,p;
|
|
|
|
* } MyInVertex;
|
|
|
|
* typedef struct {
|
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 16:56:40 -04:00
|
|
|
* uint8_t r,g,b,a;
|
2010-11-12 08:35:24 -05:00
|
|
|
* float x,y,z;
|
|
|
|
* } MyOutVertex;
|
|
|
|
* MyInVertex vertices[N_VERTICES];
|
|
|
|
* MyOutVertex results[N_VERTICES];
|
|
|
|
* CoglMatrix matrix;
|
|
|
|
*
|
|
|
|
* my_load_vertices (vertices);
|
|
|
|
* my_get_matrix (&matrix);
|
|
|
|
*
|
|
|
|
* cogl_matrix_transform_points (&matrix,
|
|
|
|
* 2,
|
|
|
|
* sizeof (MyInVertex),
|
|
|
|
* &vertices[0].x,
|
|
|
|
* sizeof (MyOutVertex),
|
|
|
|
* &results[0].x,
|
|
|
|
* N_VERTICES);
|
|
|
|
* ]|
|
|
|
|
*
|
2012-01-15 14:54:42 -05:00
|
|
|
* Stability: unstable
|
2010-11-12 08:35:24 -05:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_transform_points (const CoglMatrix *matrix,
|
|
|
|
int n_components,
|
|
|
|
size_t stride_in,
|
2011-02-08 05:37:15 -05:00
|
|
|
const void *points_in,
|
2010-11-12 08:35:24 -05:00
|
|
|
size_t stride_out,
|
|
|
|
void *points_out,
|
|
|
|
int n_points);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_project_points:
|
|
|
|
* @matrix: A projection matrix
|
|
|
|
* @n_components: The number of position components for each input point.
|
|
|
|
* (either 2, 3 or 4)
|
|
|
|
* @stride_in: The stride in bytes between input points.
|
|
|
|
* @points_in: A pointer to the first component of the first input point.
|
|
|
|
* @stride_out: The stride in bytes between output points.
|
|
|
|
* @points_out: A pointer to the first component of the first output point.
|
|
|
|
* @n_points: The number of points to transform.
|
|
|
|
*
|
|
|
|
* Projects an array of input points and writes the result to another
|
|
|
|
* array of output points. The input points can either have 2, 3 or 4
|
|
|
|
* components each. The output points always have 4 components (known
|
|
|
|
* as homogenous coordinates). The output array can simply point to
|
|
|
|
* the input array to do the transform in-place.
|
|
|
|
*
|
|
|
|
* Here's an example with differing input/output strides:
|
|
|
|
* |[
|
|
|
|
* typedef struct {
|
|
|
|
* float x,y;
|
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 16:56:40 -04:00
|
|
|
* uint8_t r,g,b,a;
|
2010-11-12 08:35:24 -05:00
|
|
|
* float s,t,p;
|
|
|
|
* } MyInVertex;
|
|
|
|
* typedef struct {
|
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 16:56:40 -04:00
|
|
|
* uint8_t r,g,b,a;
|
2010-11-12 08:35:24 -05:00
|
|
|
* float x,y,z;
|
|
|
|
* } MyOutVertex;
|
|
|
|
* MyInVertex vertices[N_VERTICES];
|
|
|
|
* MyOutVertex results[N_VERTICES];
|
|
|
|
* CoglMatrix matrix;
|
|
|
|
*
|
|
|
|
* my_load_vertices (vertices);
|
|
|
|
* my_get_matrix (&matrix);
|
|
|
|
*
|
|
|
|
* cogl_matrix_project_points (&matrix,
|
|
|
|
* 2,
|
|
|
|
* sizeof (MyInVertex),
|
|
|
|
* &vertices[0].x,
|
|
|
|
* sizeof (MyOutVertex),
|
|
|
|
* &results[0].x,
|
|
|
|
* N_VERTICES);
|
|
|
|
* ]|
|
|
|
|
*
|
2012-01-15 14:54:42 -05:00
|
|
|
* Stability: unstable
|
2010-11-12 08:35:24 -05:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_project_points (const CoglMatrix *matrix,
|
|
|
|
int n_components,
|
|
|
|
size_t stride_in,
|
2011-02-08 05:37:15 -05:00
|
|
|
const void *points_in,
|
2010-11-12 08:35:24 -05:00
|
|
|
size_t stride_out,
|
|
|
|
void *points_out,
|
|
|
|
int n_points);
|
|
|
|
|
2011-06-30 17:15:08 -04:00
|
|
|
/**
|
|
|
|
* cogl_matrix_is_identity:
|
|
|
|
* @matrix: A #CoglMatrix
|
|
|
|
*
|
|
|
|
* Determines if the given matrix is an identity matrix.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if @matrix is an identity matrix else %FALSE
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
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 16:56:40 -04:00
|
|
|
CoglBool
|
2011-06-30 17:15:08 -04:00
|
|
|
cogl_matrix_is_identity (const CoglMatrix *matrix);
|
|
|
|
|
2011-11-03 11:31:46 -04:00
|
|
|
/**
|
|
|
|
* cogl_matrix_transpose:
|
|
|
|
* @matrix: A #CoglMatrix
|
|
|
|
*
|
|
|
|
* Replaces @matrix with its transpose. Ie, every element (i,j) in the
|
|
|
|
* new matrix is taken from element (j,i) in the old matrix.
|
|
|
|
*
|
|
|
|
* Since: 1.10
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_matrix_transpose (CoglMatrix *matrix);
|
|
|
|
|
2012-06-20 10:50:18 -04:00
|
|
|
/**
|
|
|
|
* cogl_debug_matrix_print:
|
|
|
|
* @matrix: A #CoglMatrix
|
|
|
|
*
|
|
|
|
* Prints the contents of a #CoglMatrix to stdout.
|
|
|
|
*
|
|
|
|
* Since: 2.0
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
cogl_debug_matrix_print (const CoglMatrix *matrix);
|
|
|
|
|
2013-09-02 11:02:42 -04:00
|
|
|
#define COGL_GTYPE_TYPE_MATRIX (cogl_matrix_get_gtype ())
|
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_matrix_get_gtype:
|
|
|
|
*
|
|
|
|
* Returns: a #GType that can be used with the GLib type system.
|
|
|
|
*/
|
|
|
|
GType cogl_matrix_get_gtype (void);
|
2010-11-29 16:42:06 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cogl_gtype_matrix_get_type:
|
|
|
|
*
|
2012-12-29 14:17:35 -05:00
|
|
|
* Returns: the GType for the registered "CoglMatrix" boxed type. This
|
2010-11-29 16:42:06 -05:00
|
|
|
* can be used for example to define GObject properties that accept a
|
|
|
|
* #CoglMatrix value.
|
2013-09-02 11:02:42 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.18: Use cogl_matrix_get_gtype() instead.
|
2010-11-29 16:42:06 -05:00
|
|
|
*/
|
|
|
|
GType
|
|
|
|
cogl_gtype_matrix_get_type (void);
|
|
|
|
|
2012-11-22 13:01:10 -05:00
|
|
|
COGL_END_DECLS
|
2008-12-22 11:16:07 -05:00
|
|
|
|
2008-12-11 15:08:15 -05:00
|
|
|
#endif /* __COGL_MATRIX_H */
|