* Image-loading and OpenGL texture loading.
*/
-#include <stdexcept>
-
#include <boost/shared_ptr.hpp>
-#include <Moof/Resource.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);
- void bind();
- GLuint getObject();
+ static TextureP alloc(const std::string& name)
+ {
+ return TextureP(new Texture(name));
+ }
- unsigned getWidth();
- unsigned getHeight();
+ explicit Texture(const std::string& name);
- void setMinFilter(GLuint filter);
- void setMaxFilter(GLuint filter);
- void setWrapU(GLuint wrap);
- void setWrapV(GLuint wrap);
+ void bind() const;
+ GLuint getObject() const;
- void applyChanges();
+ static void resetBind();
- static std::string getPathToResource(const std::string& name);
+ unsigned getWidth() const;
+ unsigned getHeight() const;
- struct Exception : std::runtime_error
- {
- explicit Exception(const std::string& what_arg) :
- std::runtime_error(what_arg) {}
- };
+ void setMinFilter(GLuint filter);
+ void setMagFilter(GLuint filter);
+ void setWrapS(GLuint wrap);
+ void setWrapT(GLuint wrap);
+
+ static std::string getPath(const std::string& name);
private:
- class TextureImpl;
- boost::shared_ptr<TextureImpl> impl_;
+
+ class Impl;
+ boost::shared_ptr<Impl> mImpl;
};