#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 {
/**
* objects and avoid having duplicate textures loaded to GL.
*/
-class texture::texture_impl : public mippleton<texture_impl>
+class Texture::TextureImpl : public Mippleton<TextureImpl>
{
/**
* smart enough to cache it if the client has plenty of RAM.
*/
- void contextRecreated(const notification& note)
+ void contextRecreated(const Notification& note)
{
unloadFromGL();
uploadToGL();
* 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),
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);
}
{
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);
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)
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;
};
-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)
{}
* Bind the GL texture for mapping, etc.
*/
-void texture::bind()
+void Texture::bind()
{
glBindTexture(GL_TEXTURE_2D, getObject());
}
* 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: *************************************************/