]> git.sesse.net Git - movit/blobdiff - flat_input.h
Let FlatInput take in float data (sort of kludgy, though). Also remove the get_*...
[movit] / flat_input.h
index 90c038678f2e429fd775c3770510a0bf4605a9b3..1820eafda24c56248fcaa80b3af73caa7172d507 100644 (file)
@@ -7,7 +7,7 @@
 // comes from a single 2D array with chunky pixels.
 class FlatInput : public Input {
 public:
-       FlatInput(ImageFormat format, MovitPixelFormat pixel_format, unsigned width, unsigned height);
+       FlatInput(ImageFormat format, MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height);
 
        virtual std::string effect_type_id() const { return "FlatInput"; }
 
@@ -38,18 +38,21 @@ public:
        // on subsequent frames.
        void set_pixel_data(const unsigned char *pixel_data)
        {
+               assert(this->type == GL_UNSIGNED_BYTE);
                this->pixel_data = pixel_data;
                invalidate_pixel_data();
        }
 
-       void invalidate_pixel_data()
+       void set_pixel_data(const float *pixel_data)
        {
-               needs_update = true;
+               assert(this->type == GL_FLOAT);
+               this->pixel_data = pixel_data;
+               invalidate_pixel_data();
        }
 
-       const unsigned char *get_pixel_data() const
+       void invalidate_pixel_data()
        {
-               return pixel_data;
+               needs_update = true;
        }
 
        void set_pitch(unsigned pitch) {
@@ -57,19 +60,15 @@ public:
                this->pitch = pitch;
        }
 
-       unsigned get_pitch() {
-               return pitch;
-       }
-
 private:
        ImageFormat image_format;
        MovitPixelFormat pixel_format;
-       GLenum format;
+       GLenum format, type;
        GLuint pbo, texture_num;
        bool needs_update, finalized;
        int output_linear_gamma, needs_mipmaps;
        unsigned width, height, pitch, bytes_per_pixel;
-       const unsigned char *pixel_data;
+       const void *pixel_data;
 };
 
 #endif // !defined(_FLAT_INPUT_H)