2025-01-27 17:48:18 +01:00
|
|
|
|
#ifndef UTIL_MATRIX_H
|
|
|
|
|
|
#define UTIL_MATRIX_H
|
2022-06-07 23:15:34 +02:00
|
|
|
|
|
2025-01-26 17:46:50 +01:00
|
|
|
|
#include <wayland-server-protocol.h>
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_box;
|
2025-01-27 14:26:47 -05:00
|
|
|
|
struct wlr_fbox;
|
2025-01-26 17:46:50 +01:00
|
|
|
|
|
|
|
|
|
|
/** mat ← a × b */
|
2025-01-27 14:26:40 -05:00
|
|
|
|
void matrix_multiply(float mat[static 9], const float a[static 9],
|
2025-01-26 17:46:50 +01:00
|
|
|
|
const float b[static 9]);
|
|
|
|
|
|
|
|
|
|
|
|
/** Writes a transformation matrix which applies the specified
|
|
|
|
|
|
* wl_output_transform to mat */
|
2025-01-27 14:26:40 -05:00
|
|
|
|
void matrix_transform(float mat[static 9], enum wl_output_transform transform);
|
2025-01-26 17:46:50 +01:00
|
|
|
|
|
|
|
|
|
|
/** Shortcut for the various matrix operations involved in projecting the
|
2025-02-22 17:06:46 -05:00
|
|
|
|
* specified wlr_box onto a given orthographic projection. The result is
|
|
|
|
|
|
* written to mat, which can be applied to each coordinate of the box to get a
|
|
|
|
|
|
* new coordinate from [-1,1].
|
|
|
|
|
|
*/
|
2025-01-27 14:26:40 -05:00
|
|
|
|
void matrix_project_box(float mat[static 9], const struct wlr_box *box);
|
2022-06-07 23:15:34 +02:00
|
|
|
|
|
2025-01-27 14:26:40 -05:00
|
|
|
|
void matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box);
|
2022-06-07 23:15:34 +02:00
|
|
|
|
|
|
|
|
|
|
/**
|
2025-01-27 13:48:07 -05:00
|
|
|
|
* Writes a 2D orthographic projection matrix to mat of (width, height).
|
2022-06-07 23:15:34 +02:00
|
|
|
|
*
|
|
|
|
|
|
* Equivalent to glOrtho(0, width, 0, height, 1, -1) with the transform applied.
|
|
|
|
|
|
*/
|
2025-01-27 13:48:07 -05:00
|
|
|
|
void matrix_projection(float mat[static 9], int width, int height);
|
2022-06-07 23:15:34 +02:00
|
|
|
|
|
2025-01-27 17:54:55 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Compute the inverse of a matrix.
|
|
|
|
|
|
*
|
|
|
|
|
|
* The matrix needs to be inversible.
|
|
|
|
|
|
*/
|
|
|
|
|
|
void matrix_invert(float out[static 9], float m[static 9]);
|
|
|
|
|
|
|
2022-06-07 23:15:34 +02:00
|
|
|
|
#endif
|