X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FMoof%2FTexture.cc;h=8aa66c4f1ec7c64c95b3d35016f4ef1e9068593d;hb=4701bf580b75a7d77a460c6f14f9fc31fb109bbb;hp=128d54f3d7c8750b2087859a22b81aa6c5f18dc6;hpb=29e3d45f7bbbf31eadf793c41ff2b3d9c47b7539;p=chaz%2Fyoink diff --git a/src/Moof/Texture.cc b/src/Moof/Texture.cc index 128d54f..8aa66c4 100644 --- a/src/Moof/Texture.cc +++ b/src/Moof/Texture.cc @@ -51,7 +51,7 @@ namespace Mf { * objects and avoid having duplicate textures loaded to GL. */ -class Texture::TextureImpl : public Mippleton +class Texture::Impl : public Mippleton { /** @@ -78,7 +78,7 @@ class Texture::TextureImpl : public Mippleton * to cache it if the client has plenty of RAM. */ - void contextRecreated(const Notification& note) + void contextRecreated(const Notification* note) { object_ = globalObject_ = 0; uploadToGL(); @@ -129,8 +129,8 @@ public: * Construction is initialization. */ - explicit TextureImpl(const std::string& name) : - Mippleton(name), + explicit Impl(const std::string& name) : + Mippleton(name), surface_(0), width_(0), height_(0), @@ -145,10 +145,10 @@ public: // we want to know when the GL context is recreated Dispatcher::instance().addHandler("video.context_recreated", - boost::bind(&TextureImpl::contextRecreated, this, _1), this); + boost::bind(&Impl::contextRecreated, this, _1), this); } - ~TextureImpl() + ~Impl() { if (surface_) { @@ -239,7 +239,7 @@ public: { SDL_Surface* surface; - surface = IMG_Load(Texture::getPathToResource(getName()).c_str()); + surface = IMG_Load(Texture::getPath(getName()).c_str()); if (!surface) { @@ -383,13 +383,12 @@ public: static GLuint globalObject_; ///< Global GL texture handle. }; -GLuint Texture::TextureImpl::globalObject_ = 0; +GLuint Texture::Impl::globalObject_ = 0; Texture::Texture(const std::string& name) : // pass through - impl_(Texture::TextureImpl::retain(name), &Texture::TextureImpl::release) -{} + impl_(Texture::Impl::retain(name), &Texture::Impl::release) {} /** @@ -414,6 +413,13 @@ GLuint Texture::getObject() const } +void Texture::resetBind() +{ + glBindTexture(GL_TEXTURE_2D, 0); + Impl::globalObject_ = 0; +} + + unsigned Texture::getWidth() const { // pass through @@ -452,10 +458,10 @@ void Texture::setWrapT(GLuint wrap) } -std::string Texture::getPathToResource(const std::string& name) +std::string Texture::getPath(const std::string& name) { - // TODO named resources must be png for now - return Resource::getPathToResource("textures/" + name + ".png"); + std::string path = Resource::getPath("textures/" + name + ".png"); + return path; }