summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-03-19 23:05:20 -0600
committerIra Rice <irarice@gmail.com>2009-03-19 23:05:20 -0600
commit4b7755fcae0de15951c508ec034158007c8b6cf3 (patch)
treedf9cddb1231fc0812ac1d3910ab98762f554fbf3
parentc2c0a9fa8476b9335a6198b41cc702da82fd40bd (diff)
downloadmana-4b7755fcae0de15951c508ec034158007c8b6cf3.tar.gz
mana-4b7755fcae0de15951c508ec034158007c8b6cf3.tar.bz2
mana-4b7755fcae0de15951c508ec034158007c8b6cf3.tar.xz
mana-4b7755fcae0de15951c508ec034158007c8b6cf3.zip
Throttle framerates down to save CPU cycles. Now that we're getting high
framerates in OpenGL even on older hardware, this should be done to conserve on CPU usage, rather than stressing it with more frames than the monitor can render. Signed-off-by: Ira Rice <irarice@gmail.com>
-rw-r--r--src/game.cpp7
-rw-r--r--src/gui/setup_video.cpp32
-rw-r--r--src/main.cpp4
3 files changed, 25 insertions, 18 deletions
diff --git a/src/game.cpp b/src/game.cpp
index a346616f..7f0186d1 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -408,8 +408,11 @@ void Game::optionChanged(const std::string &name)
{
int fpsLimit = (int) config.getValue("fpslimit", 0);
- // Calculate new minimum frame time
- mMinFrameTime = fpsLimit ? 1000 / fpsLimit : 0;
+ // Calculate new minimum frame time. If one isn't set, use 60 FPS.
+ // (1000 / 60 is 16.66) Since the client can go well above the refresh
+ // rates for monitors now in OpenGL mode, this cutoff is done to help
+ // conserve on CPU time.
+ mMinFrameTime = fpsLimit ? 1000 / fpsLimit : 16;
// Reset draw time to current time
mDrawTime = tick_time * 10;
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index d1d7e4f8..e181f744 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -88,13 +88,15 @@ ModeListModel::ModeListModel()
SDL_Rect **modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
/* Check which modes are available */
- if (modes == (SDL_Rect **)0) {
+ if (modes == (SDL_Rect **)0)
logger->log("No modes available");
- } else if (modes == (SDL_Rect **)-1) {
+ else if (modes == (SDL_Rect **)-1)
logger->log("All resolutions available");
- } else {
+ else
+ {
//logger->log("Available Modes");
- for (int i = 0; modes[i]; ++i) {
+ for (int i = 0; modes[i]; ++i)
+ {
const std::string modeString =
toString((int)modes[i]->w) + "x" + toString((int)modes[i]->h);
//logger->log(modeString.c_str());
@@ -125,7 +127,7 @@ Setup_Video::Setup_Video():
mSpeechLabel(new Label("")),
mAlphaSlider(new Slider(0.2, 1.0)),
mFpsCheckBox(new CheckBox(_("FPS Limit:"))),
- mFpsSlider(new Slider(10, 200)),
+ mFpsSlider(new Slider(10, 120)),
mFpsField(new TextField),
mOriginalScrollLaziness((int) config.getValue("ScrollLaziness", 16)),
mScrollLazinessSlider(new Slider(1, 64)),
@@ -337,9 +339,11 @@ void Setup_Video::apply()
}
}
#ifdef WIN32
- } else {
+ }
+ else
+ {
new OkDialog(_("Switching to full screen"),
- _("Restart needed for changes to take effect."));
+ _("Restart needed for changes to take effect."));
}
#endif
config.setValue("screen", fullscreen ? true : false);
@@ -352,7 +356,7 @@ void Setup_Video::apply()
// OpenGL can currently only be changed by restarting, notify user.
new OkDialog(_("Changing OpenGL"),
- _("Applying change to OpenGL requires restart."));
+ _("Applying change to OpenGL requires restart."));
}
// FPS change
@@ -450,8 +454,9 @@ void Setup_Video::action(const gcn::ActionEvent &event)
{
config.setValue("particleeffects",
mParticleEffectsCheckBox->isSelected() ? true : false);
- new OkDialog(_("Particle effect settings changed"),
- _("Restart your client or change maps for the change to take effect."));
+ new OkDialog(_("Particle effect settings changed."),
+ _("Restart your client or change maps "
+ "for the change to take effect."));
}
else if (event.getId() == "pickupchat")
{
@@ -461,8 +466,7 @@ void Setup_Video::action(const gcn::ActionEvent &event)
else if (event.getId() == "pickupparticle")
{
config.setValue("showpickupparticle",
- mPickupParticleCheckBox->isSelected()
- ? true : false);
+ mPickupParticleCheckBox->isSelected() ? true : false);
}
else if (event.getId() == "speech")
{
@@ -576,9 +580,9 @@ void Setup_Video::keyPressed(gcn::KeyEvent &event)
{
mFps = 10;
}
- else if (mFps > 200)
+ else if (mFps > 120)
{
- mFps = 200;
+ mFps = 120;
}
mFpsField->setText(toString(mFps));
mFpsSlider->setValue(mFps);
diff --git a/src/main.cpp b/src/main.cpp
index 7ee2f6b4..a04c8696 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1101,9 +1101,9 @@ int main(int argc, char *argv[])
/*
* This loop can really stress the CPU, for no reason since it's
* just constantly redrawing the wallpaper. Added the following
- * usleep to limit it to 20 FPS during the login sequence
+ * usleep to limit it to 40 FPS during the login sequence
*/
- usleep(50000);
+ usleep(25000);
}
delete guiPalette;