mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
matrix: Add a init_translation() constructor
This allows people to initialize a matrix with a translation transformation. The options to do it at the moment were: * init_from_array() but it give cogl no information about the type of matrix. * init_indentity() and then translate() but it means doing a lot of computations for no reason. Reviewed-by: Robert Bragg <robert@linux.intel.com> (cherry picked from commit 068b3b59221e405dc288d434b0008464684a7c12)
This commit is contained in:
parent
68a6e82828
commit
7ff0b52d78
@ -1603,6 +1603,40 @@ cogl_matrix_init_identity (CoglMatrix *matrix)
|
||||
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a matrix to the (tx, ty, tz) translation matrix.
|
||||
*
|
||||
* @matix matrix.
|
||||
* @tx x coordinate of the translation vector
|
||||
* @ty y coordinate of the translation vector
|
||||
* @tz z coordinate of the translation vector
|
||||
*/
|
||||
static void
|
||||
_cogl_matrix_init_translation (CoglMatrix *matrix,
|
||||
float tx,
|
||||
float ty,
|
||||
float tz)
|
||||
{
|
||||
memcpy (matrix, identity, 16 * sizeof (float));
|
||||
|
||||
matrix->xw = tx;
|
||||
matrix->yw = ty;
|
||||
matrix->yw = tz;
|
||||
|
||||
matrix->type = COGL_MATRIX_TYPE_3D;
|
||||
matrix->flags = MAT_FLAG_TRANSLATION | MAT_DIRTY_INVERSE;
|
||||
}
|
||||
|
||||
void
|
||||
cogl_matrix_init_translation (CoglMatrix *matrix,
|
||||
float tx,
|
||||
float ty,
|
||||
float tz)
|
||||
{
|
||||
_cogl_matrix_init_translation (matrix, tx, ty, tz);
|
||||
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Test if the given matrix preserves vector lengths.
|
||||
|
@ -126,6 +126,30 @@ COGL_STRUCT_SIZE_ASSERT (CoglMatrix, 128 + sizeof (unsigned long) * 3);
|
||||
void
|
||||
cogl_matrix_init_identity (CoglMatrix *matrix);
|
||||
|
||||
/**
|
||||
* cogl_matrix_init_translation:
|
||||
* @matrix: A 4x4 transformation matrix
|
||||
* @tx x coordinate of the translation vector
|
||||
* @ty y coordinate of the translation vector
|
||||
* @tz z coordinate of the translation vector
|
||||
*
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* cogl_matrix_multiply:
|
||||
* @result: The address of a 4x4 matrix to store the result in
|
||||
|
@ -545,6 +545,7 @@ cogl_color_equal
|
||||
CoglMatrix
|
||||
cogl_matrix_init_identity
|
||||
cogl_matrix_init_from_array
|
||||
cogl_matrix_init_translation
|
||||
cogl_matrix_copy
|
||||
cogl_matrix_equal
|
||||
cogl_matrix_free
|
||||
|
Loading…
Reference in New Issue
Block a user