X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FEngine.hh;h=a0c23002080ff5ef65fa1a336cedd1294e101a35;hp=76120c49c890b45bba4beb618504f3ea76403df2;hb=892da43bf5796e7c5f593a6d0f53bd797a36bd3e;hpb=72d4af22710317acffab861421c4364b1780b6fe diff --git a/src/Moof/Engine.hh b/src/Moof/Engine.hh index 76120c4..a0c2300 100644 --- a/src/Moof/Engine.hh +++ b/src/Moof/Engine.hh @@ -29,54 +29,57 @@ #ifndef _MOOF_ENGINE_HH_ #define _MOOF_ENGINE_HH_ -#include - #include -#include -#include +#include +#include #include -#include namespace Mf { -// forward declaration +// forward declarations class Video; -class Engine : public Singleton +struct Engine { -public: - Engine(int argc, char* argv[], const std::string& configFile, - const std::string& name, const std::string& iconFile); - virtual ~Engine(); + Engine(int argc, char* argv[], const std::string& name, + const std::string& iconFile, const std::string& configFile); + ~Engine() {} + + // get global instance + static Engine& getInstance(); - int run(); - void stop(int exitCode = 0); + void run(); void setTimestep(Scalar ts); - Scalar getTimestep(); + Scalar getTimestep() const; void setMaxFrameRate(long maxFps); - long getMaxFrameRate(); + long getMaxFrameRate() const; - Video& getVideo(); - long getFrameRate(); + Video& getVideo() const; + long getFrameRate() const; - // Override these if you want. - virtual void update(Scalar t, Scalar dt); - virtual void draw(Scalar alpha); - virtual void handleEvent(const Event& event); + void pushLayer(LayerP layer); + void popLayer(); + void popLayer(Layer* layer); + void clearLayers(); - struct Exception : std::runtime_error + struct Exception : public Mf::Exception { - explicit Exception(const std::string& what_arg) : - std::runtime_error(what_arg) {} + explicit Exception(unsigned error) : + Mf::Exception(error) {} + + void raise() + { + throw *this; + } }; private: - class EngineImpl; - boost::shared_ptr impl_; + class Impl; + boost::shared_ptr impl_; };