diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-14 20:58:26 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-05-14 20:58:26 +0000 |
commit | 0632377e8b2e63f965b30ac89a9e2dca819735ef (patch) | |
tree | 522477ab24f80baa393e0f9ecece14062483c810 /src/main.cpp | |
parent | 8381ec4111505692a9058db37412adb872bedd3e (diff) | |
download | mana-0632377e8b2e63f965b30ac89a9e2dca819735ef.tar.gz mana-0632377e8b2e63f965b30ac89a9e2dca819735ef.tar.bz2 mana-0632377e8b2e63f965b30ac89a9e2dca819735ef.tar.xz mana-0632377e8b2e63f965b30ac89a9e2dca819735ef.zip |
Added framerate limiter, off by default (0 means no limit)
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 8c871b6a..505cc647 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,6 +68,7 @@ unsigned char screen_mode; char *homeDir = NULL; int displayFlags, screenW, screenH, bitDepth; bool useOpenGL = false; +volatile int framesToDraw = 0; Sound sound; Music *bgm; @@ -77,6 +78,15 @@ Logger *logger; /**< Log object */ ItemManager *itemDb; /**< Item database object */ /** + * Allows the next frame to be drawn (part of framerate limiting) + */ +Uint32 nextFrame(Uint32 interval, void *param) +{ + framesToDraw++; + return interval; +} + +/** * Listener used for responding to map start error dialog. */ class MapStartErrorListener : public gcn::ActionListener { @@ -159,6 +169,7 @@ void init_engine() config.setValue("remember", 1); config.setValue("sfxVolume", 100); config.setValue("musicVolume", 60); + config.setValue("fpslimit", 0); // Checking if the configuration file exists... otherwise creates it with // default options ! @@ -296,6 +307,15 @@ void init_engine() new OkDialog("Sound Engine", err, &initWarningListener); logger->log("Warning: %s", err); } + + // Set frame counter when using fps limit + int fpsLimit = (int)config.getValue("fpslimit", 0); + if (fpsLimit) + { + if (fpsLimit < 20) fpsLimit = 20; + if (fpsLimit > 200) fpsLimit = 200; + SDL_AddTimer(1000 / fpsLimit, nextFrame, NULL); + } } /** Clear the engine */ |