diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 089880082c..fb1cd80035 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -159,12 +159,7 @@ static void glui_render_background(settings_t *settings, gl_t *gl, glBindTexture(GL_TEXTURE_2D, 0); } - gl->shader->set_coords(&coords); - gl->shader->set_mvp(gl, &gl->mvp_no_rot); - - glEnable(GL_BLEND); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glDisable(GL_BLEND); + menu_gl_draw_frame(gl->shader, &coords, &gl->mvp_no_rot, true); gl->coords.color = gl->white_color_ptr; } @@ -205,12 +200,8 @@ static void glui_render_quad(gl_t *gl, int x, int y, int w, int h, coords.color = color; glBindTexture(GL_TEXTURE_2D, 0); - gl->shader->set_coords(&coords); - gl->shader->set_mvp(gl, &gl->mvp_no_rot); - glEnable(GL_BLEND); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - glDisable(GL_BLEND); + menu_gl_draw_frame(gl->shader, &coords, &gl->mvp_no_rot, true); gl->coords.color = gl->white_color_ptr; } diff --git a/menu/drivers/shared.h b/menu/drivers/shared.h index 8435974d29..efef723125 100644 --- a/menu/drivers/shared.h +++ b/menu/drivers/shared.h @@ -21,6 +21,29 @@ #include #include +#ifdef HAVE_OPENGL +#include "../../gfx/drivers/gl_common.h" + +static INLINE void menu_gl_draw_frame( + const shader_backend_t *shader, + struct gl_coords *coords, + math_matrix_4x4 *mat, + bool blend) +{ + driver_t *driver = driver_get_ptr(); + shader->set_coords(coords); + shader->set_mvp(driver->video_data, mat); + + if (blend) + glEnable(GL_BLEND); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + if (blend) + glDisable(GL_BLEND); +} +#endif + static INLINE void get_title(const char *label, const char *dir, unsigned menu_type, char *title, size_t sizeof_title) { diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c9c53659df..1443d8d7c5 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -26,7 +26,6 @@ #include #include "../../gfx/video_thread_wrapper.h" -#include "../../gfx/drivers/gl_common.h" #include "../../gfx/font_driver.h" #include "../../gfx/video_texture.h" #include @@ -277,25 +276,6 @@ static void xmb_draw_icon_end(void) glDisable(GL_BLEND); } -static void xmb_draw_frame( - const shader_backend_t *shader, - struct gl_coords *coords, - math_matrix_4x4 *mat, - bool blend) -{ - driver_t *driver = driver_get_ptr(); - shader->set_coords(coords); - shader->set_mvp(driver->video_data, mat); - - if (blend) - glEnable(GL_BLEND); - - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - - if (blend) - glDisable(GL_BLEND); -} - static void xmb_draw_icon(gl_t *gl, xmb_handle_t *xmb, GLuint texture, float x, float y, float alpha, float rotation, float scale_factor) @@ -342,7 +322,7 @@ static void xmb_draw_icon(gl_t *gl, xmb_handle_t *xmb, matrix_4x4_scale(&mscal, scale_factor, scale_factor, 1); matrix_4x4_multiply(&mymat, &mscal, &mymat); - xmb_draw_frame(gl->shader, &coords, &mymat, false); + menu_gl_draw_frame(gl->shader, &coords, &mymat, false); } static void xmb_draw_icon_predone(gl_t *gl, xmb_handle_t *xmb, @@ -385,7 +365,7 @@ static void xmb_draw_icon_predone(gl_t *gl, xmb_handle_t *xmb, coords.color = color; glBindTexture(GL_TEXTURE_2D, texture); - xmb_draw_frame(gl->shader, &coords, mymat, false); + menu_gl_draw_frame(gl->shader, &coords, mymat, false); } static void xmb_draw_text(menu_handle_t *menu, @@ -482,7 +462,7 @@ static void xmb_frame_background(menu_handle_t *menu, glBindTexture(GL_TEXTURE_2D, 0); } - xmb_draw_frame(gl->shader, &coords, + menu_gl_draw_frame(gl->shader, &coords, &gl->mvp_no_rot, true); gl->coords.color = gl->white_color_ptr; @@ -1246,7 +1226,7 @@ static void xmb_draw_cursor(gl_t *gl, xmb_handle_t *xmb, float x, float y) matrix_4x4_multiply(&mymat, &mrot, &gl->mvp_no_rot); xmb_draw_icon_begin(); - xmb_draw_frame(gl->shader, &coords, &mymat, true); + menu_gl_draw_frame(gl->shader, &coords, &mymat, true); } static void xmb_render(void)