* Image-loading and OpenGL texture loading.
*/
-#include <stdexcept>
-
#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
{
public:
- Texture(const std::string& name);
+
+ static TextureP alloc(const std::string& name)
+ {
+ return TextureP(new Texture(name));
+ }
+
+ explicit Texture(const std::string& name);
void bind() const;
GLuint getObject() const;
static std::string getPath(const std::string& name);
- struct Exception : public Mf::Exception
- {
- 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 "inappropriate image format";
- }
- return Mf::Exception::what();
- }
- };
-
private:
+
class Impl;
- boost::shared_ptr<Impl> impl_;
+ boost::shared_ptr<Impl> mImpl;
};