This commit is contained in:
twinaphex 2016-02-09 16:11:37 +01:00
parent 2026401cc0
commit 88c68f479a
5 changed files with 77 additions and 54 deletions

View File

@ -64,7 +64,8 @@ static void *menu_display_d3d_get_default_mvp(void)
#ifdef _XBOX
return NULL; /* TODO/FIXME */
#else
D3DXMatrixOrthoOffCenterLH(&ortho, 0, d3d->final_viewport.Width, 0, d3d->final_viewport.Height, 0, 1);
D3DXMatrixOrthoOffCenterLH(&ortho, 0,
d3d->final_viewport.Width, 0, d3d->final_viewport.Height, 0, 1);
D3DXMatrixTranspose(&mvp, &ortho);
memcpy(default_mvp.data, (FLOAT*)mvp, sizeof(default_mvp.data));
@ -72,7 +73,8 @@ static void *menu_display_d3d_get_default_mvp(void)
#endif
}
static unsigned menu_display_prim_to_d3d_enum(enum menu_display_prim_type prim_type)
static unsigned menu_display_prim_to_d3d_enum(
enum menu_display_prim_type prim_type)
{
switch (prim_type)
{
@ -107,14 +109,17 @@ static void menu_display_d3d_blend_end(void)
d3d_disable_blend_func(d3d->dev);
}
static void menu_display_d3d_draw(menu_display_ctx_draw_t *draw)
static void menu_display_d3d_draw(void *data)
{
D3DVIEWPORT vp = {0};
d3d_video_t *d3d = d3d_get_ptr();
math_matrix_4x4 *mat = draw ? (math_matrix_4x4*)draw->matrix_data : NULL;
D3DVIEWPORT vp = {0};
math_matrix_4x4 *mat = NULL;
d3d_video_t *d3d = d3d_get_ptr();
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!d3d || !draw)
return;
mat = (math_matrix_4x4*)draw->matrix_data;
/* TODO - edge case */
if (draw->height <= 0)
@ -145,21 +150,23 @@ static void menu_display_d3d_draw(menu_display_ctx_draw_t *draw)
#endif
d3d_draw_primitive(d3d->dev, (D3DPRIMITIVETYPE)
menu_display_prim_to_d3d_enum(draw->prim_type), 0, draw->coords->vertices);
menu_display_prim_to_d3d_enum(draw->prim_type),
0, draw->coords->vertices);
#if 0
gl->coords.color = gl->white_color_ptr;
#endif
}
static void menu_display_d3d_draw_bg(menu_display_ctx_draw_t *draw)
static void menu_display_d3d_draw_bg(void *data)
{
struct gfx_coords coords;
const float *new_vertex = NULL;
const float *new_tex_coord = NULL;
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
d3d_video_t *d3d = d3d_get_ptr();
const float *new_vertex = NULL;
const float *new_tex_coord = NULL;
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
d3d_video_t *d3d = d3d_get_ptr();
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!d3d || !draw)
return;
@ -182,14 +189,18 @@ static void menu_display_d3d_draw_bg(menu_display_ctx_draw_t *draw)
menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL);
if ((settings->menu.pause_libretro
|| !rarch_ctl(RARCH_CTL_IS_INITED, NULL) || rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL))
if (
( settings->menu.pause_libretro
|| !rarch_ctl(RARCH_CTL_IS_INITED, NULL)
|| rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)
)
&& !draw->force_transparency && draw->texture)
coords.color = (const float*)draw->color2;
draw->x = 0;
draw->y = 0;
draw->matrix_data = (math_matrix_4x4*)menu_display_d3d_get_default_mvp();
draw->matrix_data = (math_matrix_4x4*)
menu_display_d3d_get_default_mvp();
menu_display_d3d_draw(draw);
@ -208,10 +219,22 @@ static void menu_display_d3d_restore_clear_color(void)
d3d_clear(d3d->dev, 0, NULL, D3DCLEAR_TARGET, clear_color, 0, 0);
}
static void menu_display_d3d_clear_color(float r, float g, float b, float a)
static void menu_display_d3d_clear_color(void *data)
{
d3d_video_t *d3d = d3d_get_ptr();
DWORD clear_color = D3DCOLOR_ARGB(BYTE_CLAMP(a * 255.0f), BYTE_CLAMP(r * 255.0f), BYTE_CLAMP(g * 255.0f), BYTE_CLAMP(b * 255.0f));
DWORD clear_color = 0;
d3d_video_t *d3d = d3d_get_ptr();
menu_display_ctx_clearcolor_t *clearcolor =
(menu_display_ctx_clearcolor_t*)data;
if (!d3d || !clearcolor)
return;
clear_color = D3DCOLOR_ARGB(
BYTE_CLAMP(clearcolor->a * 255.0f), /* A */
BYTE_CLAMP(clearcolor->r * 255.0f), /* R */
BYTE_CLAMP(clearcolor->g * 255.0f), /* G */
BYTE_CLAMP(clearcolor->b * 255.0f) /* B */
);
d3d_clear(d3d->dev, 0, NULL, D3DCLEAR_TARGET, clear_color, 0, 0);
}
@ -222,8 +245,8 @@ static const float *menu_display_d3d_get_tex_coords(void)
}
static bool menu_display_d3d_font_init_first(
void **font_handle, void *video_data, const char *font_path,
float font_size)
void **font_handle, void *video_data,
const char *font_path, float font_size)
{
return font_driver_init_first(NULL, font_handle, video_data,
font_path, font_size, true, FONT_DRIVER_RENDER_DIRECT3D_API);

View File

@ -86,10 +86,11 @@ static void menu_display_gl_blend_end(void)
glDisable(GL_BLEND);
}
static void menu_display_gl_draw(menu_display_ctx_draw_t *draw)
static void menu_display_gl_draw(void *data)
{
gl_t *gl = gl_get_ptr();
math_matrix_4x4 *mat = NULL;
gl_t *gl = gl_get_ptr();
math_matrix_4x4 *mat = NULL;
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!gl || !draw)
return;
@ -121,13 +122,14 @@ static void menu_display_gl_draw(menu_display_ctx_draw_t *draw)
gl->coords.color = gl->white_color_ptr;
}
static void menu_display_gl_draw_bg(menu_display_ctx_draw_t *draw)
static void menu_display_gl_draw_bg(void *data)
{
struct gfx_coords coords;
const GLfloat *new_vertex = NULL;
const GLfloat *new_tex_coord = NULL;
settings_t *settings = config_get_ptr();
gl_t *gl = gl_get_ptr();
const GLfloat *new_vertex = NULL;
const GLfloat *new_tex_coord = NULL;
settings_t *settings = config_get_ptr();
gl_t *gl = gl_get_ptr();
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!gl || !draw)
return;
@ -175,9 +177,13 @@ static void menu_display_gl_restore_clear_color(void)
glClearColor(0.0f, 0.0f, 0.0f, 0.00f);
}
static void menu_display_gl_clear_color(float r, float g, float b, float a)
static void menu_display_gl_clear_color(void *data)
{
glClearColor(r, g, b, a);
menu_display_ctx_clearcolor_t *clearcolor = (menu_display_ctx_clearcolor_t*)data;
if (!clearcolor)
return;
glClearColor(clearcolor->r, clearcolor->g, clearcolor->b, clearcolor->a);
glClear(GL_COLOR_BUFFER_BIT);
}

