diff options
author | wm4 <wm4@nowhere> | 2015-09-10 20:52:50 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-09-10 20:52:50 +0200 |
commit | e2139488ff79c667e32b1eaf9984c5342eae0132 (patch) | |
tree | e07046c7426c8d7329ec519b97e66a79a93c7876 /video | |
parent | f1205293a70b13f53bfce0a1a9859132b8421443 (diff) |
vo_opengl: move sampler type mapping to a function
Diffstat (limited to 'video')
-rw-r--r-- | video/out/opengl/utils.c | 19 | ||||
-rw-r--r-- | video/out/opengl/utils.h | 2 |
2 files changed, 14 insertions, 7 deletions
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); |