--- /dev/null
+
+The man page (doc/yoink.6) may have a list.
+
if test x$developer = xyes
then
debug=yes
- profile=yes
- extra_warnings=yes
log_level=4
+
+ if test x$WIN32 != xyes
+ then
+ profile=yes
+ fi
fi
if test x$debug = xyes
then
- CFLAGS="$CFLAGS -Wall -O0 -g -DDEBUG"
- CXXFLAGS="$CXXFLAGS -Wall -O0 -g -DDEBUG"
+ CFLAGS="$CFLAGS -Wall -O0 -gstabs -DDEBUG"
+ CXXFLAGS="$CXXFLAGS -Wall -O0 -gstabs -DDEBUG"
else
- CFLAGS="$CFLAGS -O2 -DNDEBUG"
- CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
+ CFLAGS="$CFLAGS -O2 -DNDEBUG"
+ CXXFLAGS="$CXXFLAGS -O2 -DNDEBUG"
fi
if test x$profile = xyes
then
- CFLAGS="$CFLAGS -pg"
- CXXFLAGS="$CXXFLAGS -pg"
+ CFLAGS="$CFLAGS -pg"
+ CXXFLAGS="$CXXFLAGS -pg"
fi
if test x$extra_warnings = xyes
then
- CFLAGS="$CFLAGS -Wextra"
- CXXFLAGS="$CXXFLAGS -Wextra"
+ CFLAGS="$CFLAGS -Wextra -Wno-unused-parameter"
+ CXXFLAGS="$CXXFLAGS -Wextra -Wno-unused-parameter"
fi
AC_DEFINE_UNQUOTED([YOINK_LOGLEVEL], [$log_level],
RDEPEND="media-libs/freealut
media-libs/libsdl[opengl]
media-libs/sdl-image[png]
- media-libs/sdl-sound[mikmod,vorbis]
+ media-libs/sdl-sound[vorbis]
media-libs/openal
virtual/opengl"
DEPEND="${RDEPEND}
BuildRequires: SDL_sound-devel
BuildRequires: mesa-libGL-devel
BuildRequires: openal-devel
+BuildRequires: freealut-devel
Requires: SDL
Requires: SDL_image
Requires: SDL_sound
Requires: openal
+Requires: freealut
%description
Leap tall buildings! Crush stupid robots beneath your feet! Wield your
extra-terrestrial powers in the defence of humanity, and send those alien
*******************************************************************************/
+#include <iostream>
+
#include "Character.hh"
#include "Log.hh"
break;
}
- Mf::logInfo("current force [%f %f]", current.force[0], current.force[1]);
+ //Mf::logInfo("current force [%f %f]", current.force[0], current.force[1]);
+ //std::cerr << "current force: " << current.force << std::endl;
}
Mf::Scalar mass;
Mf::Scalar inverseMass;
+ void recalculate()
+ {
+ velocity = momentum * inverseMass;
+ }
+
void getDerivative(Derivative& derivative, Mf::Scalar t) const
{
derivative.force = force;
}
- void recalculate()
- {
- velocity = momentum * inverseMass;
- }
-
void applyDerivative(const Derivative& derivative, Mf::Scalar dt)
{
position += dt * derivative.velocity;
State previous;
State current;
- stlplus::ntree<Mf::OctreeNode>::iterator treeNode;
+ Mf::OctreeNodeP treeNode;
private:
};
-inline Character::State operator*(Mf::Scalar scalar, const Character::State& state)
+inline Character::State operator*(Mf::Scalar scalar,
+ const Character::State& state)
{
Character::State newState = state;
newState.position *= scalar;
void Hud::resize(int width, int height)
{
cml::matrix_orthographic_RH( projection_,
- 0.0,
- Mf::Scalar(width), 0.0, Mf::Scalar(height),
- 1.0, -1.0, cml::z_clip_neg_one);
+ 0.0f,
+ Mf::Scalar(width), 0.0f, Mf::Scalar(height),
+ 1.0f, -1.0f, cml::z_clip_neg_one);
// position the two progress bars at the top-left of the screen
bar1_.resize(Mf::Rectangle(20, height - 51,
Camera() :
position_(0.0, 0.0, 0.0)
{
- cml::quaternion_rotation_world_y(rotation_, 0.0);
+ cml::quaternion_rotation_world_y(rotation_, 0.0f);
calculateSecondary();
}
*******************************************************************************/
#include <cstdlib> // exit
-#include <iostream>
#include <string>
#include <SDL/SDL.h>
#include <SDL/SDL_sound.h>
#include <AL/alut.h>
+#include "Dispatcher.hh"
#include "Engine.hh"
+#include "Log.hh"
#include "Random.hh"
#include "Settings.hh"
#include "Timer.hh"
if (SDL_Init(SDL_INIT_EVERYTHING | SDL_INIT_EVENTTHREAD) != 0)
#endif
{
- std::cerr << "sdl is complaining: " << SDL_GetError() << std::endl;
+ logError("sdl is complaining: %s", SDL_GetError());
throw Exception(Exception::SDL_ERROR);
}
if (FE_Init() != 0)
{
- std::cerr << "fast events error: " << FE_GetError() << std::endl;
+ logError("fast events error: %s", FE_GetError());
throw Exception(Exception::SDL_ERROR);
}
if (Sound_Init() == 0)
{
- std::cerr << "sound initialization failed: " << Sound_GetError()
- << std::endl;
+ logError("sound initialization failed: %s", Sound_GetError());
throw Exception(Exception::SDL_ERROR);
}
alutInit(&argc, argv);
if (printFps)
{
- std::cout << "FPS: " << fps << std::endl;
+ logInfo("framerate: %d fps", fps);
}
}
#include <boost/shared_ptr.hpp>
-#include <Moof/Dispatcher.hh>
#include <Moof/Event.hh>
#include <Moof/Exception.hh>
#include <Moof/Math.hh>
*/
#include <cstdlib> // exit
-#include <cstring> // strerror
/**
typedef cml::vector< Scalar, cml::fixed<3> > Vector3;
typedef cml::vector< Scalar, cml::fixed<4> > Vector4;
+typedef cml::matrix< Scalar, cml::fixed<2,2>,
+ cml::col_basis, cml::col_major > Matrix2;
typedef cml::matrix< Scalar, cml::fixed<3,3>,
cml::col_basis, cml::col_major > Matrix3;
typedef cml::matrix< Scalar, cml::fixed<4,4>,
template <class T>
class Mippleton
{
- typedef std::pair<unsigned,T*> PtrValue;
- typedef stlplus::hash<std::string,PtrValue,getHash> PtrMap;
+ typedef std::pair<unsigned,T*> PtrValue;
+ typedef stlplus::hash<std::string,PtrValue,getHash> PtrMap;
static PtrMap ptrs_;
std::string name_;
inline void print(OctreeNodeP node)
{
- logDebug("-----");
- logDebug("depth to node: %d", tree_.depth(node));
- logDebug("size of node: %d", tree_.size(node));
+ //logDebug("-----");
+ //logDebug("depth to node: %d", tree_.depth(node));
+ //logDebug("size of node: %d", tree_.size(node));
}
inline static OctreeP alloc(const OctreeNode& rootNode)
/* Define to 1 if you want to use double precision floating-point numbers. */
-#define USE_DOUBLE_PRECISION 1
+//#define USE_DOUBLE_PRECISION 1
#if USE_DOUBLE_PRECISION
*******************************************************************************/
#include <string>
+#include <queue>
+#include <vector>
#include <SDL/SDL.h>
#include <SDL/SDL_sound.h>
#include "Mippleton.hh"
#include "Sound.hh"
-#define BUFFER_SIZE (8 * 4096)
+#define BUFFER_SIZE (64 * 1024)
+//#define BUFFER_SIZE (5*2048)
namespace Mf {
}
}
- struct Buffer : public Mippleton<Buffer>
+ class Buffer;
+ typedef boost::shared_ptr<Buffer> BufferP;
+
+ class Buffer : public Mippleton<Buffer>
{
+ Sound_Sample* sound;
+ std::vector<ALuint> objects;
+
+ public:
+
Buffer(const std::string& name) :
- Mippleton<Buffer>(name)
+ Mippleton<Buffer>(name),
+ sound(0)
{
- sound = 0;
- objects[0] = 0;
- objects[1] = 0;
+ openFile();
}
~Buffer()
{
- alDeleteBuffers(2, objects);
+ while (!objects.empty())
+ {
+ alDeleteBuffers(1, &objects.back());
+ objects.pop_back();
+ }
if (sound) Sound_FreeSample(sound);
}
- void loadFromFile(const std::string& filePath, bool stream)
+ void openFile()
{
- if (objects[0] != 0) return;
+ if (sound) Sound_FreeSample(sound);
- sound = Sound_NewSampleFromFile(filePath.c_str(),
- NULL, BUFFER_SIZE);
+ sound = Sound_NewSampleFromFile(Sound::getPath(getName()).c_str(),
+ 0, BUFFER_SIZE);
if (!sound)
{
- logWarning("error while loading sound %s: %s", getName().c_str(), Sound_GetError());
+ logWarning("error while loading sound %s: %s",
+ getName().c_str(), Sound_GetError());
throw Exception(Exception::FILE_NOT_FOUND);
}
- if (!stream)
- {
+ logDebug("buffer size: %d", sound->buffer_size);
+ logDebug(" channels: %d", sound->actual.channels);
+ logDebug(" format: %d", sound->actual.format);
+ logDebug(" frequency: %d", sound->actual.rate);
+ }
+
+
+ void loadAll(ALuint source)
+ {
+ if (!sound) openFile();
+ if (!sound) return;
+
unsigned decoded = Sound_DecodeAll(sound);
if (decoded == 0)
{
return;
}
- alGenBuffers(2, objects);
- alBufferData(objects[0], getAudioFormat(sound->actual), sound->buffer,
+ ALuint obj;
+ alGenBuffers(1, &obj);
+
+ alBufferData(obj, getAudioFormat(sound->actual), sound->buffer,
sound->buffer_size, sound->actual.rate);
- logDebug("buffer size: %d", sound->buffer_size);
- logDebug(" channels: %d", sound->actual.channels);
- logDebug(" format: %d", sound->actual.format);
- logDebug(" frequency: %d", sound->actual.rate);
+ objects.push_back(obj);
+
+ alSourcei(source, AL_BUFFER, obj);
+
+ // don't need t his anymore
Sound_FreeSample(sound);
sound = 0;
- }
- else
+ }
+
+
+ void beginStream(ALuint source, int nBuffers = 4)
+ {
+ if (!sound) openFile();
+ if (!sound) return;
+
+ ALuint objs[nBuffers];
+ alGenBuffers(nBuffers, objs);
+
+ for (int i = 0; i < nBuffers; ++i)
{
- logDebug("buffer size: %d", sound->buffer_size);
- logDebug(" channels: %d", sound->actual.channels);
- logDebug(" format: %d", sound->actual.format);
- logDebug(" frequency: %d", sound->actual.rate);
- alGenBuffers(2, objects);
+ objects.push_back(objs[i]);
+ stream(objs[i]);
}
+
+ alSourceQueueBuffers(source, nBuffers, objs);
}
- bool stream(ALuint buffer)
+ enum StreamStatus
+ {
+ STREAM_OK = 0,
+ STREAM_EOF = 1,
+ STREAM_WRONG = 2
+ };
+
+ StreamStatus stream(ALuint buffer)
{
- int bytes = Sound_Decode(sound);
+ std::vector<ALuint>::iterator it =
+ std::find(objects.begin(), objects.end(), buffer);
- if (bytes < BUFFER_SIZE) return false;
+ // that buffer doesn't belong to us
+ if (it == objects.end()) return STREAM_WRONG;
+
+ unsigned bytes = Sound_Decode(sound);
+
+ if (bytes == 0) return STREAM_EOF;
alBufferData(buffer, getAudioFormat(sound->actual), sound->buffer,
- sound->buffer_size, sound->actual.rate);
- return false;
+ bytes, sound->actual.rate);
+
+ return STREAM_OK;
+ }
+
+ inline void rewind()
+ {
+ if (!sound) openFile();
+ else Sound_Rewind(sound);
}
- Sound_Sample* sound;
- ALuint objects[2];
- //ALfloat location[] = {0.0f, 0.0f, 0.0f};
- //ALfloat location2[] = {0.0f, 0.0f, 0.0f};
- //ALfloat orient[] = {0.0f, 0.0f, -1.0f, 0.0, 1.0, 0.0};
+ // delete unused buffers, return true if all buffers deleted
+ inline bool clear()
+ {
+ // clear any openal errors
+ alGetError();
+
+ while (!objects.empty())
+ {
+ ALuint buffer = objects.back();
+ alDeleteBuffers(1, &buffer);
+ // if an error occured, the buffer was not deleted because it's
+ // still in use by some source
+ if (alGetError() != AL_NO_ERROR) return false;
- //alListenerfv(AL_POSITION, location);
- //alListenerfv(AL_VELOCITY, location);
- //alListenerfv(AL_VELOCITY, orient);
+ objects.pop_back();
+ }
+
+ return true;
+ }
};
- Impl(const std::string& name, bool stream = false) :
- buffer_(Buffer::getInstance(name))
- {
- if (!stream) buffer_->loadFromFile(Sound::getPath(name), stream);
- else buffer_->loadFromFile(SoundStream::getPath(name), stream);
- ALfloat location[] = {0.0f, 0.0f, 0.0f};
+ Impl(const std::string& name) :
+ buffer_(Buffer::getInstance(name)),
+ playing_(false),
+ looping_(false)
+ {
+ ALfloat zero[] = {0.0f, 0.0f, 0.0f};
alGenSources(1, &source_);
alSourcef(source_, AL_PITCH, 1.0f);
alSourcef(source_, AL_GAIN, 1.0f);
- alSourcefv(source_, AL_POSITION, location);
- alSourcefv(source_, AL_VELOCITY, location);
- alSourcei(source_, AL_LOOPING, AL_FALSE);
+ alSourcefv(source_, AL_POSITION, zero);
+ alSourcefv(source_, AL_VELOCITY, zero);
+ }
- if (!stream)
+ ~Impl()
+ {
+ alDeleteSources(1, &source_);
+ }
+
+
+ void play()
+ {
+ ALenum type;
+ alGetSourcei(source_, AL_SOURCE_TYPE, &type);
+
+ if (type != AL_STATIC)
{
- alSourcei(source_, AL_BUFFER, buffer_->objects[0]);
+ buffer_->loadAll(source_);
}
- else
- {
- buffer_->stream(buffer_->objects[0]);
- buffer_->stream(buffer_->objects[1]);
- alSourceQueueBuffers(source_, 2, buffer_->objects);
- }
+ alSourcei(source_, AL_LOOPING, looping_);
+ alSourcePlay(source_);
+ playing_ = true;
}
- ~Impl()
+
+ void stream()
{
- alDeleteSources(1, &source_);
- }
+ ALenum type;
+ alGetSourcei(source_, AL_SOURCE_TYPE, &type);
+
+ alSourcei(source_, AL_BUFFER, AL_NONE);
+ buffer_->rewind();
+ buffer_->beginStream(source_);
+ alSourcei(source_, AL_LOOPING, AL_FALSE);
+ alSourcePlay(source_);
+ playing_ = true;
+ }
- void update()
+ inline void update()
{
- int finished = 0;
+ ALint finished = 0;
alGetSourcei(source_, AL_BUFFERS_PROCESSED, &finished);
ALuint buffer;
alSourceUnqueueBuffers(source_, 1, &buffer);
- buffer_->stream(buffer);
- alSourceQueueBuffers(source_, 1, &buffer);
+
+ Buffer::StreamStatus status = buffer_->stream(buffer);
+
+ if (status == Buffer::STREAM_OK)
+ {
+ alSourceQueueBuffers(source_, 1, &buffer);
+ }
+ else if (status == Buffer::STREAM_EOF)
+ {
+ if (!queue_.empty())
+ {
+ // begin the next buffer in the queue
+ expired_.push_back(buffer_);
+ buffer_ = queue_.front();
+ queue_.pop();
+ buffer_->beginStream(source_, 1);
+ }
+ else if (looping_)
+ {
+ // restart from the beginning
+ buffer_->rewind();
+ buffer_->stream(buffer);
+ alSourceQueueBuffers(source_, 1, &buffer);
+ }
+ }
+ else if (status == Buffer::STREAM_WRONG)
+ {
+ clear();
+ buffer_->beginStream(source_, 1);
+ }
+ }
+
+ ALenum state;
+ alGetSourcei(source_, AL_SOURCE_STATE, &state);
+
+ // restart playing if we're stopped but supposed to be playing... this
+ // means we didn't queue enough and the audio skipped
+ if (playing_ && state != AL_PLAYING)
+ {
+ alSourcePlay(source_);
}
}
+ inline void clear()
+ {
+ // try to remove expired buffers
+ std::vector<BufferP>::iterator it;
+ for (it = expired_.end() - 1; it >= expired_.begin(); --it)
+ {
+ if ((*it)->clear()) expired_.erase(it);
+ }
+ }
- boost::shared_ptr<Buffer> buffer_;
- ALuint source_;
- bool playing;
-};
+ void stop()
+ {
+ alSourceStop(source_);
+ playing_ = false;
+ }
+
+ inline void pause()
+ {
+ alSourcePause(source_);
+ playing_ = false;
+ }
+
+ inline void resume()
+ {
+ alSourcePlay(source_);
+ playing_ = true;
+ }
+
+
+ inline void setSample(const std::string& name)
+ {
+ bool playing = isPlaying();
+ ALenum type;
+ alGetSourcei(source_, AL_SOURCE_TYPE, &type);
+
+ stop();
+
+ //alSourcei(source_, AL_BUFFER, AL_NONE);
+ buffer_ = Buffer::getInstance(name);
+
+ if (type == AL_STREAMING)
+ {
+ if (playing) stream();
+ }
+ else
+ {
+ if (playing) play();
+ }
+ }
+
+ inline void enqueue(const std::string& name)
+ {
+ BufferP buffer = Buffer::getInstance(name);
+ queue_.push(buffer);
+ }
+
+
+ inline bool isPlaying() const
+ {
+ if (playing_) return true;
+
+ ALenum state;
+ alGetSourcei(source_, AL_SOURCE_STATE, &state);
+
+ return state == AL_PLAYING;
+ }
+
+
+ inline void setLooping(bool looping)
+ {
+ looping_ = looping;
+
+ ALenum type;
+ alGetSourcei(source_, AL_SOURCE_TYPE, &type);
+
+ if (type != AL_STREAMING)
+ {
+ alSourcei(source_, AL_LOOPING, looping_);
+ }
+ }
+
+
+ ALuint source_;
+ BufferP buffer_;
+
+ bool playing_;
+ bool looping_;
+
+ std::queue<BufferP> queue_;
+ std::vector<BufferP> expired_;
+};
Sound::Sound(const std::string& name) :
// pass through
void Sound::play()
{
- if (!impl_->buffer_->sound) return;
+ // pass through
+ impl_->play();
+}
- //alSourceRewind(impl_->source_);
- alSourcePlay(impl_->source_);
- impl_->playing = true;
+
+void Sound::stream()
+{
+ // pass through
+ impl_->stream();
}
-void Sound::pause()
+void Sound::update(Scalar t, Scalar dt)
{
- alSourcePause(impl_->source_);
- impl_->playing = false;
+ // pass through
+ impl_->update();
}
-void Sound::togglePlayPause()
+
+void Sound::stop()
{
- if (impl_->playing) pause();
- else play();
+ // pass through
+ impl_->stop();
}
-void Sound::setGain(Scalar gain)
+void Sound::pause()
{
- alSourcef(impl_->source_, AL_GAIN, gain);
+ // pass through
+ impl_->pause();
}
+void Sound::resume()
+{
+ // pass through
+ impl_->resume();
+}
-std::string Sound::getPath(const std::string& name)
+void Sound::toggle()
{
- std::string path = Resource::getPath("sounds/" + name + ".ogg");
- return path;
+ if (impl_->playing_) pause();
+ else resume();
}
-//##############################################################################
+void Sound::setSample(const std::string& name)
+{
+ // pass through
+ impl_->setSample(name);
+}
+
+void Sound::enqueue(const std::string& name)
+{
+ // pass through
+ impl_->enqueue(name);
+}
-SoundStream::SoundStream(const std::string& name)
+bool Sound::isPlaying() const
+{
// pass through
- //impl_(name, true) {}
+ return impl_->isPlaying();
+}
+
+void Sound::setPosition(Vector3 position)
{
- impl_ = boost::shared_ptr<Sound::Impl>(new Sound::Impl(name, true));
+ float p[3] = {position[0], position[1], position[2]};
+ alSourcefv(impl_->source_, AL_POSITION, p);
}
+void Sound::setVelocity(Vector3 velocity)
+{
+ float v[3] = {velocity[0], velocity[1], velocity[2]};
+ alSourcefv(impl_->source_, AL_VELOCITY, v);
+}
-void SoundStream::update(Scalar t, Scalar dt)
+void Sound::setGain(Scalar gain)
+{
+ alSourcef(impl_->source_, AL_GAIN, float(gain));
+}
+
+void Sound::setPitch(Scalar pitch)
+{
+ alSourcef(impl_->source_, AL_PITCH, float(pitch));
+}
+
+void Sound::setLooping(bool looping)
{
// pass through
- impl_->update();
+ impl_->setLooping(looping);
}
-std::string SoundStream::getPath(const std::string& name)
+std::string Sound::getPath(const std::string& name)
{
- std::string path = Resource::getPath("sounds/" + name + ".xm");
+ std::string path = Resource::getPath("sounds/" + name + ".ogg");
return path;
}
* Image-loading and OpenGL texture loading.
*/
-#include <stdexcept>
-
#include <boost/shared_ptr.hpp>
#include <Moof/Exception.hh>
class Sound : public Resource
{
-protected:
- Sound() {}
class Impl;
boost::shared_ptr<Impl> impl_;
public:
- static SoundP alloc(const std::string& name)
+ inline static SoundP alloc(const std::string& name)
{
return SoundP(new Sound(name));
}
- Sound(const std::string& name);
+ explicit Sound(const std::string& name);
+
void play();
+
+ void stream();
+ void update(Scalar t, Scalar dt);
+
+ void stop();
void pause();
- void togglePlayPause();
+ void resume();
+ void toggle();
+
+ void setSample(const std::string& name);
+ void enqueue(const std::string& name);
+ bool isPlaying() const;
+
+ void setPosition(Vector3 position);
+ void setVelocity(Vector3 velocity);
void setGain(Scalar gain);
+ void setPitch(Scalar pitch);
+ void setLooping(bool looping);
static std::string getPath(const std::string& name);
};
-class SoundStream : public Sound
-{
-public:
- SoundStream(const std::string& name);
-
- void update(Scalar t, Scalar dt);
-
- static std::string getPath(const std::string& name);
-};
-
-
} // namespace Mf
#endif // _MOOF_SOUND_HH_
#include <ctime>
#include <stdexcept>
+#include "Log.hh"
#include "Timer.hh"
#if HAVE_CONFIG_H
#include "config.h"
#endif
+#include <SDL/SDL.h>
+
namespace Mf {
// SDL only promises centisecond accuracy, but that's better than a kick in the
// butt.
-#include <SDL/SDL.h>
-
Scalar getTicks()
{
Uint32 ms = SDL_GetTicks();
void sleep(Scalar seconds, bool absolute)
{
if (absolute) seconds -= getTicks();
-
- SDL_Delay(Uint32(seconds * 1000.0));
+ SDL_Delay(Uint32(cml::clamp(int(seconds * 1000.0), 0, 1000)));
}
#endif // HAVE_CLOCK_GETTIME
#include "YoinkApp.hh"
-#include <SDL/SDL_sound.h>
-#include <AL/al.h>
-#include <AL/alut.h>
-
#if HAVE_CONFIG_H
#include "config.h"
#endif
YoinkApp::YoinkApp(int argc, char* argv[]) :
Mf::Engine(argc, argv, configFiles(), PACKAGE_STRING, iconFile()),
- music("NightFusion"),
+ music("NightFusionIntro"),
punchSound("RobotPunch")
{
Mf::dispatcher::addHandler("video.context_recreated",
boost::bind(&YoinkApp::contextRecreated, this, _1), this);
setupGL();
- Mf::Scalar fade[2] = {0.0, 1.0};
- musicFade.init(fade, 0.0);
- music.play();
-
- state = 0.0;
+ music.setLooping(true);
+ music.enqueue("NightFusionLoop");
+ music.stream();
heroine = Character::alloc("RobotTrooper");
heroine->getAnimation().startSequence("Run");
void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt)
{
- //dt *= 0.2;
+ //dt *= 0.5;
- musicFade.update(dt);
music.update(t, dt);
- music.setGain(musicFade.getValue());
-
fadeIn.update(dt);
-
camera.update(t, dt);
-
heroine->update(t, dt);
+
+ // reinsert heroine
heroine->treeNode = testScene->getOctree()->reinsert(heroine, heroine->treeNode);
testScene->getOctree()->print(heroine->treeNode);
interp.update(dt);
hud.setBar1Progress(interp.getValue());
hud.setBar2Progress(1.0 - interp.getValue());
-
- prevstate = state;
- state += dt;
}
void YoinkApp::draw(Mf::Scalar alpha)
{
- //Mf::Vector4 meh;
- //meh.random(0.0, 1.0);
- //static Mf::Vector4 c1(meh);
-
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
- //Mf::Scalar drawstate = cml::lerp(prevstate, state, alpha);
- //Mf::Scalar sinstate = std::sin(drawstate);
- //Mf::Scalar cosstate = std::cos(drawstate);
-
-
glMatrixMode(GL_MODELVIEW);
- //glLoadIdentity();
-
- //glRotatef(drawstate*15.0f, 0.0, 1.0, 0.0);
- //glTranslatef(x, y, z);
glLoadMatrix(camera.getModelviewMatrix().data());
// DRAW THE SCENE
Mf::Texture::resetBind();
testScene->draw(alpha, camera);
-
-
//heroine->draw(alpha);
heroine->getAabb().draw();
-
hud.draw();
-
+ // DRAW FADE
glEnable(GL_BLEND);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
-
- /*
- glLoadIdentity();
-
- someChar->getTilemap().bind();
- glColor3f(1.0, 1.0, 1.0);
-
- Mf::Tilemap::Index heroFrame = someChar->getAnimation().getFrame();
-
- Mf::Scalar coords[8];
- someChar->getTilemap().getTileCoords(heroFrame, coords);
-
- glBegin(GL_QUADS);
- glTexCoord2f(coords[0], coords[1]);
- glVertex3f(-1.0, 0.0, 0.0);
- glTexCoord2f(coords[2], coords[3]);
- glVertex3f(0.0, 0.0, 0.0);
- glTexCoord2f(coords[4], coords[5]);
- glVertex3f(0.0, 1.0, 0.0);
- glTexCoord2f(coords[6], coords[7]);
- glVertex3f(-1.0, 1.0, 0.0);
- glEnd();
-
-
- someChar->getTilemap().getTileCoords(heroFrame, coords,
- Mf::Tilemap::REVERSE);
-
- glBegin(GL_QUADS);
- glTexCoord2f(coords[0], coords[1]);
- glVertex3f(0.0, 0.0, 0.0);
- glTexCoord2f(coords[2], coords[3]);
- glVertex3f(1.0, 0.0, 0.0);
- glTexCoord2f(coords[4], coords[5]);
- glVertex3f(1.0, 1.0, 0.0);
- glTexCoord2f(coords[6], coords[7]);
- glVertex3f(0.0, 1.0, 0.0);
- glEnd();
-
- glColor4f(1.0,0.0,0.0,0.5);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- glColor4v(c1.data());
-
- glRectd(-cosstate, -sinstate, sinstate, cosstate);
- glRectf(0.0f, 0.0f, sinstate, cosstate);
-
- font->bind();
-
- font->getTileCoords('c', coords);
-
- glBegin(GL_QUADS);
- glTexCoord2f(coords[0], coords[1]);
- glVertex3f(-1.0, 0.0, 0.0);
- glTexCoord2f(coords[2], coords[3]);
- glVertex3f(0.0, 0.0, 0.0);
- glTexCoord2f(coords[4], coords[5]);
- glVertex3f(0.0, 1.0, 0.0);
- glTexCoord2f(coords[6], coords[7]);
- glVertex3f(-1.0, 1.0, 0.0);
- glEnd();
-
- font->getTileCoords('h', coords);
-
- glBegin(GL_QUADS);
- glTexCoord2f(coords[0], coords[1]);
- glVertex3f(0.0, 0.0, 0.0);
- glTexCoord2f(coords[2], coords[3]);
- glVertex3f(1.0, 0.0, 0.0);
- glTexCoord2f(coords[4], coords[5]);
- glVertex3f(1.0, 1.0, 0.0);
- glTexCoord2f(coords[6], coords[7]);
- glVertex3f(0.0, 1.0, 0.0);
- glEnd();
-
- font->getTileCoords('a', coords);
-
- glBegin(GL_QUADS);
- glTexCoord2f(coords[0], coords[1]);
- glVertex3f(-1.0, -1.0, 0.0);
- glTexCoord2f(coords[2], coords[3]);
- glVertex3f(0.0, -1.0, 0.0);
- glTexCoord2f(coords[4], coords[5]);
- glVertex3f(0.0, 0.0, 0.0);
- glTexCoord2f(coords[6], coords[7]);
- glVertex3f(-1.0, 0.0, 0.0);
- glEnd();
-
- font->getTileCoords('z', coords);
-
- glBegin(GL_QUADS);
- glTexCoord2f(coords[0], coords[1]);
- glVertex3(0.0, -1.0, 0.0);
- glTexCoord2f(coords[2], coords[3]);
- glVertex3(1.0, -1.0, 0.0);
- glTexCoord2f(coords[4], coords[5]);
- glVertex3(1.0, 0.0, 0.0);
- glTexCoord2f(coords[6], coords[7]);
- glVertex3(0.0, 0.0, 0.0);
- glEnd();
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_DEPTH_TEST);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
-
- glBegin(GL_LINES);
- glVertex2f(0.0f, 0.0f);
- glVertex2v(interp.getState(alpha).data());
- glEnd();
-
- glColor4f(0.0f, 0.0f, 0.0f, fadeIn.getState(alpha));
- glRectf(-1.0f, -1.0f, 1.0f, 1.0f);
-
- glDisable(GL_BLEND);
- glEnable(GL_DEPTH_TEST);*/
}
void YoinkApp::handleEvent(const Mf::Event& event)
}
else if (event.key.keysym.sym == SDLK_p)
{
- music.togglePlayPause();
+ music.toggle();
break;
}
else if (event.key.keysym.sym == SDLK_l)
<< "Send patches and bug reports to <"
PACKAGE_BUGREPORT << ">." << std::endl << std::endl;
-#if ! NDEBUG
+#if YOINK_LOGLEVEL >= 4
Mf::setLogLevel(Mf::LOG_DEBUG);
+#elif YOINK_LOGLEVEL >= 3
+ Mf::setLogLevel(Mf::LOG_INFO);
+#elif YOINK_LOGLEVEL >= 2
+ Mf::setLogLevel(Mf::LOG_WARNING);
+#elif YOINK_LOGLEVEL >= 1
+ Mf::setLogLevel(Mf::LOG_ERROR);
+#elif YOINK_LOGLEVEL
+ Mf::setLogLevel(Mf::LOG_NONE);
#endif
int status = 0;
void setupGL();
void contextRecreated(const Mf::Notification* note);
- Mf::Lerps musicFade;
- Mf::SoundStream music;
+ Mf::Sound music;
CharacterP heroine;
Mf::Sound punchSound;
Mf::Camera camera;
Mf::SceneP testScene;
- Mf::Scalar state;
- Mf::Scalar prevstate;
-
Hud hud;
};