2 #define _FLAT_INPUT_H 1
6 // A FlatInput is the normal, “classic” case of an input, where everything
7 // comes from a single 2D array with chunky pixels.
8 class FlatInput : public Input {
10 FlatInput(ImageFormat format, MovitPixelFormat pixel_format, GLenum type, unsigned width, unsigned height);
12 virtual std::string effect_type_id() const { return "FlatInput"; }
14 // Create the texture itself. We cannot do this in the constructor,
15 // because we don't necessarily know all the settings (sRGB texture,
16 // mipmap generation) at that point.
19 // TODO: Check that we actually have the required extension.
20 virtual bool can_output_linear_gamma() const {
21 return (image_format.gamma_curve == GAMMA_LINEAR ||
22 image_format.gamma_curve == GAMMA_sRGB);
25 std::string output_fragment_shader();
27 // Uploads the texture if it has changed since last time.
28 void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num);
30 unsigned get_width() const { return width; }
31 unsigned get_height() const { return height; }
32 ColorSpace get_color_space() const { return image_format.color_space; }
33 GammaCurve get_gamma_curve() const { return image_format.gamma_curve; }
35 // Tells the input where to fetch the actual pixel data. Note that if you change
36 // this data, you must either call set_pixel_data() again (using the same pointer
37 // is fine), or invalidate_pixel_data(). Otherwise, the texture won't be re-uploaded
38 // on subsequent frames.
39 void set_pixel_data(const unsigned char *pixel_data)
41 assert(this->type == GL_UNSIGNED_BYTE);
42 this->pixel_data = pixel_data;
43 invalidate_pixel_data();
46 void set_pixel_data(const float *pixel_data)
48 assert(this->type == GL_FLOAT);
49 this->pixel_data = pixel_data;
50 invalidate_pixel_data();
53 void invalidate_pixel_data()
58 void set_pitch(unsigned pitch) {
64 ImageFormat image_format;
65 MovitPixelFormat pixel_format;
67 GLuint pbo, texture_num;
68 bool needs_update, finalized;
69 int output_linear_gamma, needs_mipmaps;
70 unsigned width, height, pitch, bytes_per_pixel;
71 const void *pixel_data;
74 #endif // !defined(_FLAT_INPUT_H)