blob: 21c1e7858d59948b605774ee81bde9ccbe8ef822 [file] [log] [blame]
Pekka Paalanen668ca372012-01-12 14:30:47 +02001/*
2 * Copyright © 2008-2011 Kristian Høgsberg
Pekka Paalanen75b47ec2012-01-16 14:27:00 +02003 * Copyright © 2012 Collabora, Ltd.
Pekka Paalanen668ca372012-01-12 14:30:47 +02004 *
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that the above copyright notice appear in all copies and that both that
8 * copyright notice and this permission notice appear in supporting
9 * documentation, and that the name of the copyright holders not be used in
10 * advertising or publicity pertaining to distribution of the software
11 * without specific, written prior permission. The copyright holders make
12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
14 *
15 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
20 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 */
23
24#ifndef WESTON_MATRIX_H
25#define WESTON_MATRIX_H
26
27struct weston_matrix {
28 GLfloat d[16];
29};
30
Pekka Paalanen75b47ec2012-01-16 14:27:00 +020031struct weston_inverse_matrix {
32 double LU[16]; /* column-major */
33 unsigned p[4]; /* permutation */
34};
35
Pekka Paalanen668ca372012-01-12 14:30:47 +020036struct weston_vector {
37 GLfloat f[4];
38};
39
40void
41weston_matrix_init(struct weston_matrix *matrix);
42void
43weston_matrix_multiply(struct weston_matrix *m, const struct weston_matrix *n);
44void
45weston_matrix_scale(struct weston_matrix *matrix, GLfloat x, GLfloat y, GLfloat z);
46void
47weston_matrix_translate(struct weston_matrix *matrix,
48 GLfloat x, GLfloat y, GLfloat z);
49void
50weston_matrix_transform(struct weston_matrix *matrix, struct weston_vector *v);
51
Pekka Paalanen061b7472012-01-12 15:00:57 +020052int
Pekka Paalanen75b47ec2012-01-16 14:27:00 +020053weston_matrix_invert(struct weston_inverse_matrix *inverse,
Pekka Paalanen061b7472012-01-12 15:00:57 +020054 const struct weston_matrix *matrix);
Pekka Paalanen75b47ec2012-01-16 14:27:00 +020055void
56weston_matrix_inverse_transform(struct weston_inverse_matrix *inverse,
57 struct weston_vector *v);
Pekka Paalanen061b7472012-01-12 15:00:57 +020058
Pekka Paalanen668ca372012-01-12 14:30:47 +020059#endif /* WESTON_MATRIX_H */