wlroots/include/util/matrix.h
Alexander Orzechowski 0bdcb22f66 Merge branch 'gles2-simplify-matrix' into 'master'
util/matrix: Simplify the interface

See merge request wlroots/wlroots!4975
2025-06-17 12:37:57 -04:00

40 lines
1.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef UTIL_MATRIX_H
#define UTIL_MATRIX_H
#include <wayland-server-protocol.h>
struct wlr_box;
struct wlr_fbox;
/** mat ← a × b */
void matrix_multiply(float mat[static 9], const float a[static 9],
const float b[static 9]);
/** Writes a transformation matrix which applies the specified
* wl_output_transform to mat */
void matrix_transform(float mat[static 9], enum wl_output_transform transform);
/** Shortcut for the various matrix operations involved in projecting the
* 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].
*/
void matrix_project_box(float mat[static 9], const struct wlr_box *box);
void matrix_project_fbox(float mat[static 9], const struct wlr_fbox *box);
/**
* Writes a 2D orthographic projection matrix to mat of (width, height).
*
* Equivalent to glOrtho(0, width, 0, height, 1, -1) with the transform applied.
*/
void matrix_projection(float mat[static 9], int width, int height);
/**
* Compute the inverse of a matrix.
*
* The matrix needs to be inversible.
*/
void matrix_invert(float out[static 9], float m[static 9]);
#endif