From 37f4e58a02acfdf515e40e6b73ac16f895e0e501 Mon Sep 17 00:00:00 2001 From: Daniel Evans Date: Tue, 2 Jul 2013 11:48:01 +0100 Subject: [PATCH] Initial log framework and timekeeping --- framework2/GTAEngine.cpp | 12 ++++++- framework2/GTARenderer.cpp | 2 +- .../include/renderwure/engine/GTAEngine.hpp | 31 +++++++++++++++++++ viewer/main.cpp | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/framework2/GTAEngine.cpp b/framework2/GTAEngine.cpp index e1278b51..908bf8b0 100644 --- a/framework2/GTAEngine.cpp +++ b/framework2/GTAEngine.cpp @@ -2,7 +2,7 @@ #include GTAEngine::GTAEngine(const std::string& path) -: gameData(path) +: gameData(path), gameTime(0.f) { } @@ -14,6 +14,16 @@ bool GTAEngine::load() return true; } +void GTAEngine::logInfo(const std::string& info) +{ + log.push({LogEntry::Info, gameTime, info}); +} + +void GTAEngine::logError(const std::string& error) +{ + log.push({LogEntry::Error, gameTime, error}); +} + bool GTAEngine::loadItems(const std::string& name) { auto i = gameData.iplLocations.find(name); diff --git a/framework2/GTARenderer.cpp b/framework2/GTARenderer.cpp index 1eb9bd6d..8aa19793 100644 --- a/framework2/GTARenderer.cpp +++ b/framework2/GTARenderer.cpp @@ -55,7 +55,7 @@ GLuint compileShader(GLenum type, const char *source) GTARenderer::GTARenderer() : camera() -{ +{ GLuint vertexShader = compileShader(GL_VERTEX_SHADER, vertexShaderSource); GLuint fragmentShader = compileShader(GL_FRAGMENT_SHADER, fragmentShaderSource); GLuint worldProgram = glCreateProgram(); diff --git a/framework2/include/renderwure/engine/GTAEngine.hpp b/framework2/include/renderwure/engine/GTAEngine.hpp index 5f4b69de..a5ec68e5 100644 --- a/framework2/include/renderwure/engine/GTAEngine.hpp +++ b/framework2/include/renderwure/engine/GTAEngine.hpp @@ -9,6 +9,7 @@ #include #include +#include /** * @class GTAEngine @@ -25,6 +26,31 @@ public: */ bool load(); + struct LogEntry + { + enum Type { + Info, + Error, + Warning + }; + + Type type; + float time; + std::string message; + }; + + std::queue log; + + /** + * Displays an informative message + */ + void logInfo(const std::string& info); + + /** + * Displays an alarming error + */ + void logError(const std::string& error); + /** * Loads an IPL into the game. * @param name The name of the IPL as it appears in the games' gta.dat @@ -36,6 +62,11 @@ public: */ glm::vec3 itemCentroid; + /** + * Game Clock + */ + float gameTime; + /** * Game data */ diff --git a/viewer/main.cpp b/viewer/main.cpp index ca32b20e..0a28aa29 100644 --- a/viewer/main.cpp +++ b/viewer/main.cpp @@ -11,6 +11,7 @@ #include #include +#include constexpr int WIDTH = 800, HEIGHT = 600;