From: Steinar H. Gunderson Date: Tue, 14 Jan 2014 21:48:42 +0000 (+0100) Subject: Remove the support for 1D textures as parameters. X-Git-Tag: 1.0~87 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=6602e2b9d5e5a44c0f075fe083ecc26feb10c173 Remove the support for 1D textures as parameters. This isn't required anymore after the Gamma{Compression,Expansion}Effect stopped using it; and after seeing how it was easy to missample them with regards to texture coordinates, I'm not honestly so sure anymore they were a good idea in the first place. --- diff --git a/effect.cpp b/effect.cpp index 483828b..b17c0d6 100644 --- a/effect.cpp +++ b/effect.cpp @@ -83,34 +83,6 @@ void Effect::register_vec4(const std::string &key, float *values) params_vec4[key] = values; } -void Effect::register_1d_texture(const std::string &key, float *values, size_t size) -{ - assert(params_tex_1d.count(key) == 0); - - Texture1D tex; - tex.values = values; - tex.size = size; - tex.needs_update = false; - glGenTextures(1, &tex.texture_num); - - glBindTexture(GL_TEXTURE_1D, tex.texture_num); - check_error(); - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - check_error(); - glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - check_error(); - glTexImage1D(GL_TEXTURE_1D, 0, GL_LUMINANCE16F_ARB, size, 0, GL_LUMINANCE, GL_FLOAT, values); - check_error(); - - params_tex_1d[key] = tex; -} - -void Effect::invalidate_1d_texture(const std::string &key) -{ - assert(params_tex_1d.count(key) != 0); - params_tex_1d[key].needs_update = true; -} - // Output convenience uniforms for each parameter. // These will be filled in per-frame. std::string Effect::output_convenience_uniforms() const @@ -144,13 +116,6 @@ std::string Effect::output_convenience_uniforms() const sprintf(buf, "uniform vec4 PREFIX(%s);\n", it->first.c_str()); output.append(buf); } - for (std::map::const_iterator it = params_tex_1d.begin(); - it != params_tex_1d.end(); - ++it) { - char buf[256]; - sprintf(buf, "uniform sampler1D PREFIX(%s);\n", it->first.c_str()); - output.append(buf); - } return output; } @@ -176,24 +141,6 @@ void Effect::set_gl_state(GLuint glsl_program_num, const std::string& prefix, un ++it) { set_uniform_vec4(glsl_program_num, prefix, it->first, it->second); } - - for (std::map::iterator it = params_tex_1d.begin(); - it != params_tex_1d.end(); - ++it) { - glActiveTexture(GL_TEXTURE0 + *sampler_num); - check_error(); - glBindTexture(GL_TEXTURE_1D, it->second.texture_num); - check_error(); - - if (it->second.needs_update) { - glTexImage1D(GL_TEXTURE_1D, 0, GL_LUMINANCE16F_ARB, it->second.size, 0, GL_LUMINANCE, GL_FLOAT, it->second.values); - check_error(); - it->second.needs_update = false; - } - - set_uniform_int(glsl_program_num, prefix, it->first, *sampler_num); - ++*sampler_num; - } } void Effect::clear_gl_state() {} diff --git a/effect.h b/effect.h index 9d4f247..4f740f3 100644 --- a/effect.h +++ b/effect.h @@ -257,31 +257,12 @@ protected: void register_vec3(const std::string &key, float *values); void register_vec4(const std::string &key, float *values); - // This will register a 1D texture, which will be bound to a sampler - // when your GLSL code runs (so it corresponds 1:1 to a sampler2D uniform - // in GLSL). - // - // Note that if you change the contents of , you will need to - // call invalidate_1d_texture() to have the picture re-uploaded on the - // next frame. This is in contrast to all the other parameters, which are - // set anew every frame. - void register_1d_texture(const std::string &key, float *values, size_t size); - void invalidate_1d_texture(const std::string &key); - private: - struct Texture1D { - float *values; - size_t size; - bool needs_update; - GLuint texture_num; - }; - std::map params_int; std::map params_float; std::map params_vec2; std::map params_vec3; std::map params_vec4; - std::map params_tex_1d; }; #endif // !defined(_MOVIT_EFFECT_H)