Add cb_set_shader_mvp

This commit is contained in:
twinaphex 2017-05-19 19:52:33 +02:00
parent 64fdadf60f
commit d8f5065d64
3 changed files with 14 additions and 17 deletions

View File

@ -217,7 +217,6 @@ static void gl_overlay_tex_geom(void *data,
static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info)
{
video_shader_ctx_mvp_t mvp;
video_shader_ctx_coords_t coords;
unsigned i;
unsigned width = video_info->width;
@ -245,10 +244,7 @@ static void gl_render_overlay(gl_t *gl, video_frame_info_t *video_info)
video_shader_driver_set_coords(coords);
mvp.data = gl;
mvp.matrix = &gl->mvp_no_rot;
video_shader_driver_set_mvp(mvp);
video_info->cb_shader_set_mvp(gl, video_info->shader_data, &gl->mvp_no_rot);
for (i = 0; i < gl->overlays; i++)
{
@ -1001,7 +997,6 @@ static void gl_pbo_async_readback(gl_t *gl)
static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
{
video_shader_ctx_mvp_t mvp;
video_shader_ctx_coords_t coords;
GLfloat color[16];
unsigned width = video_info->width;
@ -1041,10 +1036,7 @@ static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info)
video_shader_driver_set_coords(coords);
mvp.data = gl;
mvp.matrix = &gl->mvp_no_rot;
video_shader_driver_set_mvp(mvp);
video_info->cb_shader_set_mvp(gl, video_info->shader_data, &gl->mvp_no_rot);
glEnable(GL_BLEND);
@ -1072,7 +1064,6 @@ static bool gl_frame(void *data, const void *frame,
unsigned pitch, const char *msg,
video_frame_info_t *video_info)
{
video_shader_ctx_mvp_t mvp;
video_shader_ctx_coords_t coords;
video_shader_ctx_params_t params;
struct video_tex_info feedback_info;
@ -1230,10 +1221,7 @@ static bool gl_frame(void *data, const void *frame,
video_shader_driver_set_coords(coords);
mvp.data = gl;
mvp.matrix = &gl->mvp;
video_shader_driver_set_mvp(mvp);
video_info->cb_shader_set_mvp(gl, video_info->shader_data, &gl->mvp);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

View File

@ -121,7 +121,8 @@ typedef struct video_pixel_scaler
void *scaler_out;
} video_pixel_scaler_t;
void (*video_driver_cb_shader_use)(void *data, void *shader_data, unsigned index, bool set_active);
static void (*video_driver_cb_shader_use)(void *data, void *shader_data, unsigned index, bool set_active);
static bool (*video_driver_cb_shader_set_mvp)(void *data, void *shader_data, const math_matrix_4x4 *mat);
/* Opaque handles to currently running window.
* Used by e.g. input drivers which bind to a window.
@ -2515,6 +2516,7 @@ void video_driver_build_info(video_frame_info_t *video_info)
video_info->cb_set_resize = current_video_context.set_resize;
video_info->cb_shader_use = video_driver_cb_shader_use;
video_info->cb_shader_set_mvp = video_driver_cb_shader_set_mvp;
#ifdef HAVE_THREADS
video_driver_threaded_unlock(is_threaded);
@ -3188,8 +3190,13 @@ static void video_shader_driver_reset_to_defaults(void)
{
if (!current_shader->wrap_type)
current_shader->wrap_type = video_shader_driver_wrap_type_null;
if (!current_shader->set_mvp)
if (current_shader->set_mvp)
video_driver_cb_shader_set_mvp = current_shader->set_mvp;
else
{
current_shader->set_mvp = video_shader_driver_set_mvp_null;
video_driver_cb_shader_set_mvp = video_shader_driver_set_mvp_null;
}
if (!current_shader->set_coords)
current_shader->set_coords = video_shader_driver_set_coords_null;
if (current_shader->use)

View File

@ -451,6 +451,8 @@ typedef struct video_frame_info
bool (*cb_set_resize)(void*, unsigned, unsigned);
void (*cb_shader_use)(void *data, void *shader_data, unsigned index, bool set_active);
bool (*cb_shader_set_mvp)(void *data, void *shader_data,
const math_matrix_4x4 *mat);
void *context_data;
void *shader_data;