From 619acbb5aa579d653cecc5ae5cbda12b367833b0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 15 Nov 2017 14:16:06 +0100 Subject: [PATCH] Start implementing video_driver_set_mvp properly --- gfx/drivers/gl.c | 22 ++++++++++++++++++++-- gfx/video_driver.c | 10 +++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index a4e434db7b..6dced6ce3a 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2528,9 +2528,27 @@ static void gl_unload_texture(void *data, uintptr_t id) glDeleteTextures(1, &glid); } +static void gl_set_coords(void *handle_data, void *shader_data, + const struct video_coords *coords) +{ + gl_t *gl = (gl_t*)handle_data; + if (gl && gl->renderchain_driver->set_coords) + gl->renderchain_driver->set_coords(handle_data, + shader_data, coords); +} + +static void gl_set_mvp(void *data, void *shader_data, + const void *mat_data) +{ + gl_t *gl = (gl_t*)data; + if (gl && gl->renderchain_driver->set_mvp) + gl->renderchain_driver->set_mvp(data, + shader_data, mat_data); +} + static const video_poke_interface_t gl_poke_interface = { - NULL, /* set_coords */ - NULL, /* set_mvp */ + gl_set_coords, + gl_set_mvp, gl_load_texture, gl_unload_texture, gl_set_video_mode, diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 6a4fa06312..92a210e323 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -3453,8 +3453,16 @@ void video_driver_set_coords(video_shader_ctx_coords_t *coords) void video_driver_set_mvp(video_shader_ctx_mvp_t *mvp) { - if (mvp->matrix && current_shader && current_shader->set_mvp) + if (!mvp || !mvp->matrix) + return; + + if (current_shader && current_shader->set_mvp) current_shader->set_mvp(mvp->data, shader_data, mvp->matrix); + else + { + if (video_driver_poke && video_driver_poke->set_mvp) + video_driver_poke->set_mvp(mvp->data, shader_data, mvp->matrix); + } } bool renderchain_d3d_init_first(