tibia-client/src/framework/core/engine.h

78 lines
2.2 KiB
C
Raw Normal View History

2010-11-19 16:55:55 +01:00
/* The MIT License
*
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef ENGINE_H
#define ENGINE_H
2011-04-17 21:14:24 +02:00
#include <prerequisites.h>
#include <core/input.h>
2010-11-23 16:30:43 +01:00
class Engine
{
public:
2011-04-06 21:46:58 +02:00
Engine() : m_stopping(false),
m_running(false),
m_calculateFps(false) { }
void init();
void terminate();
/// Poll events
void poll();
/// Main loop
void run();
2010-11-23 16:30:43 +01:00
/// Stops main loop
void stop();
2010-11-23 16:30:43 +01:00
/// Change current game state
bool isRunning() const { return m_running; }
bool isStopping() const { return m_stopping; }
/// Fired by platform on window close
void onClose();
/// Fired by platform on window resize
2011-04-08 07:10:00 +02:00
void onResize(const Size& size);
/// Fired by platform on mouse/keyboard input
void onInputEvent(const InputEvent& event);
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
private:
bool m_stopping;
bool m_running;
2011-04-07 10:38:29 +02:00
bool m_calculateFps;
2011-04-15 04:13:53 +02:00
int m_lastFrameTicks;
};
extern Engine g_engine;
#endif // ENGINE_H