This commit is contained in:
Eduardo Bart
2011-04-17 17:09:37 -03:00
parent 9b22a6e0a6
commit f2c187c810
8 changed files with 1773 additions and 42 deletions

View File

@@ -61,6 +61,7 @@ public:
/// Enable FPS counter on screen
void enableFpsCounter(bool enable = true) { m_calculateFps = enable; };
/// Return the current ticks on this frame
int getCurrentFrameTicks() const { return m_lastFrameTicks; }
private:

View File

@@ -36,13 +36,19 @@ public:
GameState() { }
virtual ~GameState() { }
/// Fired when enter the state
virtual void onEnter() = 0;
/// Fired when leaves the state
virtual void onLeave() = 0;
/// Fired when user tryes to close the window
virtual void onClose() = 0;
/// Fired for every user input event, this is called before processing UI input and if it returns false the input is not passed to the UI
virtual bool onInputEvent(const InputEvent& event) = 0;
/// Fired when main window is resized
virtual void onResize(const Size& size) = 0;
/// Fired before redering the UI
virtual void render() = 0;
};

View File

@@ -27,52 +27,53 @@
#include <prerequisites.h>
namespace Platform
class Platform
{
void init(const char *appName);
void terminate();
public:
static void init(const char *appName);
static void terminate();
/// Poll platform input/window events
void poll();
static void poll();
/// Get current time in milliseconds since init
int getTicks();
static int getTicks();
/// Sleep in current thread
void sleep(ulong miliseconds);
static void sleep(ulong miliseconds);
bool createWindow(int x, int y, int width, int height, int minWidth, int minHeight, bool maximized);
void destroyWindow();
void showWindow();
void setWindowTitle(const char *title);
bool isWindowFocused();
bool isWindowVisible();
int getWindowX();
int getWindowY();
int getWindowWidth();
int getWindowHeight();
bool isWindowMaximized();
static bool createWindow(int x, int y, int width, int height, int minWidth, int minHeight, bool maximized);
static void destroyWindow();
static void showWindow();
static void setWindowTitle(const char *title);
static bool isWindowFocused();
static bool isWindowVisible();
static int getWindowX();
static int getWindowY();
static int getWindowWidth();
static int getWindowHeight();
static bool isWindowMaximized();
int getDisplayHeight();
int getDisplayWidth();
static int getDisplayHeight();
static int getDisplayWidth();
/// Get GL extension function address
void *getExtensionProcAddress(const char *ext);
static void *getExtensionProcAddress(const char *ext);
/// Check if GL extension is supported
bool isExtensionSupported(const char *ext);
static bool isExtensionSupported(const char *ext);
const char *getClipboardText();
void setClipboardText(const char *text);
static const char *getClipboardText();
static void setClipboardText(const char *text);
void hideMouseCursor();
void showMouseCursor();
static void hideMouseCursor();
static void showMouseCursor();
/// Enable/disable vertical synchronization
void setVsync(bool enable = true);
static void setVsync(bool enable = true);
/// Swap GL buffers
void swapBuffers();
static void swapBuffers();
/// Get the app user directory, the place to save files configurations files
std::string getAppUserDir();
}
static std::string getAppUserDir();
};
#endif // PLATFORM_H