Add SHADER_CTL_DEINIT

This commit is contained in:
twinaphex 2016-02-14 18:22:38 +01:00
parent 7c4b372208
commit 678cabc48c
3 changed files with 12 additions and 15 deletions

View File

@ -307,7 +307,7 @@ static bool gl_shader_init(gl_t *gl)
static void gl_shader_deinit(gl_t *gl)
{
video_shader_driver_deinit();
video_shader_driver_ctl(SHADER_CTL_DEINIT, NULL);
}
#ifndef NO_GL_FF_VERTEX

View File

@ -99,18 +99,6 @@ bool video_shader_driver_init(const shader_backend_t *shader,
return true;
}
void video_shader_driver_deinit(void)
{
if (!current_shader)
return;
if (current_shader->deinit)
current_shader->deinit(shader_data);
shader_data = NULL;
current_shader = NULL;
}
void video_shader_driver_use(void *data, unsigned index)
{
if (!current_shader)
@ -183,6 +171,16 @@ bool video_shader_driver_ctl(enum video_shader_driver_ctl_state state, void *dat
{
switch (state)
{
case SHADER_CTL_DEINIT:
if (!current_shader)
return false;
if (current_shader->deinit)
current_shader->deinit(shader_data);
shader_data = NULL;
current_shader = NULL;
break;
case SHADER_CTL_SET_PARAMS:
{
video_shader_ctx_params_t *params = (video_shader_ctx_params_t*)data;

View File

@ -33,6 +33,7 @@ extern "C" {
enum video_shader_driver_ctl_state
{
SHADER_CTL_NONE = 0,
SHADER_CTL_DEINIT,
/* Finds first suitable shader context driver. */
SHADER_CTL_INIT_FIRST,
SHADER_CTL_SET_PARAMS,
@ -138,8 +139,6 @@ struct video_shader *video_shader_driver_get_current_shader(void);
bool video_shader_driver_init(const shader_backend_t *shader,
void *data, const char *path);
void video_shader_driver_deinit(void);
void video_shader_driver_use(void *data, unsigned index);
const char *video_shader_driver_get_ident(void);