From 19bb6c924e8a6068ce6b756ef55b5ad361b97a14 Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Sat, 21 Dec 2013 21:18:20 +0100 Subject: [PATCH] Gaphics: Make frame skip a config option When using something like Valgrind that will run mkxp 20 times slower than normal, frame skip will make the redraw loop completely grind to a halt. Set 'frameSkip' to false in the config to avert this. --- README.md | 1 + src/config.cpp | 2 ++ src/config.h | 1 + src/graphics.cpp | 18 +++++++++++++----- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 52aa41a..d0de3b6 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,7 @@ mkxp reads configuration data from the file "mkxp.conf" contained in the current | defScreenW | int | 640 | Width the game window starts in (this is **not** the game resolution) | | defScreenH | int | 480 | Height the game window starts in | | fixedFramerate | int | 0 | FPS will be fixed to this amount. Ignored if 0. | +| frameSkip | bool | true | Don't skip frames to catch up (useful eg. with Valgrind) | | solidFonts | bool | false | Don't use alpha blending for fonts | | gameFolder | string | "." | mkxp will look for all game related files here | | allowSymlinks | bool | false | Allow symlinks to be followed in the game folder. | diff --git a/src/config.cpp b/src/config.cpp index 3525b0e..d36287f 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -38,6 +38,7 @@ Config::Config() defScreenW(640), defScreenH(480), fixedFramerate(0), + frameSkip(true), solidFonts(false), gameFolder("."), allowSymlinks(false) @@ -58,6 +59,7 @@ void Config::read() READ_VAL(defScreenW, Int); READ_VAL(defScreenH, Int); READ_VAL(fixedFramerate, Int); + READ_VAL(frameSkip, Bool); READ_VAL(solidFonts, Bool); READ_VAL(gameFolder, ByteArray); READ_VAL(allowSymlinks, Bool); diff --git a/src/config.h b/src/config.h index 869b59e..4e2e3c5 100644 --- a/src/config.h +++ b/src/config.h @@ -41,6 +41,7 @@ struct Config int defScreenH; int fixedFramerate; + bool frameSkip; bool solidFonts; diff --git a/src/graphics.cpp b/src/graphics.cpp index 187af91..2934073 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -583,12 +583,20 @@ void Graphics::update() if (p->fpsLimiter.frameSkipRequired()) { - /* Skip frame */ - p->fpsLimiter.delay(); - ++p->frameCount; - p->threadData->ethread->notifyFrame(); + if (p->threadData->config.frameSkip) + { + /* Skip frame */ + p->fpsLimiter.delay(); + ++p->frameCount; + p->threadData->ethread->notifyFrame(); - return; + return; + } + else + { + /* Just reset frame adjust counter */ + p->fpsLimiter.resetFrameAdjust(); + } } p->checkResize();