diff --git a/video/out/opengl/utils.c b/video/out/opengl/utils.c index d63d3a04d0..b5d33b15c3 100644 --- a/video/out/opengl/utils.c +++ b/video/out/opengl/utils.c @@ -629,19 +629,24 @@ static struct sc_uniform *find_uniform(struct gl_shader_cache *sc, return new; } +const char* mp_sampler_type(GLenum texture_target) +{ + switch (texture_target) { + case GL_TEXTURE_1D: return "sampler1D"; + case GL_TEXTURE_2D: return "sampler2D"; + case GL_TEXTURE_RECTANGLE: return "sampler2DRect"; + case GL_TEXTURE_3D: return "sampler3D"; + default: abort(); + } +} + void gl_sc_uniform_sampler(struct gl_shader_cache *sc, char *name, GLenum target, int unit) { struct sc_uniform *u = find_uniform(sc, name); u->type = UT_i; u->size = 1; - switch (target) { - case GL_TEXTURE_1D: u->glsl_type = "sampler1D"; break; - case GL_TEXTURE_2D: u->glsl_type = "sampler2D"; break; - case GL_TEXTURE_RECTANGLE: u->glsl_type = "sampler2DRect"; break; - case GL_TEXTURE_3D: u->glsl_type = "sampler3D"; break; - default: abort(); - } + u->glsl_type = mp_sampler_type(target); u->v.i[0] = unit; } diff --git a/video/out/opengl/utils.h b/video/out/opengl/utils.h index f560354bb9..75cedd6efe 100644 --- a/video/out/opengl/utils.h +++ b/video/out/opengl/utils.h @@ -39,6 +39,8 @@ void glClearTex(GL *gl, GLenum target, GLenum format, GLenum type, mp_image_t *glGetWindowScreenshot(GL *gl); +const char* mp_sampler_type(GLenum texture_target); + // print a multi line string with line numbers (e.g. for shader sources) // log, lev: module and log level, as in mp_msg() void mp_log_source(struct mp_log *log, int lev, const char *src);