From 699b5f7f3ffea63a9b62c65ad5f00d4e05576784 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 Nov 2015 19:34:01 +0100 Subject: [PATCH] Create menu_display_matrix4x4_rotate_z --- menu/drivers/glui.c | 17 ++++------------- menu/menu_display.c | 23 +++++++++++++++++++++++ menu/menu_display.h | 3 +++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 2d25ff9073..49d0cb05fb 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -181,12 +181,11 @@ static void glui_draw_icon(gl_t *gl, glui_handle_t *glui, GRfloat *color) { struct gfx_coords coords; - math_matrix_4x4 mymat, mrot, mscal; + math_matrix_4x4 mymat, mscal; menu_display_blend_begin(); - matrix_4x4_rotate_z(&mrot, rotation); - matrix_4x4_multiply(&mymat, &mrot, &gl->mvp_no_rot); + menu_display_matrix_4x4_rotate_z(&mymat, rotation); matrix_4x4_scale(&mscal, scale_factor, scale_factor, 1); matrix_4x4_multiply(&mymat, &mscal, &mymat); @@ -242,14 +241,10 @@ static void glui_render_quad(gl_t *gl, int x, int y, int w, int h, GRfloat *coord_color) { struct gfx_coords coords; - math_matrix_4x4 mymat, mrot; menu_handle_t *menu = menu_driver_get_ptr(); glui_handle_t *glui = (glui_handle_t*)menu->userdata; - matrix_4x4_rotate_z(&mrot, 0); - matrix_4x4_multiply(&mymat, &mrot, &gl->mvp_no_rot); - coords.vertices = 4; coords.vertex = glui_vertexes; coords.tex_coord = glui_tex_coords; @@ -263,7 +258,7 @@ static void glui_render_quad(gl_t *gl, int x, int y, int w, int h, height - y - h, w, h, - &coords, &mymat, glui->textures.white, + &coords, NULL, glui->textures.white, MENU_DISPLAY_PRIM_TRIANGLESTRIP ); gl->coords.color = gl->white_color_ptr; @@ -584,10 +579,6 @@ static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, float x, float y, unsigned width, unsigned height) { struct gfx_coords coords; - math_matrix_4x4 mymat, mrot; - - matrix_4x4_rotate_z(&mrot, 0); - matrix_4x4_multiply(&mymat, &mrot, &gl->mvp_no_rot); coords.vertices = 4; coords.vertex = glui_vertexes; @@ -602,7 +593,7 @@ static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, height - y - 32, 64, 64, - &coords, &mymat, + &coords, NULL, glui->textures.list[GLUI_TEXTURE_POINTER].id, MENU_DISPLAY_PRIM_TRIANGLESTRIP); diff --git a/menu/menu_display.c b/menu/menu_display.c index 866e32b3d0..b237514a9c 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -503,6 +503,26 @@ static GLenum menu_display_prim_to_gl_enum(enum menu_display_prim_type prim_type return 0; } +void menu_display_matrix_4x4_rotate_z(void *data, float rotation) +{ + math_matrix_4x4 matrix_rotated; + math_matrix_4x4 *b = NULL; + math_matrix_4x4 *matrix = (math_matrix_4x4*)data; +#ifdef HAVE_OPENGL + gl_t *gl = (gl_t*)video_driver_get_ptr(NULL); + + if (!gl) + return; + + b = (math_matrix_4x4*)&gl->mvp_no_rot; +#endif + if (!matrix) + return; + + matrix_4x4_rotate_z(&matrix_rotated, rotation); + matrix_4x4_multiply(matrix, &matrix_rotated, b); +} + void menu_display_blend_begin(void) { gl_t *gl = (gl_t*)video_driver_get_ptr(NULL); @@ -541,6 +561,9 @@ void menu_display_draw_frame( if (height <= 0) height = 1; + if (!mat) + mat = &gl->mvp_no_rot; + glViewport(x, y, width, height); glBindTexture(GL_TEXTURE_2D, texture); diff --git a/menu/menu_display.h b/menu/menu_display.h index bc3003b521..d954ddaf32 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -124,8 +124,11 @@ void menu_display_frame_background( void menu_display_restore_clear_color(void *data); void menu_display_clear_color(void *data, float r, float g, float b, float a); + #endif +void menu_display_matrix_4x4_rotate_z(void *data, float rotation); + const char *menu_video_get_ident(void); #ifdef __cplusplus