diff --git a/src/framework/configs.cpp b/src/framework/configs.cpp index 3aa7c085..92f79bfa 100644 --- a/src/framework/configs.cpp +++ b/src/framework/configs.cpp @@ -27,7 +27,7 @@ #include -Configs g_config; +Configs g_configs; bool Configs::load(const std::string& fileName) { @@ -99,43 +99,43 @@ void Configs::setValue(const std::string &key, bool value) setValue(key,"false"); } -const std::string &Configs::getString(const std::string &key) +const std::string &Configs::getString(const std::string &key) const { - auto iter = m_confsMap.find(key); - if(iter == m_confsMap.end()) { + auto it = m_confsMap.find(key); + if(it == m_confsMap.end()) { warning("Config value %s not found", key.c_str()); static std::string emptystr; return emptystr; } - return iter->second; + return it->second; } -float Configs::getFloat(const std::string &key) +float Configs::getFloat(const std::string &key) const { - auto iter = m_confsMap.find(key); - if(iter == m_confsMap.end()) { + auto it = m_confsMap.find(key); + if(it == m_confsMap.end()) { warning("Config value %s not found", key.c_str()); return 0; } - return convertType(iter->second); + return convertType(it->second); } -bool Configs::getBoolean(const std::string &key) +bool Configs::getBoolean(const std::string &key) const { - auto iter = m_confsMap.find(key); - if(iter == m_confsMap.end()) { + auto it = m_confsMap.find(key); + if(it == m_confsMap.end()) { warning("Config value %s not found", key.c_str()); return 0; } - return (iter->second == "true"); + return (it->second == "true"); } -int Configs::getInteger(const std::string &key) +int Configs::getInteger(const std::string &key) const { - auto iter = m_confsMap.find(key); - if(iter == m_confsMap.end()) { + auto it = m_confsMap.find(key); + if(it == m_confsMap.end()) { warning("Config value %s not found", key.c_str()); return 0; } - return convertType(iter->second); + return convertType(it->second); } diff --git a/src/framework/configs.h b/src/framework/configs.h index 6bf33a10..f989a62b 100644 --- a/src/framework/configs.h +++ b/src/framework/configs.h @@ -44,16 +44,16 @@ public: void setValue(const std::string &key, bool value); void setValue(const std::string &key, int value); - const std::string &getString(const std::string &key); - float getFloat(const std::string &key); - bool getBoolean(const std::string &key); - int getInteger(const std::string &key); + const std::string &getString(const std::string &key) const; + float getFloat(const std::string &key) const; + bool getBoolean(const std::string &key) const; + int getInteger(const std::string &key) const; private: std::string m_fileName; std::map m_confsMap; }; -extern Configs g_config; +extern Configs g_configs; #endif // CONFIGS_H diff --git a/src/framework/font.h b/src/framework/font.h index 8cb26892..3d5c4f77 100644 --- a/src/framework/font.h +++ b/src/framework/font.h @@ -36,12 +36,10 @@ public: /// Load font from file bool load(const std::string &file); - std::string& getName() { return m_name; } + const std::string& getName() const { return m_name; } private: std::string m_name; }; -typedef std::shared_ptr FontPtr; - #endif // FONT_H diff --git a/src/framework/framebuffer.cpp b/src/framework/framebuffer.cpp index 9cc17732..a846b553 100644 --- a/src/framework/framebuffer.cpp +++ b/src/framework/framebuffer.cpp @@ -62,7 +62,7 @@ FrameBuffer::FrameBuffer(int width, int height) oglDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)Platform::getExtensionProcAddress("glDeleteFramebuffers"); oglCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)Platform::getExtensionProcAddress("glCheckFramebufferStatus"); } - + // generate FBO oglGenFramebuffers(1, &m_fbo); oglBindFramebuffer(GL_FRAMEBUFFER_EXT, m_fbo); diff --git a/src/framework/graphics.h b/src/framework/graphics.h index fafa5f40..1030baed 100644 --- a/src/framework/graphics.h +++ b/src/framework/graphics.h @@ -40,6 +40,7 @@ public: void init(); void terminate(); + /// Check if a GL extension is supported bool isExtensionSupported(const char *extension); /// Called after every window resize diff --git a/src/main.cpp b/src/main.cpp index 65acfafe..769b77c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -53,22 +53,22 @@ void setDefaultConfigs() int defHeight = 480; // init on screen center - g_config.setValue("window x", (Platform::getDisplayWidth() - defWidth)/2); - g_config.setValue("window y", (Platform::getDisplayHeight() - defHeight)/2); + g_configs.setValue("window x", (Platform::getDisplayWidth() - defWidth)/2); + g_configs.setValue("window y", (Platform::getDisplayHeight() - defHeight)/2); - g_config.setValue("window width", defWidth); - g_config.setValue("window height", defHeight); - g_config.setValue("window maximized", false); + g_configs.setValue("window width", defWidth); + g_configs.setValue("window height", defHeight); + g_configs.setValue("window maximized", false); } void saveConfigs() { - g_config.setValue("window x", Platform::getWindowX()); - g_config.setValue("window y", Platform::getWindowY()); - g_config.setValue("window width", Platform::getWindowWidth()); - g_config.setValue("window height", Platform::getWindowHeight()); - g_config.setValue("window maximized", Platform::isWindowMaximized()); - g_config.save(); + g_configs.setValue("window x", Platform::getWindowX()); + g_configs.setValue("window y", Platform::getWindowY()); + g_configs.setValue("window width", Platform::getWindowWidth()); + g_configs.setValue("window height", Platform::getWindowHeight()); + g_configs.setValue("window maximized", Platform::isWindowMaximized()); + g_configs.save(); } int main(int argc, const char *argv[]) @@ -90,16 +90,16 @@ int main(int argc, const char *argv[]) setDefaultConfigs(); // load configurations - if(!g_config.load("config.yml")) + if(!g_configs.load("config.yml")) notice("Could not read configuration file, default configurations will be used."); notice("OTClient 0.1.0"); // create the window - Platform::createWindow(g_config.getInteger("window x"), g_config.getInteger("window y"), - g_config.getInteger("window width"), g_config.getInteger("window height"), + Platform::createWindow(g_configs.getInteger("window x"), g_configs.getInteger("window y"), + g_configs.getInteger("window width"), g_configs.getInteger("window height"), 640, 480, - g_config.getBoolean("window maximized")); + g_configs.getBoolean("window maximized")); Platform::setWindowTitle("OTClient"); Platform::setVsync(); @@ -108,7 +108,7 @@ int main(int argc, const char *argv[]) // state scope { - std::shared_ptr menuState(new MenuState()); + std::shared_ptr menuState(new MenuState); g_engine.changeState(menuState.get()); Platform::showWindow();