]> git.sesse.net Git - movit/blobdiff - effect.h
Kill the vertex shader system; it is too complicated to get it right until we have...
[movit] / effect.h
index c53a1556b28e500396387344f2dd6fd8aab28d27..1478c6e474a14ea9c42b6b603fdcc08bbdc80d36 100644 (file)
--- a/effect.h
+++ b/effect.h
@@ -4,6 +4,16 @@
 #include <map>
 #include <string>
 
+#include <GL/gl.h>
+
+// 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)
@@ -12,6 +22,11 @@ struct RGBTriplet {
        float r, g, b;
 };
 
+// Convenience functions that deal with prepending the prefix.
+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; }
@@ -20,22 +35,27 @@ public:
        virtual bool needs_mipmaps() { return false; }
 
        virtual std::string output_convenience_uniforms();
-       virtual std::string output_glsl() = 0;
+       virtual std::string output_fragment_shader() = 0;
+
+       virtual void set_uniforms(GLuint glsl_program_num, const std::string& prefix);
 
        // 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);
        
 private:
        std::map<std::string, int *> params_int;
        std::map<std::string, float *> params_float;
+       std::map<std::string, float *> params_vec2;
        std::map<std::string, float *> params_vec3;
 };