mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-10 21:10:15 +00:00
Refactor rotate Z draw calls
This commit is contained in:
parent
2b86b9dbe6
commit
7c7b170ceb
@ -185,14 +185,21 @@ static void mui_draw_icon(mui_handle_t *mui,
|
||||
float rotation, float scale_factor,
|
||||
float *color)
|
||||
{
|
||||
menu_display_ctx_rotate_draw_t rotate_draw;
|
||||
menu_display_ctx_draw_t draw;
|
||||
struct gfx_coords coords;
|
||||
math_matrix_4x4 mymat;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
|
||||
|
||||
menu_display_matrix_4x4_rotate_z(&mymat,
|
||||
rotation, scale_factor, scale_factor, 1, true);
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = rotation;
|
||||
rotate_draw.scale_x = scale_factor;
|
||||
rotate_draw.scale_y = scale_factor;
|
||||
rotate_draw.scale_z = 1;
|
||||
rotate_draw.scale_enable = true;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw);
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = NULL;
|
||||
|
@ -341,6 +341,7 @@ static void xmb_draw_icon(xmb_handle_t *xmb,
|
||||
float rotation, float scale_factor,
|
||||
float *color)
|
||||
{
|
||||
menu_display_ctx_rotate_draw_t rotate_draw;
|
||||
menu_display_ctx_draw_t draw;
|
||||
struct gfx_coords coords;
|
||||
math_matrix_4x4 mymat;
|
||||
@ -352,8 +353,14 @@ static void xmb_draw_icon(xmb_handle_t *xmb,
|
||||
y > height + xmb->icon.size)
|
||||
return;
|
||||
|
||||
menu_display_matrix_4x4_rotate_z(&mymat, rotation,
|
||||
scale_factor, scale_factor, 1, true);
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = rotation;
|
||||
rotate_draw.scale_x = scale_factor;
|
||||
rotate_draw.scale_y = scale_factor;
|
||||
rotate_draw.scale_z = 1;
|
||||
rotate_draw.scale_enable = true;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw);
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = NULL;
|
||||
@ -413,6 +420,7 @@ static void xmb_draw_icon_predone(xmb_handle_t *xmb,
|
||||
static void xmb_draw_boxart(xmb_handle_t *xmb, float *color,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
menu_display_ctx_rotate_draw_t rotate_draw;
|
||||
menu_display_ctx_draw_t draw;
|
||||
struct gfx_coords coords;
|
||||
math_matrix_4x4 mymat;
|
||||
@ -420,7 +428,14 @@ static void xmb_draw_boxart(xmb_handle_t *xmb, float *color,
|
||||
float x = xmb->margins.screen.left + xmb->icon.spacing.horizontal +
|
||||
xmb->icon.spacing.horizontal*4 - xmb->icon.size / 4;
|
||||
|
||||
menu_display_matrix_4x4_rotate_z(&mymat, 0, 1, 1, 1, true);
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0;
|
||||
rotate_draw.scale_x = 1;
|
||||
rotate_draw.scale_y = 1;
|
||||
rotate_draw.scale_z = 1;
|
||||
rotate_draw.scale_enable = true;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw);
|
||||
|
||||
coords.vertices = 4;
|
||||
coords.vertex = NULL;
|
||||
@ -1353,6 +1368,7 @@ static void xmb_draw_items(xmb_handle_t *xmb,
|
||||
size_t i;
|
||||
unsigned ticker_limit;
|
||||
math_matrix_4x4 mymat;
|
||||
menu_display_ctx_rotate_draw_t rotate_draw;
|
||||
xmb_node_t *core_node = NULL;
|
||||
size_t end = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -1368,7 +1384,14 @@ static void xmb_draw_items(xmb_handle_t *xmb,
|
||||
|
||||
end = file_list_get_size(list);
|
||||
|
||||
menu_display_matrix_4x4_rotate_z(&mymat, 0, 1, 1, 1, true);
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0;
|
||||
rotate_draw.scale_x = 1;
|
||||
rotate_draw.scale_y = 1;
|
||||
rotate_draw.scale_z = 1;
|
||||
rotate_draw.scale_enable = true;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw);
|
||||
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
|
||||
|
||||
@ -1719,6 +1742,7 @@ static void xmb_frame(void *data)
|
||||
float coord_color[16];
|
||||
float coord_color2[16];
|
||||
menu_display_ctx_draw_t draw;
|
||||
menu_display_ctx_rotate_draw_t rotate_draw;
|
||||
bool display_kb;
|
||||
bool render_background = false;
|
||||
xmb_handle_t *xmb = (xmb_handle_t*)data;
|
||||
@ -1810,7 +1834,14 @@ static void xmb_frame(void *data)
|
||||
xmb->categories.selection_ptr,
|
||||
&item_color[0], width, height);
|
||||
|
||||
menu_display_matrix_4x4_rotate_z(&mymat, 0, 1, 1, 1, true);
|
||||
rotate_draw.matrix = &mymat;
|
||||
rotate_draw.rotation = 0;
|
||||
rotate_draw.scale_x = 1;
|
||||
rotate_draw.scale_y = 1;
|
||||
rotate_draw.scale_z = 1;
|
||||
rotate_draw.scale_enable = true;
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw);
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL);
|
||||
|
||||
|
@ -478,6 +478,26 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
|
||||
draw->vertex_count, draw->prim_type);
|
||||
}
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_ROTATE_Z:
|
||||
{
|
||||
math_matrix_4x4 matrix_rotated, matrix_scaled;
|
||||
math_matrix_4x4 *b = NULL;
|
||||
menu_display_ctx_rotate_draw_t *draw = (menu_display_ctx_rotate_draw_t*)data;
|
||||
if (!draw || !menu_disp || !menu_disp->get_default_mvp)
|
||||
return false;
|
||||
|
||||
b = (math_matrix_4x4*)menu_disp->get_default_mvp();
|
||||
|
||||
matrix_4x4_rotate_z(&matrix_rotated, draw->rotation);
|
||||
matrix_4x4_multiply(draw->matrix, &matrix_rotated, b);
|
||||
|
||||
if (!draw->scale_enable)
|
||||
return false;
|
||||
|
||||
matrix_4x4_scale(&matrix_scaled, draw->scale_x, draw->scale_y, draw->scale_z);
|
||||
matrix_4x4_multiply(draw->matrix, &matrix_scaled, draw->matrix);
|
||||
}
|
||||
break;
|
||||
case MENU_DISPLAY_CTL_NONE:
|
||||
default:
|
||||
break;
|
||||
@ -511,29 +531,6 @@ void menu_display_timedate(char *s, size_t len, unsigned time_mode)
|
||||
}
|
||||
}
|
||||
|
||||
void menu_display_matrix_4x4_rotate_z(
|
||||
math_matrix_4x4 *matrix, float rotation,
|
||||
float scale_x, float scale_y, float scale_z,
|
||||
bool scale_enable)
|
||||
{
|
||||
math_matrix_4x4 matrix_rotated, matrix_scaled;
|
||||
math_matrix_4x4 *b = NULL;
|
||||
menu_display_ctx_driver_t *menu_disp = menu_display_context_get_ptr();
|
||||
if (!matrix || !menu_disp || !menu_disp->get_default_mvp)
|
||||
return;
|
||||
|
||||
b = (math_matrix_4x4*)menu_disp->get_default_mvp();
|
||||
|
||||
matrix_4x4_rotate_z(&matrix_rotated, rotation);
|
||||
matrix_4x4_multiply(matrix, &matrix_rotated, b);
|
||||
|
||||
if (!scale_enable)
|
||||
return;
|
||||
|
||||
matrix_4x4_scale(&matrix_scaled, scale_x, scale_y, scale_z);
|
||||
matrix_4x4_multiply(matrix, &matrix_scaled, matrix);
|
||||
}
|
||||
|
||||
const float *menu_display_get_tex_coords(void)
|
||||
{
|
||||
menu_display_ctx_driver_t *menu_disp = menu_display_context_get_ptr();
|
||||
|
@ -76,7 +76,8 @@ enum menu_display_ctl_state
|
||||
MENU_DISPLAY_CTL_RESTORE_CLEAR_COLOR,
|
||||
MENU_DISPLAY_CTL_CLEAR_COLOR,
|
||||
MENU_DISPLAY_CTL_DRAW,
|
||||
MENU_DISPLAY_CTL_DRAW_BG
|
||||
MENU_DISPLAY_CTL_DRAW_BG,
|
||||
MENU_DISPLAY_CTL_ROTATE_Z
|
||||
};
|
||||
|
||||
enum menu_display_prim_type
|
||||
@ -179,12 +180,6 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data);
|
||||
|
||||
void menu_display_timedate(char *s, size_t len, unsigned time_mode);
|
||||
|
||||
void menu_display_matrix_4x4_rotate_z(
|
||||
math_matrix_4x4 *matrix, float rotation,
|
||||
float scale_x, float scale_y, float scale_z,
|
||||
bool scale_enable);
|
||||
|
||||
|
||||
void menu_display_handle_wallpaper_upload(void *task_data,
|
||||
void *user_data, const char *err);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user