(Menu) Create viewport function callback

This commit is contained in:
twinaphex 2016-04-19 08:50:35 +02:00
parent cddeabd4ec
commit 17273493ef
6 changed files with 60 additions and 18 deletions

View File

@ -49,7 +49,7 @@
#include "../../tasks/tasks_internal.h"
#if 0
#if 1
#define XMB_RIBBON_ENABLE
#define XMB_RIBBON_ROWS 16
#define XMB_RIBBON_COLS 32

View File

@ -110,9 +110,27 @@ static void menu_display_d3d_blend_end(void)
d3d_disable_blend_func(d3d->dev);
}
static void menu_display_d3d_draw(void *data)
static void menu_display_d3d_viewport(void *data)
{
D3DVIEWPORT vp = {0};
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false);
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!d3d || !draw)
return;
vp.X = draw->x;
vp.Y = draw->y;
vp.Width = draw->width;
vp.Height = draw->height;
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;
d3d_set_viewports(d3d->dev, &vp);
}
static void menu_display_d3d_draw(void *data)
{
math_matrix_4x4 *mat = NULL;
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false);
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
@ -136,14 +154,7 @@ static void menu_display_d3d_draw(void *data)
if (!draw->coords->lut_tex_coord)
draw->coords->lut_tex_coord = menu_display_d3d_get_default_tex_coords();
vp.X = draw->x;
vp.Y = draw->y;
vp.Width = draw->width;
vp.Height = draw->height;
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;
d3d_set_viewports(d3d->dev, &vp);
menu_display_d3d_viewport(draw);
d3d_set_texture(d3d->dev, 0, (LPDIRECT3DTEXTURE)draw->texture);
#if 0
@ -192,6 +203,7 @@ static bool menu_display_d3d_font_init_first(
menu_display_ctx_driver_t menu_display_ctx_d3d = {
menu_display_d3d_draw,
menu_display_d3d_viewport,
menu_display_d3d_blend_begin,
menu_display_d3d_blend_end,
menu_display_d3d_restore_clear_color,

View File

@ -94,12 +94,22 @@ static void menu_display_gl_blend_end(void)
glDisable(GL_BLEND);
}
static void menu_display_gl_viewport(void *data)
{
gl_t *gl = (gl_t*)video_driver_get_ptr(false);
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!gl || !draw)
return;
glViewport(draw->x, draw->y, draw->width, draw->height);
}
static void menu_display_gl_draw(void *data)
{
video_shader_ctx_mvp_t mvp;
video_shader_ctx_coords_t coords;
gl_t *gl = (gl_t*)video_driver_get_ptr(false);
math_matrix_4x4 *mat = NULL;
gl_t *gl = (gl_t*)video_driver_get_ptr(false);
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
if (!gl || !draw)
@ -120,7 +130,7 @@ static void menu_display_gl_draw(void *data)
if (!draw->coords->lut_tex_coord)
draw->coords->lut_tex_coord = menu_display_gl_get_default_tex_coords();
glViewport(draw->x, draw->y, draw->width, draw->height);
menu_display_gl_viewport(draw);
glBindTexture(GL_TEXTURE_2D, (GLuint)draw->texture);
coords.handle_data = gl;
@ -164,6 +174,7 @@ static bool menu_display_gl_font_init_first(
menu_display_ctx_driver_t menu_display_ctx_gl = {
menu_display_gl_draw,
menu_display_gl_viewport,
menu_display_gl_blend_begin,
menu_display_gl_blend_end,
menu_display_gl_restore_clear_color,

View File

@ -42,6 +42,11 @@ static void menu_display_null_draw(void *data)
(void)data;
}
static void menu_display_null_viewport(void *data)
{
(void)data;
}
static void menu_display_null_restore_clear_color(void)
{
}
@ -72,6 +77,7 @@ static const float *menu_display_null_get_default_tex_coords(void)
menu_display_ctx_driver_t menu_display_ctx_null = {
menu_display_null_draw,
menu_display_null_viewport,
menu_display_null_blend_begin,
menu_display_null_blend_end,
menu_display_null_restore_clear_color,

View File

@ -61,6 +61,22 @@ static unsigned to_display_pipeline(
return ((type == MENU_DISPLAY_PRIM_TRIANGLESTRIP) << 1) | (blend << 0);
}
static void menu_display_vk_viewport(void *data)
{
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
vk_t *vk = (vk_t*)video_driver_get_ptr(false);
if (!vk || !draw)
return;
vk->vk_vp.x = draw->x;
vk->vk_vp.y = vk->context->swapchain_height - draw->y - draw->height;
vk->vk_vp.width = draw->width;
vk->vk_vp.height = draw->height;
vk->vk_vp.minDepth = 0.0f;
vk->vk_vp.maxDepth = 1.0f;
}
static void menu_display_vk_draw(void *data)
{
unsigned i;
@ -99,12 +115,7 @@ static void menu_display_vk_draw(void *data)
if (!texture)
texture = &vk->display.blank_texture;
vk->vk_vp.x = draw->x;
vk->vk_vp.y = vk->context->swapchain_height - draw->y - draw->height;
vk->vk_vp.width = draw->width;
vk->vk_vp.height = draw->height;
vk->vk_vp.minDepth = 0.0f;
vk->vk_vp.maxDepth = 1.0f;
menu_display_vk_viewport(draw);
vk->tracker.dirty |= VULKAN_DIRTY_DYNAMIC_BIT;
/* Bake interleaved VBO. Kinda ugly, we should probably try to move to
@ -190,6 +201,7 @@ static bool menu_display_vk_font_init_first(
menu_display_ctx_driver_t menu_display_ctx_vulkan = {
menu_display_vk_draw,
menu_display_vk_viewport,
menu_display_vk_blend_begin,
menu_display_vk_blend_end,
menu_display_vk_restore_clear_color,

View File

@ -150,6 +150,7 @@ typedef struct menu_display_ctx_datetime
typedef struct menu_display_ctx_driver
{
void (*draw)(void *data);
void (*viewport)(void *data);
void (*blend_begin)(void);
void (*blend_end)(void);
void (*restore_clear_color)(void);