]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Texture.cc
extreme refactoring
[chaz/yoink] / src / Moof / Texture.cc
similarity index 83%
rename from src/texture.cc
rename to src/Moof/Texture.cc
index 6d3e912925b8f1376018b9cc612fde8db1d4677a..44a0b423719d6dfbb10c1be2ae98630a97c6e05c 100644 (file)
 #include <SDL/SDL.h>
 #include <SDL/SDL_image.h>
 
-#include "mippleton.hh"
+#include "Dispatcher.hh"
+#include "Mippleton.hh"
+#include "OpenGL.hh"
+#include "Texture.hh"
 
-#include "dispatcher.hh"
-#include "opengl.hh"
 
-#include "texture.hh"
-
-
-namespace dc {
+namespace Mf {
 
 
 /**
@@ -53,7 +51,7 @@ namespace dc {
  * objects and avoid having duplicate textures loaded to GL.
  */
 
-class texture::texture_impl : public mippleton<texture_impl>
+class Texture::TextureImpl : public Mippleton<TextureImpl>
 {
 
        /**
@@ -75,7 +73,7 @@ class texture::texture_impl : public mippleton<texture_impl>
         * smart enough to cache it if the client has plenty of RAM.
         */
 
-       void contextRecreated(const notification& note)
+       void contextRecreated(const Notification& note)
        {
                unloadFromGL();
                uploadToGL();
@@ -103,8 +101,8 @@ public:
         * Construction is initialization.
         */
 
-       explicit texture_impl(const std::string& name) :
-               mippleton<texture_impl>(name),
+       explicit TextureImpl(const std::string& name) :
+               Mippleton<TextureImpl>(name),
                width_(0),
                height_(0),
                mode_(0),
@@ -117,15 +115,15 @@ public:
                uploadToGL();
 
                // we want to know when the GL context is recreated
-               dispatcher::instance().addHandler("video.context_recreated",
-                               boost::bind(&texture_impl::contextRecreated, this, _1), this);
+               Dispatcher::instance().addHandler("video.context_recreated",
+                               boost::bind(&TextureImpl::contextRecreated, this, _1), this);
        }
 
-       ~texture_impl()
+       ~TextureImpl()
        {
                unloadFromGL();
 
-               dispatcher::instance().removeHandler(this);
+               Dispatcher::instance().removeHandler(this);
        }
 
 
@@ -223,11 +221,11 @@ public:
        {
                SDL_Surface* surface;
 
-               surface = IMG_Load(texture::getPathToResource(getName()).c_str());
+               surface = IMG_Load(Texture::getPathToResource(getName()).c_str());
 
                if (!surface)
                {
-                       throw texture::exception("loading failed");
+                       throw Texture::Exception("loading failed");
                }
 
                SDL_Surface* temp = prepareImageForGL(surface);
@@ -235,7 +233,7 @@ public:
 
                if (!temp)
                {
-                       throw texture::exception("image couldn't be prepared for GL");
+                       throw Texture::Exception("image couldn't be prepared for GL");
                }
 
                if (temp->format->BytesPerPixel == 3)
@@ -249,7 +247,7 @@ public:
                else
                {
                        SDL_FreeSurface(temp);
-                       throw texture::exception("image is not the required 24 or 32 bpp");
+                       throw Texture::Exception("image is not the required 24 or 32 bpp");
                }
 
                width_ = temp->w;
@@ -322,9 +320,9 @@ public:
 };
 
 
-texture::texture(const std::string& name) :
+Texture::Texture(const std::string& name) :
        // pass through
-       impl(texture::texture_impl::retain(name), &texture::texture_impl::release)
+       impl_(Texture::TextureImpl::retain(name), &Texture::TextureImpl::release)
 {}
 
 
@@ -332,7 +330,7 @@ texture::texture(const std::string& name) :
  * Bind the GL texture for mapping, etc.
  */
 
-void texture::bind()
+void Texture::bind()
 {
        glBindTexture(GL_TEXTURE_2D, getObject());
 }
@@ -342,63 +340,63 @@ void texture::bind()
  * Get the texture object, for the curious.
  */
 
-GLuint texture::getObject()
+GLuint Texture::getObject()
 {
        // pass through
-       return impl->object_;
+       return impl_->object_;
 }
 
 
-unsigned texture::getWidth()
+unsigned Texture::getWidth()
 {
        // pass through
-       return impl->width_;
+       return impl_->width_;
 }
 
-unsigned texture::getHeight()
+unsigned Texture::getHeight()
 {
        // pass through
-       return impl->height_;
+       return impl_->height_;
 }
 
 
-void texture::setMinFilter(GLuint filter)
+void Texture::setMinFilter(GLuint filter)
 {
-       impl->minFilter_ = filter;
+       impl_->minFilter_ = filter;
 }
 
-void texture::setMaxFilter(GLuint filter)
+void Texture::setMaxFilter(GLuint filter)
 {
-       impl->maxFilter_ = filter;
+       impl_->maxFilter_ = filter;
 }
 
-void texture::setWrapU(GLuint wrap)
+void Texture::setWrapU(GLuint wrap)
 {
-       impl->wrapU_ = wrap;
+       impl_->wrapU_ = wrap;
 }
 
-void texture::setWrapV(GLuint wrap)
+void Texture::setWrapV(GLuint wrap)
 {
-       impl->wrapV_ = wrap;
+       impl_->wrapV_ = wrap;
 }
 
 
-void texture::applyChanges()
+void Texture::applyChanges()
 {
        bind();
-       impl->setProperties();
+       impl_->setProperties();
 }
 
 
-std::string texture::getPathToResource(const std::string& name)
+std::string Texture::getPathToResource(const std::string& name)
 {
        // TODO since this is a generic library class, more than PNG should be
        // supported
-       return resource::getPathToResource("textures/" + name + ".png");
+       return Resource::getPathToResource("textures/" + name + ".png");
 }
 
 
-} // namespace dc
+} // namespace Mf
 
 /** vim: set ts=4 sw=4 tw=80: *************************************************/
 
This page took 0.026647 seconds and 4 git commands to generate.