From 0c9b612bff7d88af8416c18147f9bc7d537a18ce Mon Sep 17 00:00:00 2001 From: "Stefanos A." Date: Tue, 14 Jan 2014 14:20:38 +0100 Subject: [PATCH] [OpenTK] Increase max Update/RenderFrame rates Given the new 144Hz monitors on the market today, it makes sense to increase the Update/RenderFrame limit from 200Hz to 500Hz. --- Source/OpenTK/GameWindow.cs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/OpenTK/GameWindow.cs b/Source/OpenTK/GameWindow.cs index 5cd8b81a..559c90b1 100644 --- a/Source/OpenTK/GameWindow.cs +++ b/Source/OpenTK/GameWindow.cs @@ -75,6 +75,8 @@ namespace OpenTK { #region --- Fields --- + const double MaxFrequency = 500.0; // Frequency cap for Update/RenderFrame events + readonly Stopwatch watch = new Stopwatch(); IGraphicsContext glContext; @@ -681,7 +683,7 @@ namespace OpenTK /// /// /// A value of 0.0 indicates that RenderFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities). - /// Values lower than 1.0Hz are clamped to 1.0Hz. Values higher than 200.0Hz are clamped to 200.0Hz. + /// Values lower than 1.0Hz are clamped to 0.0. Values higher than 500.0Hz are clamped to 200.0Hz. /// public double TargetRenderFrequency { @@ -699,11 +701,11 @@ namespace OpenTK { TargetRenderPeriod = 0.0; } - else if (value <= 200.0) + else if (value <= MaxFrequency) { TargetRenderPeriod = 1.0 / value; } - else Debug.Print("Target render frequency clamped to 200.0Hz."); // TODO: Where is it actually performed? + else Debug.Print("Target render frequency clamped to {0}Hz.", MaxFrequency); } } @@ -716,7 +718,7 @@ namespace OpenTK /// /// /// A value of 0.0 indicates that RenderFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities). - /// Values lower than 0.005 seconds (200Hz) are clamped to 0.0. Values higher than 1.0 seconds (1Hz) are clamped to 1.0. + /// Values lower than 0.002 seconds (500Hz) are clamped to 0.0. Values higher than 1.0 seconds (1Hz) are clamped to 1.0. /// public double TargetRenderPeriod { @@ -728,7 +730,7 @@ namespace OpenTK set { EnsureUndisposed(); - if (value <= 0.005) + if (value <= 1 / MaxFrequency) { target_render_period = 0.0; } @@ -749,7 +751,7 @@ namespace OpenTK /// /// /// A value of 0.0 indicates that UpdateFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities). - /// Values lower than 1.0Hz are clamped to 1.0Hz. Values higher than 200.0Hz are clamped to 200.0Hz. + /// Values lower than 1.0Hz are clamped to 0.0. Values higher than 500.0Hz are clamped to 500.0Hz. /// public double TargetUpdateFrequency { @@ -767,11 +769,11 @@ namespace OpenTK { TargetUpdatePeriod = 0.0; } - else if (value <= 200.0) + else if (value <= MaxFrequency) { TargetUpdatePeriod = 1.0 / value; } - else Debug.Print("Target update frequency clamped to 200.0Hz."); // TODO: Where is it actually performed? + else Debug.Print("Target render frequency clamped to {0}Hz.", MaxFrequency); } } @@ -784,7 +786,7 @@ namespace OpenTK /// /// /// A value of 0.0 indicates that UpdateFrame events are generated at the maximum possible frequency (i.e. only limited by the hardware's capabilities). - /// Values lower than 0.005 seconds (200Hz) are clamped to 0.0. Values higher than 1.0 seconds (1Hz) are clamped to 1.0. + /// Values lower than 0.002 seconds (500Hz) are clamped to 0.0. Values higher than 1.0 seconds (1Hz) are clamped to 1.0. /// public double TargetUpdatePeriod { @@ -796,7 +798,7 @@ namespace OpenTK set { EnsureUndisposed(); - if (value <= 0.005) + if (value <= 1 / MaxFrequency) { target_update_period = 0.0; } @@ -804,7 +806,7 @@ namespace OpenTK { target_update_period = value; } - else Debug.Print("Target update period clamped to 1.0 seconds."); // TODO: Where is it actually performed? + else Debug.Print("Target update period clamped to 1.0 seconds."); } }