View File

@ -37,22 +37,23 @@ static void menu_display_null_blend_end(void)
{
}
static void menu_display_null_draw(menu_display_ctx_draw_t *draw)
static void menu_display_null_draw(void *data)
{
(void)draw;
(void)data;
}
static void menu_display_null_draw_bg(menu_display_ctx_draw_t *draw)
static void menu_display_null_draw_bg(void *data)
{
(void)draw;
(void)data;
}
static void menu_display_null_restore_clear_color(void)
{
}
static void menu_display_null_clear_color(float r, float g, float b, float a)
static void menu_display_null_clear_color(void *data)
{
(void)data;
}
static const float *menu_display_null_get_tex_coords(void)
@ -62,8 +63,8 @@ static const float *menu_display_null_get_tex_coords(void)
}
static bool menu_display_null_font_init_first(
void **font_handle, void *video_data, const char *font_path,
float font_size)
void **font_handle, void *video_data,
const char *font_path, float font_size)
{
return true;
}

View File

@ -442,29 +442,24 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data)
break;
case MENU_DISPLAY_CTL_CLEAR_COLOR:
{
menu_display_ctx_clearcolor_t *clearcolor =
(menu_display_ctx_clearcolor_t*)data;
if (!menu_disp || !menu_disp->clear_color || !clearcolor)
if (!menu_disp || !menu_disp->clear_color)
return false;
menu_disp->clear_color(clearcolor->r,
clearcolor->g, clearcolor->b, clearcolor->a);
menu_disp->clear_color(data);
}
break;
case MENU_DISPLAY_CTL_DRAW:
{
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!menu_disp || !menu_disp->draw)
return false;
menu_disp->draw(draw);
menu_disp->draw(data);
}
break;
case MENU_DISPLAY_CTL_DRAW_BG:
{
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!menu_disp || !menu_disp->draw_bg)
return false;
menu_disp->draw_bg(draw);
menu_disp->draw_bg(data);
}
break;
case MENU_DISPLAY_CTL_ROTATE_Z:

View File

@ -147,19 +147,17 @@ typedef struct menu_display_ctx_datetime
typedef struct menu_display_ctx_driver
{
void (*draw)(menu_display_ctx_draw_t *draw);
void (*draw_bg)(menu_display_ctx_draw_t *draw);
void (*draw)(void *data);
void (*draw_bg)(void *data);
void (*blend_begin)(void);
void (*blend_end)(void);
void (*restore_clear_color)(void);
void (*clear_color)(float r, float g, float b, float a);
void (*clear_color)(void *data);
void *(*get_default_mvp)(void);
const float *(*get_tex_coords)(void);
bool (*font_init_first)(
void **font_handle, void *video_data, const char *font_path,
float font_size);
void **font_handle, void *video_data,
const char *font_path, float font_size);
enum menu_display_driver_type type;
const char *ident;
} menu_display_ctx_driver_t;