X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FMoof%2FTexture.cc;h=46dbb480afc3fc179f06b2db8192ac5b421c0735;hb=a5f0d391406a68275b41448fc3f49e8d8396c497;hp=dc9407afc9da1af082ed577da1ab99a6b27bc1e6;hpb=72d4af22710317acffab861421c4364b1780b6fe;p=chaz%2Fyoink diff --git a/src/Moof/Texture.cc b/src/Moof/Texture.cc index dc9407a..46dbb48 100644 --- a/src/Moof/Texture.cc +++ b/src/Moof/Texture.cc @@ -38,6 +38,7 @@ #include "OpenGL.hh" #include "Texture.hh" +#include namespace Mf { @@ -51,7 +52,7 @@ namespace Mf { * objects and avoid having duplicate textures loaded to GL. */ -class Texture::TextureImpl : public Mippleton +class Texture::Impl : public Mippleton { /** @@ -78,8 +79,9 @@ 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) { + std::cout << "context recrated!" << std::endl; object_ = globalObject_ = 0; uploadToGL(); } @@ -129,8 +131,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), @@ -144,11 +146,11 @@ public: loadFromFile(); // we want to know when the GL context is recreated - Dispatcher::instance().addHandler("video.context_recreated", - boost::bind(&TextureImpl::contextRecreated, this, _1), this); + Dispatcher::getInstance().addHandler("video.context_recreated", + boost::bind(&Impl::contextRecreated, this, _1), this); } - ~TextureImpl() + ~Impl() { if (surface_) { @@ -157,7 +159,7 @@ public: unloadFromGL(); - Dispatcher::instance().removeHandler(this); + Dispatcher::getInstance().removeHandler(this); } @@ -239,7 +241,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 +385,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) {} /** @@ -417,7 +418,7 @@ GLuint Texture::getObject() const void Texture::resetBind() { glBindTexture(GL_TEXTURE_2D, 0); - TextureImpl::globalObject_ = 0; + Impl::globalObject_ = 0; } @@ -459,10 +460,10 @@ void Texture::setWrapT(GLuint wrap) } -std::string Texture::getPathToResource(const std::string& name) +std::string Texture::getPath(const std::string& name) { - // TODO named texture resources must be png for now - return Resource::getPathToResource("textures/" + name + ".png"); + std::string path = Resource::getPath("textures/" + name + ".png"); + return path; }