X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect.h;h=c911f276ef71d94a6ab281f6339c87bb702af806;hp=39c612601a36a4e4a9ed9d755c11233d298d2479;hb=2322070a3dbeb6b46b39cca07a0fbf20e95f5468;hpb=b10c546f579c7ccb5939161e61a71cd18a3f9bbd diff --git a/effect.h b/effect.h index 39c6126..c911f27 100644 --- a/effect.h +++ b/effect.h @@ -40,12 +40,21 @@ struct RGBTriplet { float r, g, b; }; +// Can alias on a float[4]. +struct RGBATriplet { + RGBATriplet(float r, float g, float b, float a) + : r(r), g(g), b(b), a(a) {} + + float r, g, b, a; +}; + // Convenience functions that deal with prepending the prefix. GLint get_uniform_location(GLuint glsl_program_num, const std::string &prefix, const std::string &key); void set_uniform_int(GLuint glsl_program_num, const std::string &prefix, const std::string &key, int value); void set_uniform_float(GLuint glsl_program_num, const std::string &prefix, const std::string &key, float value); void set_uniform_vec2(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values); void set_uniform_vec3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values); +void set_uniform_vec4(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values); void set_uniform_vec4_array(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const float *values, size_t num_values); void set_uniform_mat3(GLuint glsl_program_num, const std::string &prefix, const std::string &key, const Eigen::Matrix3d &matrix); @@ -159,11 +168,16 @@ public: virtual bool changes_output_size() const { return false; } // If changes_output_size() is true, you must implement this to tell - // the framework what output size you want. + // the framework what output size you want. Also, you can set a + // virtual width/height, which is the size the next effect (if any) + // will _think_ your data is in. This is primarily useful if you are + // relying on getting OpenGL's bilinear resizing for free; otherwise, + // your virtual_width/virtual_height should be the same as width/height. // // Note that it is explicitly allowed to change width and height // from frame to frame; EffectChain will reallocate textures as needed. - virtual void get_output_size(unsigned *width, unsigned *height) const { + virtual void get_output_size(unsigned *width, unsigned *height, + unsigned *virtual_width, unsigned *virtual_height) const { assert(false); } @@ -226,6 +240,7 @@ public: virtual bool set_float(const std::string &key, float value) MUST_CHECK_RESULT; virtual bool set_vec2(const std::string &key, const float *values) MUST_CHECK_RESULT; virtual bool set_vec3(const std::string &key, const float *values) MUST_CHECK_RESULT; + virtual bool set_vec4(const std::string &key, const float *values) MUST_CHECK_RESULT; protected: // Register a parameter. Whenever set_*() is called with the same key, @@ -238,10 +253,11 @@ protected: // Thus, ints that you register will _not_ be converted to GLSL uniforms. void register_int(const std::string &key, int *value); - // These correspond directly to float/vec2/vec3 in GLSL. + // These correspond directly to float/vec2/vec3/vec4 in GLSL. void register_float(const std::string &key, float *value); void register_vec2(const std::string &key, float *values); 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 @@ -266,6 +282,7 @@ private: std::map params_float; std::map params_vec2; std::map params_vec3; + std::map params_vec4; std::map params_tex_1d; };