X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fimage_input.h;h=7b712ab13ec9920ac53fcf5a956fb349022b3ec0;hb=adc0df09f7a9dc88a3c0dbad47a21a805e728862;hp=32fd52913a6cf2b930e6866772c0592ab004e89f;hpb=45a94bcaba587f636c1aa40485d02c5619109b20;p=nageru diff --git a/nageru/image_input.h b/nageru/image_input.h index 32fd529..7b712ab 100644 --- a/nageru/image_input.h +++ b/nageru/image_input.h @@ -13,7 +13,7 @@ #include #include -#include "ref_counted_texture.h" +#include "shared/ref_counted_texture.h" #include "tweaked_inputs.h" class QSurface; @@ -23,26 +23,35 @@ class QSurface; // from disk about every second. class ImageInput : public sRGBSwitchingFlatInput { public: + // For loading images. // NOTE: You will need to call start_update_thread() yourself, once per program. + struct Image { + unsigned width, height; + UniqueTexture tex; + timespec last_modified; + }; + static std::shared_ptr load_image(const std::string &filename, const std::string &pathname); + + // Actual members. + + ImageInput(); // Construct an empty input, which can't be used until you call switch_image(). ImageInput(const std::string &filename); std::string effect_type_id() const override { return "ImageInput"; } void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) override; + // Switch to a different image. The image must be previously loaded using load_image(). + void switch_image(const std::string &pathname); + + std::string get_pathname() const { return pathname; } + static void start_update_thread(QSurface *surface); static void end_update_thread(); private: - struct Image { - unsigned width, height; - RefCountedTexture tex; - timespec last_modified; - }; - std::string pathname; std::shared_ptr current_image; - static std::shared_ptr load_image(const std::string &filename, const std::string &pathname); static std::shared_ptr load_image_raw(const std::string &pathname); static void update_thread_func(QSurface *surface); static std::mutex all_images_lock;