util: document matrices

Add comments explaining the matrix storage and multiplication, so that
no-one else needs to decipher them again.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
dev
Pekka Paalanen 13 years ago
parent c61eca6002
commit daaf01b3e1
  1. 10
      src/util.c

@ -27,6 +27,14 @@
#include "compositor.h" #include "compositor.h"
/*
* Matrices are stored in column-major order, that is the array indices are:
* 0 4 8 12
* 1 5 9 13
* 2 6 10 14
* 3 7 11 15
*/
WL_EXPORT void WL_EXPORT void
weston_matrix_init(struct weston_matrix *matrix) weston_matrix_init(struct weston_matrix *matrix)
{ {
@ -37,6 +45,7 @@ weston_matrix_init(struct weston_matrix *matrix)
memcpy(matrix, &identity, sizeof identity); memcpy(matrix, &identity, sizeof identity);
} }
/* m <- n * m, that is, m is multiplied on the LEFT. */
WL_EXPORT void WL_EXPORT void
weston_matrix_multiply(struct weston_matrix *m, const struct weston_matrix *n) weston_matrix_multiply(struct weston_matrix *m, const struct weston_matrix *n)
{ {
@ -76,6 +85,7 @@ weston_matrix_scale(struct weston_matrix *matrix, GLfloat x, GLfloat y, GLfloat
weston_matrix_multiply(matrix, &scale); weston_matrix_multiply(matrix, &scale);
} }
/* v <- m * v */
WL_EXPORT void WL_EXPORT void
weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v) weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v)
{ {

Loading…
Cancel
Save