#include <boost/shared_ptr.hpp>
+#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> impl_;
+
public:
+
+ static TextureP alloc(const std::string& name)
+ {
+ return TextureP(new Texture(name));
+ }
+
Texture(const std::string& name);
void bind() const;
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<TextureImpl> impl_;
};