-/*] Copyright (c) 2009-2010, Charles McGarvey [**************************
+/*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
**] All rights reserved.
*
-* vi:ts=4 sw=4 tw=75
-*
* Distributable under the terms and conditions of the 2-clause BSD license;
* see the file COPYING for a complete text of the license.
*
-**************************************************************************/
+*****************************************************************************/
#include <cstdio> // FILE
#include <cstring> // strncmp
#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
+#include <stlplus/portability/file_system.hpp>
+
#include "dispatcher.hh"
#include "log.hh"
#include "opengl.hh"
namespace moof {
-sprite::sprite(const std::string& path, int tile)
+sprite::sprite(const std::string& name, int tile)
{
- image_ = resource::load(path);
- image_->tile_coordinates(tile, tile_);
+ image(name);
+ sprite::tile(tile);
}
sprite::sprite(const image_handle& image, int tile) :
image_(image)
{
- image_->tile_coordinates(tile, tile_);
+ sprite::tile(tile);
}
sprite::sprite(const sprite& sprite, int tile)
image_ = sprite.image_;
}
-
-void sprite::image(const std::string& path)
+void sprite::image(const std::string& name)
{
- image_ = resource::load(path);
- // FIXME what about tiles?
+ image_ = resource::load(name, "png");
}
void sprite::tile(int tile)
if (image_) image_->tile_coordinates(tile, tile_);
}
-
void sprite::bind() const
{
if (image_) image_->bind();
image::reset_binding();
}
-
void sprite::draw(const vector3 vertices[4]) const
{
bind();
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
-
/*
void min_filter(GLuint filter)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, mWrapT);
}
-
bool sprite::tile_coordinates(int index, scalar coords[8],
orientation orientation) const
{