--- Scene: Classic Yoink
--- created by Neil Carter
--- converted to Lua by Charles McGarvey
-
-LogInfo("-----", "Scene: Classic", "Created by Neil Carter",
- "Converted to Lua by Charles McGarvey", "-----")
+LogInfo("-----",
+ "Scene: Classic",
+ "Created by Neil Carter",
+ "Converted to Lua by Charles McGarvey",
+ "-----")
-- Scene API:
--
+++ /dev/null
-tiles_s = 8
-tiles_t = 4
-min_filter = NEAREST
-mag_filter = NEAREST
+++ /dev/null
-tiles_s = 1
-tiles_t = 1
-min_filter = LINEAR
-mag_filter = LINEAR
-wrap_s = CLAMP
-wrap_t = CLAMP
+++ /dev/null
-tiles_s = 1
-tiles_t = 1
-min_filter = LINEAR
-mag_filter = LINEAR
-wrap_s = REPEAT
-wrap_t = REPEAT
+++ /dev/null
-tiles_s = 8
-tiles_t = 1
-min_filter = NEAREST
-mag_filter = NEAREST
-wrap_s = CLAMP
-wrap_t = CLAMP
+++ /dev/null
-tiles_s = 8
-tiles_t = 4
-min_filter = NEAREST
-mag_filter = NEAREST
-wrap_s = CLAMP
-wrap_t = CLAMP
+++ /dev/null
-tiles_s = 8
-tiles_t = 4
-min_filter = NEAREST
-mag_filter = NEAREST
-wrap_s = CLAMP
-wrap_t = CLAMP
+++ /dev/null
-tiles_s = 8
-tiles_t = 8
-min_filter = NEAREST
-mag_filter = NEAREST
+++ /dev/null
-tiles_s = 8
-tiles_t = 4
-min_filter = NEAREST
-mag_filter = NEAREST
+++ /dev/null
-tiles_s = 4
-tiles_t = 2
-min_filter = NEAREST
-mag_filter = NEAREST
+++ /dev/null
-tiles_s = 8
-tiles_t = 4
-min_filter = NEAREST
-mag_filter = NEAREST
-wrap_s = CLAMP
-wrap_t = CLAMP
+++ /dev/null
-tiles_s = 8
-tiles_t = 4
-min_filter = NEAREST
-mag_filter = NEAREST
+++ /dev/null
-tiles_s = 4
-tiles_t = 4
-min_filter = NEAREST
-mag_filter = NEAREST
-wrap_s = REPEAT
-wrap_t = REPEAT
+++ /dev/null
-tiles_s = 4
-tiles_t = 1
-min_filter = NEAREST
-mag_filter = NEAREST
+++ /dev/null
-tiles_s = 4
-tiles_t = 4
-min_filter = NEAREST
-mag_filter = NEAREST
-wrap_s = CLAMP
-wrap_t = CLAMP
+++ /dev/null
-tiles_s = 2
-tiles_t = 1
-min_filter = NEAREST
-mag_filter = NEAREST
-wrap_s = CLAMP
-wrap_t = CLAMP
#include <map>
#include <vector>
-#include <Moof/Library.hh>
+#include <Moof/Manager.hh>
#include <Moof/Log.hh>
#include <Moof/Script.hh>
class Animation::Impl
{
- friend class Animation;
+public:
/**
* Contains "global" animation data for the various animations which get
* which wants to use these loaded sequences.
*/
- class Data : public Mf::Library<Data>
+ class Data : public Mf::Manager<Data>
{
- friend class Impl;
- friend class Mf::Library<Data>;
+ public:
/**
* A frame of an animation sequence. A frame is merely an index which
class Frame
{
- friend class Impl;
+ public:
unsigned mIndex; ///< Frame index.
Mf::Scalar mDuration; ///< Frame duration.
* that they should be played.
*/
- struct Sequence
+ class Sequence
{
- friend class Impl;
+ public:
std::vector<Frame> mFrames; ///< List of frames.
Mf::Scalar mDelay; ///< Scale frame durations.
* individual sequence.
*/
- void loadFromFile()
+ void init(const std::string& name)
{
Mf::Script script;
- std::string filePath = Animation::getPath(getName());
+ std::string filePath = Animation::getPath(name);
script.importBaseLibrary();
importLogFunctions(script);
std::string nameStr;
name.get(nameStr);
- sequences.insert(std::pair<std::string,Sequence>(nameStr,
+ mSequences.insert(std::pair<std::string,Sequence>(nameStr,
Sequence(script, table)));
return 0;
}
- /**
- * Construction is initialization. The animation class data container
- * registers itself as a mippleton and then loads the animation data.
- */
-
- explicit Data(const std::string& name) :
- Mf::Library<Data>(name)
- {
- loadFromFile();
- }
-
- std::map<std::string,Sequence> sequences; ///< List of sequences.
+ std::map<std::string,Sequence> mSequences; ///< List of sequences.
};
{
std::map<std::string,Data::Sequence>::iterator it;
- it = mData->sequences.find(name);
+ it = mData->mSequences.find(name);
- if (it != mData->sequences.end())
+ if (it != mData->mSequences.end())
{
mCurrentSequence = &(*it).second;
mFrameCounter = 0;
//glColor3f(1.0f, 1.0f, 1.0f);
tilemap.bind();
- Tilemap::Index frame = animation.getFrame();
+ Mf::Texture::TileIndex frame = animation.getFrame();
+ Mf::Texture::Orientation orientation = Mf::Texture::NORMAL;
- Tilemap::Orientation orientation = Tilemap::NORMAL;
-
- if (mState.velocity[0] < 0.0) orientation = Tilemap::REVERSE;
+ if (mState.velocity[0] < 0.0) orientation = Mf::Texture::REVERSE;
Mf::Scalar coords[8];
tilemap.getTileCoords(frame, coords, orientation);
#include <Moof/Math.hh>
#include <Moof/RigidBody.hh>
#include <Moof/Sphere.hh>
+#include <Moof/Texture.hh>
#include "Animation.hh"
-#include "Tilemap.hh"
//virtual int getOctant(const Mf::Aabb<3>& aabb) const;
- Tilemap tilemap;
+ Mf::Texture tilemap;
Animation animation;
};
#include "Hud.hh"
-ProgressBar::ProgressBar(const Tilemap& tilemap, Tilemap::Index index) :
+ProgressBar::ProgressBar(const Mf::Texture& tilemap, Mf::Texture::TileIndex index) :
mProgress(0.0),
mTilemap(tilemap)
{
Hud::Hud(GameState& state) :
mState(state),
- mBar1(Tilemap("StatusBars"), 0),
- mBar2(Tilemap("StatusBars"), 2),
+ mBar1(Mf::Texture("StatusBars"), 0),
+ mBar2(Mf::Texture("StatusBars"), 2),
mFont("Font")
{
ASSERT(Mf::video && "no current video context from which to get dimensions");
#include <Moof/Layer.hh>
#include <Moof/Math.hh>
#include <Moof/Rectangle.hh>
+#include <Moof/Texture.hh>
#include "GameState.hh"
-#include "Tilemap.hh"
// TODO this stuff is still just hacked up
{
public:
- ProgressBar(const Tilemap& tilemap, Tilemap::Index index);
+ ProgressBar(const Mf::Texture& tilemap, Mf::Texture::TileIndex index);
void resize(const Mf::Rectangle& rect);
Mf::Vector2 mVertices[8];
Mf::Scalar mWidth;
- Tilemap mTilemap;
+ Mf::Texture mTilemap;
Mf::Scalar mTexCoords[8];
Mf::Scalar mMidCoords[2];
};
ProgressBar mBar2;
unsigned mNumber;
- Tilemap mFont;
+ Mf::Texture mFont;
Mf::Matrix4 mProjection;
};
Moof/Image.hh \
Moof/Interpolator.hh \
Moof/Layer.hh \
- Moof/Library.hh \
Moof/Line.hh \
Moof/Log.cc \
Moof/Log.hh \
+ Moof/Manager.hh \
Moof/Math.hh \
Moof/ModalDialog.hh \
Moof/Octree.hh \
Main.hh \
Scene.cc \
Scene.hh \
- Tilemap.cc \
- Tilemap.hh \
TilemapFont.cc \
TilemapFont.hh \
TitleLayer.cc \
#include <list>
#include <string>
-#include <AL/alc.h>
#include <SDL/SDL.h>
#include "fastevents.h"
{
public:
- Backend_() :
- mAlDevice(0),
- mAlContext(0)
+ Backend_()
{
#if defined(_WIN32) || defined(__WIN32__)
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0)
return; // fatal
}
- mAlDevice = alcOpenDevice(0);
- mAlContext = alcCreateContext(mAlDevice, 0);
- if (!mAlDevice || !mAlContext)
- {
- const char* error = alcGetString(mAlDevice,alcGetError(mAlDevice));
- gError.init(Error::OPENAL_INIT, error);
- return;
- }
- else
- {
- alcMakeContextCurrent(mAlContext);
- logInfo << "opened sound device `"
- << alcGetString(mAlDevice, ALC_DEFAULT_DEVICE_SPECIFIER)
- << "'" << std::endl;
- }
-
gError.init(Error::NONE);
}
~Backend_()
{
- alcMakeContextCurrent(0);
- alcDestroyContext(mAlContext);
- alcCloseDevice(mAlDevice);
-
FE_Quit();
SDL_Quit();
}
}
}
- static bool check(Error& error)
+ static const Error& getError()
{
- error = gError;
- return error.code() == Error::NONE;
+ return gError;
}
private:
- ALCdevice* mAlDevice;
- ALCcontext* mAlContext;
-
static Error gError;
static int gRetainCount;
static BackendP gInstance;
Backend_::release();
}
-bool Backend::check(Error& error)
+bool Backend::isInitialized()
+{
+ return getError().code() == Error::NONE;
+}
+
+const Error& Backend::getError()
{
- return Backend_::check(error);
+ return Backend_::getError();
}
Backend();
~Backend();
- static bool check(Error& error);
+ static bool isInitialized();
+ static const Error& getError();
};
UNKNOWN_IMAGE_FORMAT, // name of resource
};
- explicit Error(unsigned code, const std::string& what = "")
+ explicit Error(unsigned code = NONE, const std::string& what = "")
{
init(code, what);
}
mCode = code;
}
- virtual void raise()
+ virtual void raise() const
{
throw *this;
}
return mWhat;
}
- bool isError() const throw()
+ operator bool () const
{
+ // resolves to true if error code is not NONE
return mCode != NONE;
}
#include <cstdio> // FILE
#include <cstring> // strncmp
+#include <boost/algorithm/string.hpp>
+
#include <SDL/SDL.h>
#include <png.h>
#include "Core.hh"
#include "Error.hh"
#include "Image.hh"
-#include "Library.hh"
#include "Log.hh"
+#include "Manager.hh"
namespace Mf {
-class Image::Impl : public Library<Impl>
+class Image::Impl : public Manager<Impl>
{
public:
- explicit Impl(const std::string& name, bool flipped = false) :
- Library<Impl>(name),
+ explicit Impl() :
mContext(0),
- mPixels(0)
- {
- init(getName(), flipped);
- }
+ mPixels(0) {}
~Impl()
{
}
- SDL_Surface* mContext;
- char* mPixels;
-
- unsigned mDepth;
- GLuint mColorMode;
-
- std::string mComment;
-
-
-private:
-
- Backend mBackend;
-
- bool init(const std::string& filePath, bool flipped)
+ bool init(const std::string& name, bool flipped = false)
{
- logInfo("opening image file...");
- FILE* fp = fopen(filePath.c_str(), "rb");
+ std::string path = Image::getPath(name);
+
+ logInfo << "opening image file " << path << std::endl;
+ FILE* fp = fopen(path.c_str(), "rb");
if (!fp) return false;
png_byte signature[8];
logInfo << "num texts: " << numTexts << std::endl;
for (int i = 0; i < numTexts; ++i)
{
- if (strncmp(texts[i].key, "Comment", 7) == 0)
+ if (strncmp(texts[i].key, "TextureInfo", 11) == 0)
{
mComment = texts[i].text;
break;
return mContext;
}
+
+
+ SDL_Surface* mContext;
+ char* mPixels;
+
+ unsigned mDepth;
+ GLuint mColorMode;
+
+ std::string mComment;
+
+private:
+
+ Backend mBackend;
};
return mImpl->mContext->pitch;
}
-GLuint Image::getColorMode() const
+GLuint Image::getMode() const
{
return mImpl->mColorMode;
}
}
-
std::string Image::getPath(const std::string& name)
{
- std::string path = Resource::getPath("images/" + name + ".png");
- return path;
+ if (boost::find_last(name, ".png"))
+ {
+ return Resource::getPath(name);
+ }
+ else
+ {
+ std::string path("images/");
+ path += name;
+ path += ".png";
+ return Resource::getPath(path);
+ }
}
namespace Mf {
+class Image;
+typedef boost::shared_ptr<Image> ImageP;
+
class Image : public Resource
{
public:
+ static ImageP alloc(const std::string& name)
+ {
+ return ImageP(new Image(name));
+ }
+
explicit Image(const std::string& name);
bool isValid() const;
unsigned getDepth() const;
unsigned getPitch() const;
- GLuint getColorMode() const;
+ GLuint getMode() const;
std::string getComment() const;
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*******************************************************************************/
-
-#ifndef _MOOF_LIBRARY_HH_
-#define _MOOF_LIBRARY_HH_
-
-/**
- * @file Library.hh
- * A library is a collection of named objects of the same type. Libraries use
- * reference counting to automagically delete objects which no longer have any
- * interested code.
- */
-
-#include <string>
-
-#include <boost/shared_ptr.hpp>
-
-#include <Moof/Hash.hh>
-
-
-namespace Mf {
-
-
-template <class T>
-class Library
-{
- typedef std::pair<unsigned,T*> PtrValue;
- typedef stlplus::hash<std::string,PtrValue,getHash> PtrMap;
-
- static PtrMap mPtrMap;
- std::string mName;
-
- static T* retain(const std::string& name)
- {
- typename PtrMap::iterator it = mPtrMap.find(name);
-
- if (it != mPtrMap.end())
- {
- ++((*it).second.first);
- return (*it).second.second;
- }
- else
- {
- T* newObj(new T(name));
- if (newObj)
- {
- mPtrMap.insert(std::make_pair(name, std::make_pair(1, newObj)));
- }
- return newObj;
- }
- }
-
- static void release(T* obj)
- {
- releaseByName(obj->mName);
- }
-
- static void releaseByName(const std::string& name)
- {
- typename PtrMap::iterator it;
-
- if ((it = mPtrMap.find(name)) != mPtrMap.end() &&
- --(*it).second.first == 0)
- {
- delete (*it).second.second;
- mPtrMap.erase((*it).first);
- }
- }
-
-public:
-
- explicit Library(const std::string& name) :
- mName(name) {}
-
- const std::string& getName() const
- {
- return mName;
- }
-
- static boost::shared_ptr<T> getInstance(const std::string& name)
- {
- return boost::shared_ptr<T>(retain(name), &release);
- }
-};
-
-template <class T>
-stlplus::hash< std::string,std::pair<unsigned,T*>,getHash >
- Library<T>::mPtrMap;
-
-
-} // namespace Mf
-
-#endif // _MOOF_LIBRARY_HH_
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
#include <list>
#include <string>
+#include <boost/algorithm/string.hpp>
+
#include <AL/al.h>
+#include <AL/alc.h>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
-#include "Core.hh"
#include "Error.hh"
-#include "Library.hh"
+#include "Manager.hh"
#include "Log.hh"
#include "Sound.hh"
#include "Timer.hh"
class Buffer;
typedef boost::shared_ptr<Buffer> BufferP;
- class Buffer : public Library<Buffer>
+ class Buffer : public Manager<Buffer>
{
public:
- explicit Buffer(const std::string& name) :
- Library<Buffer>(name),
+ Buffer() :
mBuffer(-1)
{
mOggStream.datasource = 0;
- openFile();
}
~Buffer()
}
- void openFile()
+ void init(const std::string& name)
{
if (mOggStream.datasource)
{
mOggStream.datasource = 0;
}
- std::string filePath = Sound::getPath(getName());
- int result = ov_fopen((char*)filePath.c_str(), &mOggStream);
+ std::string path = Sound::getPath(name);
+ int result = ov_fopen((char*)path.c_str(), &mOggStream);
if (result < 0)
{
- logWarning << "error while loading sound "
- << getName() << std::endl;
- throw Error(Error::UNKNOWN_AUDIO_FORMAT, getName());
+ logWarning << "couldn't load sound: " << path << std::endl;
+ throw Error(Error::UNKNOWN_AUDIO_FORMAT, path);
}
vorbis_info* vorbisInfo = ov_info(&mOggStream, -1);
void loadAll(ALuint source)
{
- if (!mOggStream.datasource) openFile();
+ if (!mOggStream.datasource) init(getName());
if (!mOggStream.datasource) return;
char data[BUFFER_SIZE];
void rewind()
{
- if (!mOggStream.datasource) openFile();
+ if (!mOggStream.datasource) init(getName());
else ov_raw_seek(&mOggStream, 0);
}
void init()
{
+ retainBackend();
+
mIsLoaded = false;
mIsPlaying = false;
mIsLooping = false;
alDeleteBuffers(1, &mBuffers.back());
mBuffers.pop_back();
}
+
+ releaseBackend();
}
// than a timer, probably as a compile-time option
}
+ static void retainBackend()
+ {
+ if (gRetainCount++ == 0)
+ {
+ gAlDevice = alcOpenDevice(0);
+ gAlContext = alcCreateContext(gAlDevice, 0);
+ if (!gAlDevice || !gAlContext)
+ {
+ const char* error = alcGetString(gAlDevice,
+ alcGetError(gAlDevice));
+ logError << "audio subsystem initialization failure: "
+ << error << std::endl;
+ }
+ else
+ {
+ alcMakeContextCurrent(gAlContext);
+ logInfo << "opened sound device `"
+ << alcGetString(gAlDevice, ALC_DEFAULT_DEVICE_SPECIFIER)
+ << "'" << std::endl;
+ }
+ }
+ }
+
+ static void releaseBackend()
+ {
+ if (--gRetainCount == 0)
+ {
+ alcMakeContextCurrent(0);
+ alcDestroyContext(gAlContext);
+ alcCloseDevice(gAlDevice);
+ }
+ }
+
ALuint mSource;
std::list<ALuint> mBuffers;
Timer mStreamTimer;
- Backend mBackend;
+ static unsigned gRetainCount;
+ static ALCdevice* gAlDevice;
+ static ALCcontext* gAlContext;
};
+unsigned Sound::Impl::gRetainCount = 0;
+ALCdevice* Sound::Impl::gAlDevice = 0;
+ALCcontext* Sound::Impl::gAlContext = 0;
+
Sound::Sound() :
// pass through
std::string Sound::getPath(const std::string& name)
{
- std::string path = Resource::getPath("sounds/" + name + ".ogg");
- return path;
+ if (boost::find_last(name, ".ogg"))
+ {
+ return Resource::getPath(name);
+ }
+ else
+ {
+ std::string path("sounds/");
+ path += name;
+ path += ".ogg";
+ return Resource::getPath(path);
+ }
}
#include <cstdio> // FILE
#include <cstring> // strncmp
+#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
#include "Dispatch.hh"
-#include "Core.hh"
#include "Error.hh"
-#include "Image.hh"
-#include "Library.hh"
+#include "Manager.hh"
#include "Log.hh"
#include "OpenGL.hh"
+#include "Script.hh"
#include "Texture.hh"
#include "Video.hh"
* which is worth having in memory. The image data itself is not worth keeping
* in memory if the texture has been loaded to GL, but the name of the resource
* is retained so that it can be reloaded if necessary. The implementation is a
- * library so that multiple texture objects can share the same internal objects
+ * manager so that multiple texture objects can share the same internal objects
* and avoid having duplicate textures loaded to GL.
*/
-class Texture::Impl : public Library<Impl>
+class Texture::Impl : public Manager<Impl>
{
/**
return value;
}
+
+ static void bindScriptConstants(Mf::Script& script)
+ {
+ script.push(GL_CLAMP); script.set("CLAMP");
+ script.push(GL_REPEAT); script.set("REPEAT");
+ script.push(GL_LINEAR); script.set("LINEAR");
+ script.push(GL_NEAREST); script.set("NEAREST");
+ script.push(GL_LINEAR_MIPMAP_LINEAR); script.set("LINEAR_MIPMAP_LINEAR");
+ script.push(GL_LINEAR_MIPMAP_NEAREST); script.set("LINEAR_MIPMAP_NEAREST");
+ script.push(GL_NEAREST_MIPMAP_LINEAR); script.set("NEAREST_MIPMAP_LINEAR");
+ script.push(GL_NEAREST_MIPMAP_NEAREST); script.set("NEAREST_MIPMAP_NEAREST");
+ }
+
public:
/**
* Construction is initialization.
*/
- explicit Impl(const std::string& name) :
- Library<Impl>(name),
- //mContext(0),
- mImage(Texture::getPath(getName())),
- mWidth(0),
- mHeight(0),
- mMode(0),
+ Impl() :
mMinFilter(GL_NEAREST),
mMagFilter(GL_NEAREST),
mWrapS(GL_CLAMP),
mWrapT(GL_CLAMP),
+ mTilesS(1),
+ mTilesT(1),
mObject(0)
{
// make sure we have a video context
- //ASSERT(video && "cannot load textures without a current video context");
+ ASSERT(video && "cannot load textures without a current video context");
// we want to know when the GL context is recreated
mDispatchHandler = core.addHandler("video.newcontext",
boost::bind(&Impl::contextRecreated, this));
-
- loadFromFile();
}
~Impl()
* @return Image data.
*/
- void loadFromFile()
+ void init(const std::string& name)
{
- if (!mImage.isValid())
+ std::string path = Texture::getPath(name);
+
+ mImage = Image::alloc(path);
+ if (!mImage->isValid())
+ {
+ logWarning << "texture not found: " << path << std::endl;
+ Error(Error::RESOURCE_NOT_FOUND, path).raise();
+ }
+
+ mImage->flip();
+
+ Mf::Script script;
+
+ importLogFunctions(script);
+ bindScriptConstants(script);
+
+ if (script.doString(mImage->getComment()) != Mf::Script::SUCCESS)
{
- logWarning << "texture not found: " << getName() << std::endl;
- throw Error(Error::RESOURCE_NOT_FOUND, getName());
+ std::string str;
+ script[-1].get(str);
+ Mf::logWarning(str);
}
+ else
+ {
+ Mf::logInfo << "loading tiles from texture " << path << std::endl;
+
+ Mf::Script::Slot globals = script.getGlobalTable();
+ Mf::Script::Slot top = script[-1];
- mImage.flip();
+ globals.pushField("tiles_s");
+ top.get(mTilesS);
- mWidth = mImage.getWidth();
- mHeight = mImage.getHeight();
- mMode = mImage.getColorMode();
+ globals.pushField("tiles_t");
+ top.get(mTilesT);
+
+ globals.pushField("min_filter");
+ top.get(mMinFilter);
+
+ globals.pushField("mag_filter");
+ top.get(mMagFilter);
+
+ globals.pushField("wrap_s");
+ top.get(mWrapS);
+
+ globals.pushField("wrap_t");
+ top.get(mWrapT);
+ }
}
return;
}
- //if (!mContext) loadFromFile();
-
glGenTextures(1, &mObject);
glBindTexture(GL_TEXTURE_2D, mObject);
(
GL_TEXTURE_2D,
0,
- mMode,
+ mImage->getMode(),
//3,
- mWidth,
- mHeight,
+ mImage->getWidth(),
+ mImage->getHeight(),
0,
- mMode,
+ mImage->getMode(),
GL_UNSIGNED_BYTE,
- mImage.getPixels()
+ mImage->getPixels()
);
setProperties();
-
- //SDL_FreeSurface(mContext);
- //mContext = 0;
}
}
- Image mImage;
- unsigned mWidth; ///< Horizontal dimension of the image.
- unsigned mHeight; ///< Vertical dimension.
+ bool getTileCoords(Texture::TileIndex index, Scalar coords[8]) const
+ {
+ // make sure the index represents a real tile
+ if (index >= mTilesS * mTilesT) return false;
+
+ Scalar w = 1.0 / Scalar(mTilesS);
+ Scalar h = 1.0 / Scalar(mTilesT);
+
+ coords[0] = Scalar(index % mTilesS) * w;
+ coords[1] = (Scalar(mTilesT - 1) -
+ Scalar(index / mTilesS)) * h;
+ coords[2] = coords[0] + w;
+ coords[3] = coords[1];
+ coords[4] = coords[2];
+ coords[5] = coords[1] + h;
+ coords[6] = coords[0];
+ coords[7] = coords[5];
+
+ return true;
+ }
+
+ ImageP mImage;
- GLuint mMode; ///< GL_RGB or GL_RGBA.
- GLuint mMinFilter; ///< Minifcation filter.
+ GLuint mMinFilter; ///< Minification filter.
GLuint mMagFilter; ///< Magnification filter.
GLuint mWrapS; ///< Wrapping behavior horizontally.
GLuint mWrapT; ///< Wrapping behavior vertically.
+ unsigned mTilesS;
+ unsigned mTilesT;
GLuint mObject; ///< GL texture handle.
static GLuint gObject; ///< Global GL texture handle.
Texture::Texture(const std::string& name) :
+ Image(Texture::getPath(name)),
// pass through
mImpl(Texture::Impl::getInstance(name)) {}
}
-unsigned Texture::getWidth() const
-{
- // pass through
- return mImpl->mWidth;
-}
-
-unsigned Texture::getHeight() const
-{
- // pass through
- return mImpl->mHeight;
-}
-
-
void Texture::setMinFilter(GLuint filter)
{
// pass through
}
+bool Texture::getTileCoords(TileIndex index, Scalar coords[8]) const
+{
+ // pass through
+ return mImpl->getTileCoords(index, coords);
+}
+
+bool Texture::getTileCoords(TileIndex index, Scalar coords[8],
+ Orientation orientation) const
+{
+ if (getTileCoords(index, coords))
+ {
+ if (orientation & FLIP)
+ {
+ // this looks kinda weird, but it's just swapping in a way that
+ // doesn't require an intermediate variable
+ coords[1] = coords[5];
+ coords[5] = coords[3];
+ coords[3] = coords[7];
+ coords[7] = coords[5];
+ }
+ if (orientation & REVERSE)
+ {
+ coords[0] = coords[2];
+ coords[2] = coords[6];
+ coords[4] = coords[6];
+ coords[6] = coords[0];
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+
std::string Texture::getPath(const std::string& name)
{
- std::string path = Resource::getPath("textures/" + name + ".png");
- return path;
+ if (boost::find_last(name, ".png"))
+ {
+ return Resource::getPath(name);
+ }
+ else
+ {
+ std::string path("textures/");
+ path += name;
+ path += ".png";
+ return Resource::getPath(path);
+ }
}
#include <boost/shared_ptr.hpp>
+#include <Moof/Image.hh>
#include <Moof/OpenGL.hh>
-#include <Moof/Resource.hh>
namespace Mf {
typedef boost::shared_ptr<Texture> TextureP;
-class Texture : public Resource
+class Texture : public Image
{
public:
+ /**
+ * Possible orientations for texture coordinates.
+ */
+
+ typedef unsigned TileIndex;
+ static const TileIndex NO_TILE = -1;
+
+ typedef enum
+ {
+ NORMAL = 0, ///< Normal orientation.
+ FLIP = 1, ///< Flip over a horizontal axis.
+ REVERSE = 2, ///< Flip over a vertical axis.
+ FLIP_AND_REVERSE = 3 ///< Flip over both.
+ } Orientation;
+
+
static TextureP alloc(const std::string& name)
{
return TextureP(new Texture(name));
static void resetBind();
- unsigned getWidth() const;
- unsigned getHeight() const;
-
void setMinFilter(GLuint filter);
void setMagFilter(GLuint filter);
void setWrapS(GLuint wrap);
void setWrapT(GLuint wrap);
+
+ /**
+ * Calculate texture coordinates for a tile at a certain index. Tiles are
+ * indexed start with zero as the to-left tile and moving across, then down.
+ * @param index The tile index.
+ * @param coords An array of scalars where the texture coordinates will be
+ * stored after this call. The first coordinate (u,v) will be in the first
+ * two places and so on until all four coordinates are stored, therefore
+ * requiring enough room for an array of eight scalars. The winding of the
+ * coordinates is always counter-clockwise (the GL default).
+ * @return True if index is valid, false otherwise.
+ */
+
+ bool getTileCoords(TileIndex index, Scalar coords[8]) const;
+
+
+ /**
+ * This version let's you specify an orientation that will be reflected in
+ * the texture coordinates. This allows you to easily map a texture
+ * backwards or upside-down.
+ * @param what The orientation; can be flip, reverse, or flip_and_reverse.
+ * @return True if index is valid, false otherwise.
+ */
+
+ bool getTileCoords(TileIndex index, Scalar coords[8], Orientation what) const;
+
+
static std::string getPath(const std::string& name);
private:
Video::Video()
{
- init(mAttribs);
+ init();
}
-Video::Video(const Attributes& attribs)
+Video::Video(const Attributes& attribs) :
+ mAttribs(attribs)
{
- init(attribs);
+ init();
}
Video::Video(const std::string& caption, const std::string& icon)
{
- if (mAttribs.caption == "Untitled")
- {
- mAttribs.caption = caption;
- }
- if (mAttribs.icon == "")
- {
- mAttribs.icon = icon;
- }
+ mAttribs.caption = caption;
+ mAttribs.icon = icon;
- init(mAttribs);
+ init();
}
-void Video::init(const Attributes& attribs)
+void Video::init()
{
+ Error error = Backend::getError();
+ if (error) error.raise();
+
mContext = 0;
mFlags = 0;
- mAttribs = attribs;
- setFull(attribs.fullscreen);
- setResizable(attribs.resizable);
+ setFull(mAttribs.fullscreen);
+ setResizable(mAttribs.resizable);
setOpenGLAttributes();
- setCaption(attribs.caption);
+ setCaption(mAttribs.caption);
setIcon();
- setCursorVisible(attribs.cursorVisible);
- setCursorGrab(attribs.cursorGrab);
- setVideoMode(attribs.mode);
+ setCursorVisible(mAttribs.cursorVisible);
+ setCursorGrab(mAttribs.cursorGrab);
+ setVideoMode(mAttribs.mode);
video = this;
}
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, mAttribs.multisampleBuffers);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, mAttribs.multisampleSamples);
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, mAttribs.swapControl);
- SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, mAttribs.hardwareonly);
+ SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, mAttribs.hardwareOnly);
}
multisampleBuffers = 0;
multisampleSamples = 0;
swapControl = false;
- hardwareonly = false;
+ hardwareOnly = false;
mode[0] = 640;
mode[1] = 480;
mode[2] = 0;
settings.get("multiesamplebuffers", multisampleBuffers);
settings.get("multiesamplesamples", multisampleSamples);
settings.get("swapcontrol", swapControl);
- settings.get("hardwareonly", hardwareonly);
+ settings.get("hardwareonly", hardwareOnly);
if (!settings.get("caption", caption))
{
mode[0] = dimensions[0];
mode[1] = dimensions[1];
}
- else if (fullscreen)
+ else if (fullscreen && Backend::isInitialized())
{
SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*******************************************************************************/
+/*] Copyright (c) 2009-2010, Charles McGarvey [**************************
+**] All rights reserved.
+*
+* vi:ts=8 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.
+*
+**************************************************************************/
#ifndef _MOOF_VIDEO_HH_
#define _MOOF_VIDEO_HH_
long multisampleBuffers;
long multisampleSamples;
bool swapControl;
- bool hardwareonly;
+ bool hardwareOnly;
// Window attributes
std::string caption;
private:
- Backend backend;
+ Backend mBackend;
+
};
- static VideoP alloc(const std::string& caption, const std::string& icon)
+ static VideoP alloc(const std::string& caption,
+ const std::string& icon)
{
return VideoP(new Video(caption, icon));
}
private:
- void init(const Attributes& attribs);
+ void init();
void recreateContext();
void setOpenGLAttributes();
#endif // _MOOF_VIDEO_HH_
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
#include <Moof/Aabb.hh>
#include <Moof/Camera.hh>
#include <Moof/Entity.hh>
-#include <Moof/Library.hh>
+#include <Moof/Manager.hh>
#include <Moof/Line.hh>
#include <Moof/Log.hh>
#include <Moof/Math.hh>
//#include <Moof/Octree.hh>
#include <Moof/Script.hh>
#include <Moof/Settings.hh>
+#include <Moof/Texture.hh>
#include "Character.hh"
#include "Scene.hh"
-#include "Tilemap.hh"
-struct Scene::Impl : public Mf::Library<Impl>
+struct Scene::Impl : public Mf::Manager<Impl>
{
struct Quad : public Mf::Entity
{
};
Quad(const Mf::Vector3* vertices[4], const std::string& texture,
- Tilemap::Index tileIndex) :
+ Mf::Texture::TileIndex tileIndex) :
mTilemap(texture),
mBlending(false),
mFog(false),
Mf::Vector3 mVertices[4];
Mf::Scalar mTexCoords[8];
- Tilemap mTilemap;
+ Mf::Texture mTilemap;
bool mBlending;
bool mFog;
};
- explicit Impl(const std::string& name) :
- Mf::Library<Impl>(name) {}
+ void init(const std::string& name) {}
+
void importSceneBindings(Mf::Script& script)
{
table.pushField(i);
- Tilemap::Index index;
+ Mf::Texture::TileIndex index;
top.get(index);
script.pop();
vertices[h][wPlus1] = Mf::demote(mTransform *
Mf::Vector4(wPlus1, h, 0.0, 1.0));
- if (index == Tilemap::NO_TILE) continue;
+ if (index == Mf::Texture::NO_TILE) continue;
const Mf::Vector3* corners[4] = {
&vertices[h][w],
Mf::Script::Slot param = script[1];
Mf::Script::Slot top = script[-1];
- Tilemap::Index index = 0;
- int width = 1;
- bool blending = false;
- bool fog = false;
+ Mf::Texture::TileIndex index = 0;
+ int width = 1;
+ bool blending = false;
+ bool fog = false;
if (param.isTable())
{
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*******************************************************************************/
-
-#include <Moof/Library.hh>
-#include <Moof/OpenGL.hh>
-#include <Moof/Script.hh>
-
-#include "Tilemap.hh"
-
-
-struct Tilemap::Impl : public Mf::Library<Impl>
-{
- Impl(const std::string& name) :
- Mf::Library<Impl>(name),
- mMagFilter(GL_NEAREST),
- mMinFilter(GL_NEAREST),
- mTilesS(1),
- mTilesT(1),
- mWrapS(GL_CLAMP),
- mWrapT(GL_CLAMP)
- {
- loadFromFile();
- }
-
-
- static void bindScriptConstants(Mf::Script& script)
- {
- script.push(GL_CLAMP); script.set("CLAMP");
- script.push(GL_REPEAT); script.set("REPEAT");
- script.push(GL_LINEAR); script.set("LINEAR");
- script.push(GL_NEAREST); script.set("NEAREST");
- script.push(GL_LINEAR_MIPMAP_LINEAR); script.set("LINEAR_MIPMAP_LINEAR");
- script.push(GL_LINEAR_MIPMAP_NEAREST); script.set("LINEAR_MIPMAP_NEAREST");
- script.push(GL_NEAREST_MIPMAP_LINEAR); script.set("NEAREST_MIPMAP_LINEAR");
- script.push(GL_NEAREST_MIPMAP_NEAREST); script.set("NEAREST_MIPMAP_NEAREST");
- }
-
- void loadFromFile()
- {
- Mf::Script script;
- std::string filePath = Tilemap::getPath(getName());
-
- script.importStandardLibraries();
- importLogFunctions(script);
- bindScriptConstants(script);
-
- if (script.doFile(filePath) != Mf::Script::SUCCESS)
- {
- std::string str;
- script[-1].get(str);
- Mf::logWarning(str);
- return; // TODO needs a better exit strategy
- }
-
- Mf::logInfo << "loading tiles from tilemap " << filePath << std::endl;
-
- Mf::Script::Slot globals = script.getGlobalTable();
- Mf::Script::Slot top = script[-1];
-
- globals.pushField("tiles_s");
- top.get(mTilesS);
-
- globals.pushField("tiles_t");
- top.get(mTilesT);
-
- globals.pushField("min_filter");
- top.get(mMinFilter);
-
- globals.pushField("mag_filter");
- top.get(mMagFilter);
-
- globals.pushField("wrap_s");
- top.get(mWrapS);
-
- globals.pushField("wrap_t");
- top.get(mWrapT);
- }
-
-
- bool getTileCoords(Tilemap::Index index, Mf::Scalar coords[8]) const
- {
- // make sure the index represents a real tile
- if (index >= mTilesS * mTilesT) return false;
-
- Mf::Scalar w = 1.0 / Mf::Scalar(mTilesS);
- Mf::Scalar h = 1.0 / Mf::Scalar(mTilesT);
-
- 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];
- coords[5] = coords[1] + h;
- coords[6] = coords[0];
- coords[7] = coords[5];
-
- return true;
- }
-
-
- GLuint mMagFilter;
- GLuint mMinFilter;
- unsigned mTilesS;
- unsigned mTilesT;
- GLuint mWrapS;
- GLuint mWrapT;
-};
-
-
-Tilemap::Tilemap(const std::string& name) :
- Texture(name),
- mImpl(Tilemap::Impl::getInstance(name))
-{
- 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 mImpl->getTileCoords(index, coords);
-}
-
-bool Tilemap::getTileCoords(Index index, Mf::Scalar coords[8],
- Orientation orientation) const
-{
- if (getTileCoords(index, coords))
- {
- if (orientation & FLIP)
- {
- // this looks kinda weird, but it's just swapping in a way that
- // doesn't require an intermediate variable
- coords[1] = coords[5];
- coords[5] = coords[3];
- coords[3] = coords[7];
- coords[7] = coords[5];
- }
- if (orientation & REVERSE)
- {
- coords[0] = coords[2];
- coords[2] = coords[6];
- coords[4] = coords[6];
- coords[6] = coords[0];
- }
-
- return true;
- }
-
- return false;
-}
-
-
-std::string Tilemap::getPath(const std::string& name)
-{
- return Resource::getPath("tilemaps/" + name + ".lua");
-}
-
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
+++ /dev/null
-
-/*******************************************************************************
-
- Copyright (c) 2009, Charles McGarvey
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-*******************************************************************************/
-
-#ifndef _TILEMAP_HH_
-#define _TILEMAP_HH_
-
-/**
- * @file Tilemap.hh
- * Small subclass to give some basic tile-mapping functionality to textures.
- */
-
-#include <boost/shared_ptr.hpp>
-
-#include <Moof/Math.hh>
-#include <Moof/Texture.hh>
-
-
-/**
- * A tilemap is a texture which is meant to be divided into smaller sprites.
- * This class provides all the functionality of a texture and adds some methods
- * to get texture coordinates to individual tiles within the tilemap. For
- * simplicity, this class assumes square tiles.
- */
-
-class Tilemap : public Mf::Texture
-{
-public:
-
- /**
- * Possible orientations for texture coordinates.
- */
-
- typedef unsigned Index;
- static const Index NO_TILE = -1;
-
- typedef enum
- {
- NORMAL = 0, ///< Normal orientation.
- FLIP = 1, ///< Flip over a horizontal axis.
- REVERSE = 2, ///< Flip over a vertical axis.
- FLIP_AND_REVERSE = 3 ///< Flip over both.
- } Orientation;
-
-
- explicit Tilemap(const std::string& name);
-
- /**
- * Calculate texture coordinates for a tile at a certain index. Tiles are
- * indexed start with zero as the to-left tile and moving across, then down.
- * @param index The tile index.
- * @param coords An array of scalars where the texture coordinates will be
- * stored after this call. The first coordinate (u,v) will be in the first
- * two places and so on until all four coordinates are stored, therefore
- * requiring enough room for an array of eight scalars. The winding of the
- * coordinates is always counter-clockwise (the GL default).
- * @return True if index is valid, false otherwise.
- */
-
- bool getTileCoords(Index index, Mf::Scalar coords[8]) const;
-
-
- /**
- * This version let's you specify an orientation that will be reflected in
- * the texture coordinates. This allows you to easily map a texture
- * backwards or upside-down.
- * @param what The orientation; can be flip, reverse, or flip_and_reverse.
- * @return True if index is valid, false otherwise.
- */
-
- bool getTileCoords(Index index, Mf::Scalar coords[8], Orientation what) const;
-
-
- static std::string getPath(const std::string& name);
-
-private:
-
- class Impl;
- boost::shared_ptr<Impl> mImpl;
-};
-
-
-#endif // _TILEMAP_HH_
-
-/** vim: set ts=4 sw=4 tw=80: *************************************************/
-
TilemapFont::TilemapFont() :
- Tilemap("Font") {}
+ Mf::Texture("Font") {}
void TilemapFont::getTileCoords(char symbol, Mf::Scalar coords[8],
- Tilemap::Orientation what)
+ Mf::Texture::Orientation what)
{
- Tilemap::Index index = 0;
+ Mf::Texture::TileIndex index = 0;
if (symbol >= ' ' && symbol <= '_')
{
index = 0;
}
- Tilemap::getTileCoords(index, coords, what);
+ Mf::Texture::getTileCoords(index, coords, what);
}
* Text on the screen.
*/
-#include "Tilemap.hh"
+#include <Moof/Texture.hh>
-class TilemapFont : public Tilemap
+class TilemapFont : public Mf::Texture
{
public:
TilemapFont();
void getTileCoords(char symbol, Mf::Scalar coords[8],
- Tilemap::Orientation what = Tilemap::NORMAL);
+ Mf::Texture::Orientation what = Mf::Texture::NORMAL);
};