X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FMoof%2FTexture.cc;h=3ca067af4ebe72dcc6552b92b3aa2c1aab09f07a;hb=90b2c7fb10b244b781b84965a0d36f1f323ee94d;hp=48e6e1b6193909766df411c85757ab6393201a41;hpb=837bae9f2bf7b25e1d3d2625eeaf39c1d2f48827;p=chaz%2Fyoink diff --git a/src/Moof/Texture.cc b/src/Moof/Texture.cc index 48e6e1b..3ca067a 100644 --- a/src/Moof/Texture.cc +++ b/src/Moof/Texture.cc @@ -121,12 +121,13 @@ public: mObject(0) { // make sure we have a video context - ASSERT(video && - "cannot load textures without a current video context"); + Video* video = Video::current(); + ASSERT(video && "should have a video context set"); // we want to know when the GL context is recreated - mDispatchHandler = core.addHandler("video.newcontext", - boost::bind(&Impl::contextRecreated, this)); + Dispatch& dispatch = Dispatch::global(); + mNewContextDispatch = dispatch.addTarget("video.newcontext", + boost::bind(&Impl::contextRecreated, this)); } ~Impl() @@ -214,7 +215,9 @@ public: void init(const std::string& name) { - std::string path = Texture::getPath(name); + std::string path(name); + + Texture::getPath(path); mImage = Image::alloc(path); if (!mImage->isValid()) @@ -388,14 +391,14 @@ public: GLuint mObject; ///< GL texture handle. static GLuint gObject; ///< Global GL texture handle. - Dispatch::Handler mDispatchHandler; + Dispatch::Handle mNewContextDispatch; }; GLuint Texture::Impl::gObject = 0; -Texture::Texture(const std::string& name) : - Image(Texture::getPath(name)), +Texture::Texture(const std::string& name) : // TODO hmm.. + Image(name), // pass through mImpl(Texture::Impl::getInstance(name)) {} @@ -489,19 +492,9 @@ bool Texture::getTileCoords(TileIndex index, Scalar coords[8], } -std::string Texture::getPath(const std::string& name) +bool Texture::getPath(std::string& name) { - if (boost::find_last(name, ".png")) - { - return Resource::getPath(name); - } - else - { - std::string path("textures/"); - path += name; - path += ".png"; - return Resource::getPath(path); - } + return Resource::getPath(name, "textures/", "png"); }