From daaf01b3e104047326d072e8bd8c849537129530 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Tue, 10 Jan 2012 15:40:18 +0200 Subject: [PATCH] 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 --- src/util.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util.c b/src/util.c index 4faa8b4e..8a1742a7 100644 --- a/src/util.c +++ b/src/util.c @@ -27,6 +27,14 @@ #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 weston_matrix_init(struct weston_matrix *matrix) { @@ -37,6 +45,7 @@ weston_matrix_init(struct weston_matrix *matrix) memcpy(matrix, &identity, sizeof identity); } +/* m <- n * m, that is, m is multiplied on the LEFT. */ WL_EXPORT void 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); } +/* v <- m * v */ WL_EXPORT void weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v) {