1 #pragma once 2 3 #include "solarus/core/Rectangle.h" 4 #include "solarus/core/Point.h" 5 #include "solarus/graphics/SDLPtrs.h" 6 #include "solarus/graphics/SurfaceImpl.h" 7 #include "solarus/graphics/glrenderer/GlRenderer.h" 8 9 #include <memory> 10 11 namespace Solarus { 12 13 /** 14 * @brief Abstract class for internal surface pixel representation and manipulation 15 */ 16 class GlTexture : public SurfaceImpl 17 { 18 friend class GlRenderer; 19 public: 20 GlTexture(int width, int height, bool screen_tex = false); 21 GlTexture(SDL_Surface_UniquePtr surface); 22 23 GLuint get_texture() const; 24 SDL_Surface* get_surface() const override; 25 26 GlTexture& targetable(); 27 28 int get_width() const override; 29 int get_height() const override; 30 31 /** 32 * @brief upload potentially modified surface 33 * 34 * When modifying pixels of the Surface, we have 35 * to upload it to the texture for changes to be reflected 36 */ 37 void upload_surface() override; 38 private: 39 bool target = false; 40 void release() const; 41 void set_texture_params(); 42 glm::mat3 uv_transform; 43 mutable bool surface_dirty = true; 44 GLuint tex_id = 0; 45 GlRenderer::Fbo* fbo = nullptr; 46 mutable SDL_Surface_UniquePtr surface = nullptr; 47 }; 48 49 } 50