X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FTexture.cc;fp=src%2Ftexture.cc;h=44a0b423719d6dfbb10c1be2ae98630a97c6e05c;hp=6d3e912925b8f1376018b9cc612fde8db1d4677a;hb=c2321281bf12a7efaedde930422c7ddbc92080d4;hpb=87bc17e55b0c1dc73ecc66df856d3f08fd7a7724 diff --git a/src/texture.cc b/src/Moof/Texture.cc similarity index 83% rename from src/texture.cc rename to src/Moof/Texture.cc index 6d3e912..44a0b42 100644 --- a/src/texture.cc +++ b/src/Moof/Texture.cc @@ -33,15 +33,13 @@ #include #include -#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 +class Texture::TextureImpl : public Mippleton { /** @@ -75,7 +73,7 @@ class texture::texture_impl : public mippleton * 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(name), + explicit TextureImpl(const std::string& name) : + Mippleton(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: *************************************************/