mirror of
https://github.com/mpv-player/mpv
synced 2024-12-18 04:45:33 +00:00
vo_opengl: move sampler type mapping to a function
This commit is contained in:
parent
f1205293a7
commit
e2139488ff
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user