mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-04 10:36:50 +00:00
Turn more matrix 4x4 functions into macros
This commit is contained in:
parent
809bce6cd9
commit
fbd6d0ebc6
@ -290,7 +290,7 @@ static void gl_set_projection(gl_t *gl,
|
||||
return;
|
||||
}
|
||||
|
||||
matrix_4x4_rotate_z(&rot, M_PI * gl->rotation / 180.0f);
|
||||
matrix_4x4_rotate_z(rot, M_PI * gl->rotation / 180.0f);
|
||||
matrix_4x4_multiply(&gl->mvp, &rot, &gl->mvp_no_rot);
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ static void vita2d_set_projection(vita_video_t *vita,
|
||||
return;
|
||||
}
|
||||
|
||||
matrix_4x4_rotate_z(&rot, M_PI * vita->rotation / 180.0f);
|
||||
matrix_4x4_rotate_z(rot, M_PI * vita->rotation / 180.0f);
|
||||
matrix_4x4_multiply(&vita->mvp, &rot, &vita->mvp_no_rot);
|
||||
}
|
||||
|
||||
|
@ -1324,7 +1324,7 @@ static void vulkan_set_projection(vk_t *vk,
|
||||
return;
|
||||
}
|
||||
|
||||
matrix_4x4_rotate_z(&rot, M_PI * vk->rotation / 180.0f);
|
||||
matrix_4x4_rotate_z(rot, M_PI * vk->rotation / 180.0f);
|
||||
matrix_4x4_multiply(&vk->mvp, &rot, &vk->mvp_no_rot);
|
||||
}
|
||||
|
||||
|
@ -106,33 +106,6 @@ void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad)
|
||||
MAT_ELEM_4X4(*mat, 3, 3) = 1.0f;
|
||||
}
|
||||
|
||||
/*
|
||||
* Builds a rotation matrix using the
|
||||
* rotation around the Z-axis.
|
||||
*/
|
||||
void matrix_4x4_rotate_z(math_matrix_4x4 *mat, float rad)
|
||||
{
|
||||
float cosine = cosf(rad);
|
||||
float sine = sinf(rad);
|
||||
|
||||
MAT_ELEM_4X4(*mat, 0, 0) = cosine;
|
||||
MAT_ELEM_4X4(*mat, 0, 1) = -sine;
|
||||
MAT_ELEM_4X4(*mat, 0, 2) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 0, 3) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 1, 0) = sine;
|
||||
MAT_ELEM_4X4(*mat, 1, 1) = cosine;
|
||||
MAT_ELEM_4X4(*mat, 1, 2) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 1, 3) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 2, 0) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 2, 1) = 0.0f;
|
||||
MAT_ELEM_4X4(*mat, 2, 2) = 1.0f;
|
||||
MAT_ELEM_4X4(*mat, 2, 3) = 0.0f;
|
||||
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 an orthographic projection matrix.
|
||||
*/
|
||||
|
@ -68,7 +68,32 @@ void matrix_4x4_transpose(math_matrix_4x4 *out, const math_matrix_4x4 *in);
|
||||
|
||||
void matrix_4x4_rotate_x(math_matrix_4x4 *mat, float rad);
|
||||
void matrix_4x4_rotate_y(math_matrix_4x4 *mat, float rad);
|
||||
void matrix_4x4_rotate_z(math_matrix_4x4 *mat, float rad);
|
||||
|
||||
/*
|
||||
* Builds a rotation matrix using the
|
||||
* rotation around the Z-axis.
|
||||
*/
|
||||
#define matrix_4x4_rotate_z(mat, radians) \
|
||||
{ \
|
||||
float cosine = cosf(radians); \
|
||||
float sine = sinf(radians); \
|
||||
MAT_ELEM_4X4(mat, 0, 0) = cosine; \
|
||||
MAT_ELEM_4X4(mat, 0, 1) = -sine; \
|
||||
MAT_ELEM_4X4(mat, 0, 2) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 0, 3) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 1, 0) = sine; \
|
||||
MAT_ELEM_4X4(mat, 1, 1) = cosine; \
|
||||
MAT_ELEM_4X4(mat, 1, 2) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 1, 3) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 2, 0) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 2, 1) = 0.0f; \
|
||||
MAT_ELEM_4X4(mat, 2, 2) = 1.0f; \
|
||||
MAT_ELEM_4X4(mat, 2, 3) = 0.0f; \
|
||||
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_ortho(math_matrix_4x4 *mat,
|
||||
float left, float right,
|
||||
|
@ -604,7 +604,9 @@ void menu_display_draw_texture(
|
||||
draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP;
|
||||
draw.pipeline.id = 0;
|
||||
coords.color = (const float*)color;
|
||||
|
||||
menu_display_rotate_z(&rotate_draw);
|
||||
|
||||
draw.texture = texture;
|
||||
draw.x = x;
|
||||
draw.y = height - y;
|
||||
@ -906,7 +908,7 @@ void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw)
|
||||
|
||||
b = (math_matrix_4x4*)menu_disp->get_default_mvp();
|
||||
|
||||
matrix_4x4_rotate_z(&matrix_rotated, draw->rotation);
|
||||
matrix_4x4_rotate_z(matrix_rotated, draw->rotation);
|
||||
matrix_4x4_multiply(draw->matrix, &matrix_rotated, b);
|
||||
|
||||
if (!draw->scale_enable)
|
||||
|
Loading…
x
Reference in New Issue
Block a user