/* _______________ ,----------------------------------------------------------------. //`````````````\\ \ \ //~~~~~~~~~~~~~~~\\ \ 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(__EMSCRIPTEN__) #include #else #include "glew/glew.h" #endif #include #include #include #include #include #include "glm/glm.hpp" #include "Attributes.hpp" #include "Texture.hpp" class Model { protected: std::map> model_attributes; std::map model_texture; glm::mat4 model_transformation = glm::mat4(1); 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 std::string&, const sb::Attributes&); void attributes(const std::string&, const std::shared_ptr&); std::shared_ptr& operator[](const std::string&); void enable(); void disable(); sb::Texture& texture(const std::string&); void texture(const std::string&, const sb::Texture&); 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}})) {} }; /* Plane that stores multiple textures which can be cycled through and looped. Only one texture is * active at a time, returned by Background::current. Cycle only goes forward, using Background::next. */ class Background : public Plane { private: std::uint8_t offset = 0; public: void next(); const sb::Texture& current() const; }; class CameraView : public Plane { private: bool swapped = false; public: CameraView(); void generate(const glm::vec2&); sb::Texture& current(); sb::Texture& free(); void swap(); }; #endif