Hi people,
Here's the patch for limiting megaglest's FPS, since it would otherwise burn up my CPU.
Since I don't know how to attach file, I will just paste the content of the patch:
--- ./source/glest_game/main/main.cpp.orig 2011-09-05 11:52:33.232676996 -0400
+++ ./source/glest_game/main/main.cpp 2011-07-16 13:47:35.716676997 -0400
@@ -2999,8 +2999,16 @@
//time_t lastTextureLoadEvent = time(NULL);
//main loop
+ int interval = 1;
while(Window::handleEvent()) {
program->loop();
+ if (program->getFPS() > 1) {
+ if (interval == 1) interval = (1000000.00 / ((double) program->getFPS()));
+ usleep(interval);
+ }
+ else if (program->getFPS() == 0) {
+ usleep(30000);
+ }
// Because OpenGL really doesn't do multi-threading well
// if(difftime(time(NULL),lastTextureLoadEvent) >= 3) {
// lastTextureLoadEvent = time(NULL);
--- ./source/glest_game/main/program.cpp.orig 2011-09-05 11:52:43.845676996 -0400
+++ ./source/glest_game/main/program.cpp 2011-07-16 10:34:26.323676997 -0400
@@ -575,13 +575,17 @@
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
+int Program::getFPS(){
+ return freq;
+}
+
void Program::setDisplaySettings(){
Config &config= Config::getInstance();
- if(!config.getBool("Windowed")) {
+ freq = config.getInt("RefreshFrequency");
- int freq= config.getInt("RefreshFrequency");
+ if(!config.getBool("Windowed")) {
int colorBits= config.getInt("ColorBits");
int screenWidth= config.getInt("ScreenWidth");
int screenHeight= config.getInt("ScreenHeight");
--- ./source/glest_game/main/program.h.orig 2011-09-05 11:52:50.115676996 -0400
+++ ./source/glest_game/main/program.h 2011-07-16 08:50:46.762676996 -0400
@@ -139,6 +139,7 @@
GraphicMessageBox msgBox;
int skipRenderFrameCount;
+ int freq;
public:
Program();
@@ -151,6 +152,7 @@
void initServer(WindowGl *window,bool autostart=false,bool openNetworkSlots=false);
void initClient(WindowGl *window, const Ip &serverIp);
void initScenario(WindowGl *window, string autoloadScenarioName);
+ int getFPS();
//main
void keyDown(char key);