]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Texture.hh
minor refactoring and state progress
[chaz/yoink] / src / Moof / Texture.hh
index e858093e1a44afa06b44d50dcc5eac80503855e7..5aa38e1dc85e04ea70aa5f910c6c91992b688a0f 100644 (file)
 
 #include <boost/shared_ptr.hpp>
 
-#include <Moof/Resource.hh>
+#include <Moof/Exception.hh>
 #include <Moof/OpenGL.hh>
+#include <Moof/Resource.hh>
 
 
 namespace Mf {
 
 
+class Texture;
+typedef boost::shared_ptr<Texture> TextureP;
+
+
 class Texture : public Resource
 {
+       class Impl;
+       boost::shared_ptr<Impl> mImpl;
+
 public:
+
+       static TextureP alloc(const std::string& name)
+       {
+               return TextureP(new Texture(name));
+       }
+
        Texture(const std::string& name);
 
-       void bind();
-       GLuint getObject();
+       void bind() const;
+       GLuint getObject() const;
 
-       unsigned getWidth();
-       unsigned getHeight();
+       static void resetBind();
+
+       unsigned getWidth() const;
+       unsigned getHeight() const;
 
        void setMinFilter(GLuint filter);
-       void setMaxFilter(GLuint filter);
-       void setWrapU(GLuint wrap);
-       void setWrapV(GLuint wrap);
+       void setMagFilter(GLuint filter);
+       void setWrapS(GLuint wrap);
+       void setWrapT(GLuint wrap);
 
-       void applyChanges();
+       static std::string getPath(const std::string& name);
 
-       static std::string getPathToResource(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<TextureImpl> impl_;
 };
 
 
This page took 0.018608 seconds and 4 git commands to generate.