]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Texture.cc
better logging (maybe) and exception handling
[chaz/yoink] / src / Moof / Texture.cc
index 46dbb480afc3fc179f06b2db8192ac5b421c0735..b778c1ccde0299b1e306d33724457728c563d65a 100644 (file)
 #include <SDL/SDL_image.h>
 
 #include "Dispatcher.hh"
+#include "Log.hh"
 #include "Mippleton.hh"
 #include "OpenGL.hh"
 #include "Texture.hh"
 
-#include <iostream>
 
 namespace Mf {
 
@@ -81,7 +81,6 @@ class Texture::Impl : public Mippleton<Impl>
 
        void contextRecreated(const Notification* note)
        {
-               std::cout << "context recrated!" << std::endl;
                object_ = globalObject_ = 0;
                uploadToGL();
        }
@@ -245,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);
@@ -253,7 +253,7 @@ public:
 
                if (!temp)
                {
-                       throw Texture::Exception("uploading to opengl failed");
+                       throw Exception(Exception::OPENGL_ERROR);
                }
 
                if (temp->format->BytesPerPixel == 3)
@@ -267,7 +267,7 @@ public:
                else
                {
                        SDL_FreeSurface(temp);
-                       throw Texture::Exception("incompatible color mode");
+                       throw Exception(Exception::BAD_IMAGE_FORMAT);
                }
 
                width_ = temp->w;
@@ -390,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.01912 seconds and 4 git commands to generate.