(Zarch) Use menu_display_draw_frame

This commit is contained in:
twinaphex 2015-10-24 07:51:33 +02:00
parent 8ecfa76ab9
commit 798ed9eba8
5 changed files with 60 additions and 26 deletions

View File

@ -120,7 +120,8 @@ static void glui_render_quad(gl_t *gl, int x, int y, int w, int h,
w,
h,
gl->shader, &coords,
&gl->mvp_no_rot, true, glui->textures.white, 4);
&gl->mvp_no_rot, true, glui->textures.white, 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP );
gl->coords.color = gl->white_color_ptr;
}
@ -450,7 +451,8 @@ static void glui_frame(void)
gl, width, height,
glui->textures.bg.id, 0.75f, false,
&coord_color[0], &coord_color2[0],
&glui_vertexes[0], &glui_tex_coords[0], 4);
&glui_vertexes[0], &glui_tex_coords[0], 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
menu_entries_get_title(title, sizeof(title));

View File

@ -383,7 +383,8 @@ static void xmb_draw_icon(gl_t *gl, xmb_handle_t *xmb,
height - y,
xmb->icon.size,
xmb->icon.size,
gl->shader, &coords, &mymat, false, texture, 4);
gl->shader, &coords, &mymat, false, texture, 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
}
static void xmb_draw_icon_predone(gl_t *gl, xmb_handle_t *xmb,
@ -417,7 +418,8 @@ static void xmb_draw_icon_predone(gl_t *gl, xmb_handle_t *xmb,
height - y,
xmb->icon.size,
xmb->icon.size,
gl->shader, &coords, mymat, false, texture, 4);
gl->shader, &coords, mymat, false, texture, 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
}
static void xmb_draw_boxart(gl_t *gl, xmb_handle_t *xmb, GRfloat *color, unsigned width, unsigned height)
@ -448,7 +450,8 @@ static void xmb_draw_boxart(gl_t *gl, xmb_handle_t *xmb, GRfloat *color, unsigne
height - y,
xmb->boxart_size,
xmb->boxart_size,
gl->shader, &coords, &mymat, false, xmb->boxart, 4);
gl->shader, &coords, &mymat, false, xmb->boxart, 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
}
static void xmb_draw_text(menu_handle_t *menu,
@ -1435,7 +1438,8 @@ static void xmb_draw_cursor(gl_t *gl, xmb_handle_t *xmb,
height - y,
xmb->cursor.size,
xmb->cursor.size,
gl->shader, &coords, &mymat, true, xmb->textures.list[XMB_TEXTURE_POINTER].id, 4);
gl->shader, &coords, &mymat, true, xmb->textures.list[XMB_TEXTURE_POINTER].id, 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
}
static void xmb_render(void)
@ -1603,7 +1607,8 @@ static void xmb_frame(void)
menu_display_frame_background(menu, settings,
gl, width, height, xmb->textures.bg.id, xmb->alpha, false, &coord_color[0],
&coord_color2[0], &rmb_vertex[0], &rmb_tex_coord[0], 4);
&coord_color2[0], &rmb_vertex[0], &rmb_tex_coord[0], 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
xmb_draw_text(menu, xmb,
xmb->title_name, xmb->margins.title.left,
@ -1712,7 +1717,8 @@ static void xmb_frame(void)
width, height,
xmb->textures.bg.id, xmb->alpha, true,
&coord_color[0], &coord_color2[0],
&rmb_vertex[0], &rmb_tex_coord[0], 4);
&rmb_vertex[0], &rmb_tex_coord[0], 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
xmb_frame_messagebox(msg);
}

View File

