]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Texture.cc
better logging (maybe) and exception handling
[chaz/yoink] / src / Moof / Texture.cc
index e8f5d86d1f2e65fd85d413c5b93b26bfcedc6ac3..b778c1ccde0299b1e306d33724457728c563d65a 100644 (file)
@@ -34,6 +34,7 @@
 #include <SDL/SDL_image.h>
 
 #include "Dispatcher.hh"
+#include "Log.hh"
 #include "Mippleton.hh"
 #include "OpenGL.hh"
 #include "Texture.hh"
@@ -78,7 +79,7 @@ class Texture::Impl : public Mippleton<Impl>
         * to cache it if the client has plenty of RAM.
         */
 
-       void contextRecreated(const Notification& note)
+       void contextRecreated(const Notification* note)
        {
                object_ = globalObject_ = 0;
                uploadToGL();
@@ -144,7 +145,7 @@ public:
                loadFromFile();
 
                // we want to know when the GL context is recreated
-               Dispatcher::instance().addHandler("video.context_recreated",
+               Dispatcher::getInstance().addHandler("video.context_recreated",
                                boost::bind(&Impl::contextRecreated, this, _1), this);
        }
 
@@ -157,7 +158,7 @@ public:
 
                unloadFromGL();
 
-               Dispatcher::instance().removeHandler(this);
+               Dispatcher::getInstance().removeHandler(this);
        }
 
 
@@ -243,7 +244,8 @@ public:
 
                if (!surface)
                {
-                       throw Texture::Exception("loading from file failed");
+                       logWarning("texture not found: %s", getName().c_str());
+                       throw Exception(Exception::FILE_NOT_FOUND);
                }
 
                SDL_Surface* temp = prepareImageForGL(surface);
@@ -251,7 +253,7 @@ public:
 
                if (!temp)
                {
-                       throw Texture::Exception("uploading to opengl failed");
+                       throw Exception(Exception::OPENGL_ERROR);
                }
 
                if (temp->format->BytesPerPixel == 3)
@@ -265,7 +267,7 @@ public:
                else
                {
                        SDL_FreeSurface(temp);
-                       throw Texture::Exception("incompatible color mode");
+                       throw Exception(Exception::BAD_IMAGE_FORMAT);
                }
 
                width_ = temp->w;
@@ -388,7 +390,7 @@ GLuint Texture::Impl::globalObject_ = 0;
 
 Texture::Texture(const std::string& name) :
        // pass through
-       impl_(Texture::Impl::retain(name), &Texture::Impl::release) {}
+       impl_(Texture::Impl::getInstance(name)) {}
 
 
 /**
This page took 0.019103 seconds and 4 git commands to generate.