mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 18:20:27 +00:00
Turn more matrix_4x4 functions into macros
This commit is contained in:
parent
fbd6d0ebc6
commit
32cebbbcba
@ -281,7 +281,7 @@ static void gl_set_projection(gl_t *gl,
|
||||
math_matrix_4x4 rot;
|
||||
|
||||
/* Calculate projection. */
|
||||
matrix_4x4_ortho(&gl->mvp_no_rot, ortho->left, ortho->right,
|
||||
matrix_4x4_ortho(gl->mvp_no_rot, ortho->left, ortho->right,
|
||||
ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
||||
|
||||
if (!allow_rotate)
|
||||
|
@ -332,7 +332,7 @@ static void vita2d_set_projection(vita_video_t *vita,
|
||||
math_matrix_4x4 rot;
|
||||
|
||||
/* Calculate projection. */
|
||||
matrix_4x4_ortho(&vita->mvp_no_rot, ortho->left, ortho->right,
|
||||
matrix_4x4_ortho(vita->mvp_no_rot, ortho->left, ortho->right,
|
||||
ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
||||
|
||||
if (!allow_rotate)
|
||||
|
@ -1315,7 +1315,7 @@ static void vulkan_set_projection(vk_t *vk,
|
||||
math_matrix_4x4 rot;
|
||||
|
||||
/* Calculate projection. */
|
||||
matrix_4x4_ortho(&vk->mvp_no_rot, ortho->left, ortho->right,
|
||||
matrix_4x4_ortho(vk->mvp_no_rot, ortho->left, ortho->right,
|
||||
ortho->bottom, ortho->top, ortho->znear, ortho->zfar);
|
||||
|
||||
if (!allow_rotate)
|
||||
|
@ -106,35 +106,6 @@ void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad)
|
||||
MAT_ELEM_4X4(*mat, 3, 3) = 1.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates an orthographic projection matrix.
|
||||
*/
|
||||
void matrix_4x4_ortho(math_matrix_4x4 *mat,
|
||||
float left, float right,
|
||||
float bottom, float top,
|
||||
float znear, float zfar)
|
||||
{
|
||||
float rl = right - left;
|
||||
float tb = top - bottom;
|
||||
float fn = zfar - znear;
|
||||
|
||||
MAT_ELEM_4X4(*mat, 0, 0) = 2.0f / rl;
|
||||
MAT_ELEM_4X4(*mat, 0, 1) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 0, 2) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 0, 3) = -(left + right) / rl;
|
||||
MAT_ELEM_4X4(*mat, 1, 0) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 1, 1) = 2.0f / tb;
|
||||
MAT_ELEM_4X4(*mat, 1, 2) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 1, 3) = -(top + bottom) / tb;
|
||||
MAT_ELEM_4X4(*mat, 2, 0) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 2, 1) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 2, 2) = -2.0f / fn;
|
||||
MAT_ELEM_4X4(*mat, 2, 3) = -(zfar + znear) / fn;
|
||||
MAT_ELEM_4X4(*mat, 3, 0) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 3, 1) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 3, 2) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 3, 3) = 1.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a perspective projection matrix.
|
||||
|
@ -95,10 +95,31 @@ void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad);
|
||||
MAT_ELEM_4X4(mat, 3, 3) = 1.0f; \
|
||||
}
|
||||
|
||||
void matrix_4x4_ortho(math_matrix_4x4 *mat,
|
||||
float left, float right,
|
||||
float bottom, float top,
|
||||
float znear, float zfar);
|
||||
/*
|
||||
* Creates an orthographic projection matrix.
|
||||
*/
|
||||
#define matrix_4x4_ortho(mat, left, right, bottom, top, znear, zfar) \
|
||||
{ \
|
||||
float rl = (right) - (left); \
|
||||
float tb = (top) - (bottom); \
|
||||
float fn = (zfar) - (znear); \
|
||||
MAT_ELEM_4X4(mat, 0, 0) = 2.0f / rl; \
|
||||
MAT_ELEM_4X4(mat, 0, 1) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 0, 3) = -((left) + (right)) / rl; \
|
||||
MAT_ELEM_4X4(mat, 1, 0) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 1, 1) = 2.0f / tb; \
|
||||
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 1, 3) = -((top) + (bottom)) / tb; \
|
||||
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 2, 2) = -2.0f / fn; \
|
||||
MAT_ELEM_4X4(mat, 2, 3) = -((zfar) + (znear)) / fn; \
|
||||
MAT_ELEM_4X4(mat, 3, 0) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 3, 1) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 3, 2) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 3, 3) = 1.0f; \
|
||||
}
|
||||
|
||||
void matrix_4x4_lookat(math_matrix_4x4 *out,
|
||||
vec3_t eye,
|
||||
|
@ -1016,7 +1016,7 @@ static void *zarch_init(void **userdata)
|
||||
zui->header_height = 1000; /* dpi / 3; */
|
||||
zui->font_size = 28;
|
||||
|
||||
matrix_4x4_ortho(&zui->mvp, 0, 1, 1, 0, 0, 1);
|
||||
matrix_4x4_ortho(zui->mvp, 0, 1, 1, 0, 0, 1);
|
||||
|
||||
return menu;
|
||||
error:
|
||||
|
Loading…
Reference in New Issue
Block a user