X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FTexture.hh;h=5aa38e1dc85e04ea70aa5f910c6c91992b688a0f;hp=d2b2359f0eb4e28d09194cac40816e66dd0536a0;hb=a31d65a998121df0651c57bfb68782e2a07d2e2f;hpb=29e3d45f7bbbf31eadf793c41ff2b3d9c47b7539 diff --git a/src/Moof/Texture.hh b/src/Moof/Texture.hh index d2b2359..5aa38e1 100644 --- a/src/Moof/Texture.hh +++ b/src/Moof/Texture.hh @@ -38,6 +38,7 @@ #include +#include #include #include @@ -45,14 +46,29 @@ namespace Mf { +class Texture; +typedef boost::shared_ptr TextureP; + + class Texture : public Resource { + class Impl; + boost::shared_ptr mImpl; + public: + + static TextureP alloc(const std::string& name) + { + return TextureP(new Texture(name)); + } + Texture(const std::string& name); void bind() const; GLuint getObject() const; + static void resetBind(); + unsigned getWidth() const; unsigned getHeight() const; @@ -61,17 +77,34 @@ public: void setWrapS(GLuint wrap); void setWrapT(GLuint wrap); - static std::string getPathToResource(const std::string& name); + static std::string getPath(const std::string& name); - struct Exception : std::runtime_error + + struct Exception : public Mf::Exception { - explicit Exception(const std::string& what_arg) : - std::runtime_error(what_arg) {} + enum + { + BAD_IMAGE_FORMAT = 1024 + }; + + explicit Exception(unsigned error) : + Mf::Exception(error) {} + + void raise() + { + throw *this; + } + + const char* what() const throw() + { + switch (code) + { + case BAD_IMAGE_FORMAT: + return "unknown image format"; + } + return Mf::Exception::what(); + } }; - -private: - class TextureImpl; - boost::shared_ptr impl_; };