X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=effect.h;h=196682f3f3f652450dd01aa809d5394064d46da6;hp=3585e2df9a168a0439d7da808471dd0871dee102;hb=3915264bd8fde4d550e47c10a67a2741625b9033;hpb=bfa58911af9e945f3532a2c48306b4e9e293e0f7 diff --git a/effect.h b/effect.h index 3585e2d..196682f 100644 --- a/effect.h +++ b/effect.h @@ -6,6 +6,14 @@ #include +// Can alias on a float[2]. +struct Point2D { + Point2D(float x, float y) + : x(x), y(y) {} + + float x, y; +}; + // Can alias on a float[3]. struct RGBTriplet { RGBTriplet(float r, float g, float b) @@ -14,37 +22,52 @@ struct RGBTriplet { float r, g, b; }; -// Convenience functions that deal with prepending the prefix.. -void set_uniform_float(GLhandleARB glsl_program_num, const std::string &prefix, const std::string &key, float value); -void set_uniform_vec3(GLhandleARB glsl_program_num, const std::string &prefix, const std::string &key, const float *values); +// Convenience functions that deal with prepending the prefix. +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); class Effect { public: - virtual bool needs_linear_light() { return true; } - virtual bool needs_srgb_primaries() { return true; } - virtual bool needs_many_samples() { return false; } - virtual bool needs_mipmaps() { return false; } + virtual bool needs_linear_light() const { return true; } + virtual bool needs_srgb_primaries() const { return true; } + virtual bool needs_many_samples() const { return false; } + virtual bool needs_mipmaps() const { return false; } - virtual std::string output_convenience_uniforms(); - virtual std::string output_glsl() = 0; + virtual std::string output_convenience_uniforms() const; + virtual std::string output_fragment_shader() = 0; - virtual void set_uniforms(GLhandleARB glsl_program_num, const std::string& prefix); + virtual void set_uniforms(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num); // Neither of these take ownership. bool set_int(const std::string&, int value); bool set_float(const std::string &key, float value); + bool set_vec2(const std::string &key, const float *values); bool set_vec3(const std::string &key, const float *values); protected: // Neither of these take ownership. void register_int(const std::string &key, int *value); 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_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_tex_1d; }; #endif // !defined(_EFFECT_H)