2010-11-18 23:13:35 +01:00
|
|
|
#ifndef ENGINE_H
|
|
|
|
#define ENGINE_H
|
|
|
|
|
2011-07-13 23:12:36 +02:00
|
|
|
#include <global.h>
|
2011-07-17 02:13:53 +02:00
|
|
|
#include "input.h"
|
2010-11-23 16:30:43 +01:00
|
|
|
|
2010-11-18 23:13:35 +01:00
|
|
|
class Engine
|
|
|
|
{
|
|
|
|
public:
|
2011-04-06 21:46:58 +02:00
|
|
|
Engine() : m_stopping(false),
|
|
|
|
m_running(false),
|
2011-04-22 15:49:46 +02:00
|
|
|
m_calculateFps(false) { }
|
2010-11-18 23:13:35 +01:00
|
|
|
|
|
|
|
void init();
|
|
|
|
void terminate();
|
|
|
|
|
2011-04-22 15:49:46 +02:00
|
|
|
/// Poll events
|
|
|
|
void poll();
|
2010-11-21 22:48:58 +01:00
|
|
|
/// Main loop
|
2010-11-18 23:13:35 +01:00
|
|
|
void run();
|
2010-11-23 16:30:43 +01:00
|
|
|
|
|
|
|
/// Stops main loop
|
2010-11-18 23:13:35 +01:00
|
|
|
void stop();
|
|
|
|
|
2010-11-23 16:30:43 +01:00
|
|
|
/// Change current game state
|
2010-11-18 23:13:35 +01:00
|
|
|
bool isRunning() const { return m_running; }
|
|
|
|
bool isStopping() const { return m_stopping; }
|
|
|
|
|
2010-11-21 22:48:58 +01:00
|
|
|
/// Fired by platform on window close
|
2010-11-18 23:13:35 +01:00
|
|
|
void onClose();
|
2010-11-21 22:48:58 +01:00
|
|
|
/// Fired by platform on window resize
|
2011-04-08 07:10:00 +02:00
|
|
|
void onResize(const Size& size);
|
2010-11-21 22:48:58 +01:00
|
|
|
/// Fired by platform on mouse/keyboard input
|
2011-04-09 21:07:35 +02:00
|
|
|
void onInputEvent(const InputEvent& event);
|
2010-11-18 23:13:35 +01:00
|
|
|
|
2011-04-07 10:38:29 +02:00
|
|
|
/// Enable FPS counter on screen
|
|
|
|
void enableFpsCounter(bool enable = true) { m_calculateFps = enable; };
|
|
|
|
|
2011-04-17 22:09:37 +02:00
|
|
|
/// Return the current ticks on this frame
|
2011-04-17 21:14:24 +02:00
|
|
|
int getCurrentFrameTicks() const { return m_lastFrameTicks; }
|
2011-04-15 04:13:53 +02:00
|
|
|
|
2010-11-18 23:13:35 +01:00
|
|
|
private:
|
|
|
|
bool m_stopping;
|
|
|
|
bool m_running;
|
2011-04-07 10:38:29 +02:00
|
|
|
bool m_calculateFps;
|
2010-11-18 23:13:35 +01:00
|
|
|
|
2011-04-15 04:13:53 +02:00
|
|
|
int m_lastFrameTicks;
|
2010-11-18 23:13:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern Engine g_engine;
|
|
|
|
|
|
|
|
#endif // ENGINE_H
|
|
|
|
|