*******************************************************************************/
-#include <Moof/Mippleton.hh>
+#include <Moof/Library.hh>
#include <Moof/OpenGL.hh>
#include <Moof/Script.hh>
#include "Tilemap.hh"
-struct Tilemap::Impl : public Mf::Mippleton<Impl>
+struct Tilemap::Impl : public Mf::Library<Impl>
{
Impl(const std::string& name) :
- Mf::Mippleton<Impl>(name),
- magFilter_(GL_NEAREST),
- minFilter_(GL_NEAREST),
- nTilesS_(1),
- nTilesT_(1),
- wrapS_(GL_CLAMP),
- wrapT_(GL_CLAMP)
+ Mf::Library<Impl>(name),
+ mMagFilter(GL_NEAREST),
+ mMinFilter(GL_NEAREST),
+ mTilesS(1),
+ mTilesT(1),
+ mWrapS(GL_CLAMP),
+ mWrapT(GL_CLAMP)
{
loadFromFile();
}
std::string filePath = Tilemap::getPath(getName());
script.importStandardLibraries();
- importLogScript(script);
+ importLogPrintFunction(script);
bindScriptConstants(script);
if (script.doFile(filePath) != Mf::Script::SUCCESS)
Mf::Script::Value top = script[-1];
globals.pushField("tiles_s");
- top.get(nTilesS_);
+ top.get(mTilesS);
globals.pushField("tiles_t");
- top.get(nTilesT_);
+ top.get(mTilesT);
globals.pushField("min_filter");
- top.get(minFilter_);
+ top.get(mMinFilter);
globals.pushField("mag_filter");
- top.get(magFilter_);
+ top.get(mMagFilter);
globals.pushField("wrap_s");
- top.get(wrapS_);
+ top.get(mWrapS);
globals.pushField("wrap_t");
- top.get(wrapT_);
+ top.get(mWrapT);
}
bool getTileCoords(Tilemap::Index index, Mf::Scalar coords[8]) const
{
// make sure the index represents a real tile
- if (index >= nTilesS_ * nTilesT_) return false;
+ if (index >= mTilesS * mTilesT) return false;
- Mf::Scalar w = 1.0 / Mf::Scalar(nTilesS_);
- Mf::Scalar h = 1.0 / Mf::Scalar(nTilesT_);
+ Mf::Scalar w = 1.0 / Mf::Scalar(mTilesS);
+ Mf::Scalar h = 1.0 / Mf::Scalar(mTilesT);
- coords[0] = Mf::Scalar(index % nTilesS_) * w;
- coords[1] = (Mf::Scalar(nTilesT_ - 1) -
- Mf::Scalar(index / nTilesS_)) * h;
+ coords[0] = Mf::Scalar(index % mTilesS) * w;
+ coords[1] = (Mf::Scalar(mTilesT - 1) -
+ Mf::Scalar(index / mTilesS)) * h;
coords[2] = coords[0] + w;
coords[3] = coords[1];
coords[4] = coords[2];
}
- GLuint magFilter_;
- GLuint minFilter_;
- unsigned nTilesS_;
- unsigned nTilesT_;
- GLuint wrapS_;
- GLuint wrapT_;
+ GLuint mMagFilter;
+ GLuint mMinFilter;
+ unsigned mTilesS;
+ unsigned mTilesT;
+ GLuint mWrapS;
+ GLuint mWrapT;
};
Tilemap::Tilemap(const std::string& name) :
Texture(name),
- impl_(Tilemap::Impl::getInstance(name))
+ mImpl(Tilemap::Impl::getInstance(name))
{
- setMinFilter(impl_->minFilter_);
- setMagFilter(impl_->magFilter_);
- setWrapS(impl_->wrapS_);
- setWrapT(impl_->wrapT_);
+ setMinFilter(mImpl->mMinFilter);
+ setMagFilter(mImpl->mMagFilter);
+ setWrapS(mImpl->mWrapS);
+ setWrapT(mImpl->mWrapT);
}
bool Tilemap::getTileCoords(Index index, Mf::Scalar coords[8]) const
{
// pass through
- return impl_->getTileCoords(index, coords);
+ return mImpl->getTileCoords(index, coords);
}
bool Tilemap::getTileCoords(Index index, Mf::Scalar coords[8],