mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 08:37:41 +00:00
Add matrix_scale/matrix_translate/matrix_projection - file will be
reused for libretro 3D projects so leave this in
This commit is contained in:
parent
9f16c5eee5
commit
435a7dc467
@ -92,6 +92,49 @@ void matrix_ortho(math_matrix *mat,
|
||||
MAT_ELEM(*mat, 2, 3) = tz;
|
||||
}
|
||||
|
||||
void matrix_scale(math_matrix *out, float x, float y,
|
||||
float z)
|
||||
{
|
||||
math_matrix mat;
|
||||
|
||||
MAT_ELEM(mat, 0, 0) = x;
|
||||
MAT_ELEM(mat, 1, 1) = y;
|
||||
MAT_ELEM(mat, 2, 2) = z;
|
||||
MAT_ELEM(mat, 3, 3) = 1.0;
|
||||
|
||||
*out = mat;
|
||||
}
|
||||
|
||||
void matrix_translate(math_matrix *out, float x,
|
||||
float y, float z)
|
||||
{
|
||||
math_matrix mat;
|
||||
|
||||
MAT_ELEM(mat, 0, 0) = 1.0;
|
||||
MAT_ELEM(mat, 1, 1) = 1.0;
|
||||
MAT_ELEM(mat, 2, 2) = 1.0;
|
||||
MAT_ELEM(mat, 3, 3) = 1.0;
|
||||
MAT_ELEM(mat, 0, 3) = x;
|
||||
MAT_ELEM(mat, 1, 3) = y;
|
||||
MAT_ELEM(mat, 2, 3) = z;
|
||||
|
||||
*out = mat;
|
||||
}
|
||||
|
||||
void matrix_projection(math_matrix *out, float znear,
|
||||
float zfar)
|
||||
{
|
||||
math_matrix mat;
|
||||
|
||||
MAT_ELEM(mat, 0, 0) = znear;
|
||||
MAT_ELEM(mat, 1, 1) = zfar;
|
||||
MAT_ELEM(mat, 2, 2) = (zfar + znear) / (zfar - znear);
|
||||
MAT_ELEM(mat, 2, 3) = -2.0f * zfar * znear / (zfar - znear);
|
||||
MAT_ELEM(mat, 3, 2) = -1.0f;
|
||||
|
||||
*out = mat;
|
||||
}
|
||||
|
||||
void matrix_multiply(math_matrix *out,
|
||||
const math_matrix *a, const math_matrix *b)
|
||||
{
|
||||
@ -110,4 +153,3 @@ void matrix_multiply(math_matrix *out,
|
||||
|
||||
*out = mat;
|
||||
}
|
||||
|
||||
|
@ -39,5 +39,9 @@ void matrix_ortho(math_matrix *mat,
|
||||
|
||||
void matrix_multiply(math_matrix *out, const math_matrix *a, const math_matrix *b);
|
||||
|
||||
void matrix_scale(math_matrix *out, float x, float y, float z);
|
||||
void matrix_translate(math_matrix *out, float x, float y, float z);
|
||||
void matrix_projection(math_matrix *out, float znear, float zfar);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user