/* _______________ ,----------------------------------------------------------------. //`````````````\\ \ \ //~~~~~~~~~~~~~~~\\ \ by @ohsqueezy & @sleepin \ //=================\\ \ [ohsqueezy.itch.io] [sleepin.itch.io] \ // \\ \ \ // \\ \ code released under the zlib license [git.nugget.fun/pudding] \ // ☆ GUNKISS ☆ \\ \ \ //_________________________\\ `---------------------------------------------------------------*/ #ifndef MODEL_H_ #define MODEL_H_ /* GL functions */ #if defined(__ANDROID__) || defined(ANDROID) #include #include #else #include "glew/glew.h" #endif #include #include #include #include #include #include "glm/glm.hpp" #include "Attributes.hpp" #include "Texture.hpp" class Model { private: inline static const std::string DEFAULT_TEXTURE_NAME = "default"; std::map model_textures; std::map> model_attributes; glm::mat4 model_transformation {1.0f}; public: Model(); Model(const std::map>&); Model(const std::map&); Model(const std::initializer_list&); std::map>& attributes(); std::shared_ptr& attributes(const std::string&); void attributes(const sb::Attributes&, const std::string&); void attributes(const std::shared_ptr&, const std::string&); std::shared_ptr& operator[](const std::string&); void enable(); void disable(); std::map& textures(); sb::Texture& texture(const std::string&); sb::Texture& texture(); void texture(const sb::Texture&, const std::string&); void texture(const sb::Texture&); const glm::mat4& transformation() const; void transformation(const glm::mat4&); std::size_t size(); operator glm::mat4() const; }; class Plane : public Model { public: inline const static std::shared_ptr position = std::make_shared(sb::Attributes{ {-1.0f, 1.0f}, {1.0f, 1.0f}, {-1.0f, -1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}, {-1.0f, -1.0f} }); inline const static std::shared_ptr uv = std::make_shared(sb::Attributes{ {0.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}, {1.0f, 1.0f}, {1.0f, 0.0f}, {0.0f, 0.0f} }); Plane() : Model(std::map>({{"position", position}, {"uv", uv}})) {} }; /*! * A version of `Plane` which contains two texture objects, one of which is active at a time. A reference * to the active `sb::Texture` object is available from `PlaneDoubleBuffer.active`, and the inactive object is * available from `PlaneDoubleBuffer.inactive`. The buffers can be swapped using `PlaneDoubleBuffer.swap`. */ class PlaneDoubleBuffer : public Plane { private: bool swapped = false; public: PlaneDoubleBuffer(); void generate(const glm::vec2&); sb::Texture& active(); sb::Texture& inactive(); void swap(); }; #endif