@ -252,20 +252,17 @@ static void zui_finish(zui_t *zui,
else if (zui->item.active == 0)
zui->item.active = -1;
glViewport(x, y, width, height);
glBindTexture(GL_TEXTURE_2D, 0);
gl->shader->set_coords(&zui->ca);
glEnable(GL_BLEND);
glDrawArrays(GL_TRIANGLES, 0, zui->ca.coords.vertices);
menu_display_draw_frame(
x,
y,
width,
height,
gl->shader, (struct gfx_coords*)&zui->ca,
NULL, true, 0, zui->ca.coords.vertices,
MENU_DISPLAY_PRIM_TRIANGLES);
menu_display_font_flush_block(zui->menu, driver->font_osd_driver);
glDisable(GL_BLEND);
gl->shader->set_mvp(gl, &gl->mvp_no_rot);
zui->rendering = false;
}
@ -943,7 +940,8 @@ static void zarch_frame(void)
gl, zui->width, zui->height,
zui->textures.bg.id, 0.75f, false,
&coord_color[0], &coord_color2[0],
&zarch_vertexes[0], &zarch_tex_coords[0], 4);
&zarch_vertexes[0], &zarch_tex_coords[0], 4,
MENU_DISPLAY_PRIM_TRIANGLESTRIP);
if (gl && gl->shader && gl->shader->use)
gl->shader->use(gl, GL_SHADER_STOCK_BLEND);

View File

@ -483,6 +483,22 @@ void menu_display_msg_queue_push(const char *msg, unsigned prio, unsigned durati
}
#ifdef HAVE_OPENGL
static GLenum menu_display_prim_to_gl_enum(enum menu_display_prim_type prim_type)
{
switch (prim_type)
{
case MENU_DISPLAY_PRIM_TRIANGLESTRIP:
return GL_TRIANGLE_STRIP;
case MENU_DISPLAY_PRIM_TRIANGLES:
return GL_TRIANGLES;
case MENU_DISPLAY_PRIM_NONE:
default:
break;
}
return 0;
}
void menu_display_draw_frame(
unsigned x, unsigned y,
unsigned width, unsigned height,
@ -491,7 +507,8 @@ void menu_display_draw_frame(
math_matrix_4x4 *mat,
bool blend,
GLuint texture,
size_t vertex_count
size_t vertex_count,
enum menu_display_prim_type prim_type
)
{
const shader_backend_t *shader = (const shader_backend_t*)shader_data;
@ -506,7 +523,7 @@ void menu_display_draw_frame(
if (blend)
glEnable(GL_BLEND);
glDrawArrays(GL_TRIANGLE_STRIP, 0, vertex_count);
glDrawArrays(menu_display_prim_to_gl_enum(prim_type), 0, vertex_count);
if (blend)
glDisable(GL_BLEND);
@ -525,7 +542,8 @@ void menu_display_frame_background(
GRfloat *coord_color2,
const GRfloat *vertex,
const GRfloat *tex_coord,
size_t vertex_count)
size_t vertex_count,
enum menu_display_prim_type prim_type)
{
struct gfx_coords coords;
@ -550,7 +568,7 @@ void menu_display_frame_background(
menu_display_draw_frame(0, 0, width, height,
gl->shader, &coords,
&gl->mvp_no_rot, true, texture, vertex_count);
&gl->mvp_no_rot, true, texture, vertex_count, prim_type);
gl->coords.color = gl->white_color_ptr;
}

View File

@ -58,6 +58,13 @@ enum menu_display_ctl_state
MENU_DISPLAY_CTL_SET_FONT_FB
};
enum menu_display_prim_type
{
MENU_DISPLAY_PRIM_NONE = 0,
MENU_DISPLAY_PRIM_TRIANGLESTRIP,
MENU_DISPLAY_PRIM_TRIANGLES
};
void menu_display_free(void);
bool menu_display_init(void);
@ -93,7 +100,8 @@ void menu_display_draw_frame(
math_matrix_4x4 *mat,
bool blend,
GLuint texture,
size_t vertex_count
size_t vertex_count,
enum menu_display_prim_type prim_type
);
void menu_display_frame_background(
@ -108,7 +116,9 @@ void menu_display_frame_background(
GRfloat *color2,
const GRfloat *vertex,
const GRfloat *tex_coord,
size_t vertex_count);
size_t vertex_count,
enum menu_display_prim_type prim_type
);
#endif
const char *menu_video_get_ident(void);