add framelimiter as per Joseph_Vissarion's patch

This commit is contained in:
Chris Forbes
2011-11-26 16:17:23 +13:00
parent 8bdab6a5f2
commit 58a6c01c3b
2 changed files with 14 additions and 0 deletions

View File

@@ -326,8 +326,20 @@ namespace OpenRA
internal static void Run()
{
while (!quit)
{
var idealFrameTime = 1.0 / Settings.Graphics.MaxFramerate;
var sw = new Stopwatch();
Tick( orderManager, viewport );
if (Settings.Graphics.CapFramerate)
{
var waitTime = idealFrameTime - sw.ElapsedTime();
if (waitTime > 0)
System.Threading.Thread.Sleep( TimeSpan.FromSeconds(waitTime) );
}
}
OnQuit();
}

View File

@@ -60,6 +60,8 @@ namespace OpenRA.GameRules
public int2 FullscreenSize = new int2(0,0);
public int2 WindowedSize = new int2(1024, 768);
public bool PixelDouble = false;
public bool CapFramerate = false;
public int MaxFramerate = 60;
public int BatchSize = 8192;
public int NumTempBuffers = 8;