[OpenTK] Query the driver for VSyncMode getter
authorthefiddler <stapostol@gmail.com>
Tue, 29 Apr 2014 06:31:47 +0000 (08:31 +0200)
committerthefiddler <stapostol@gmail.com>
Tue, 29 Apr 2014 06:31:47 +0000 (08:31 +0200)
Otherwise, the user could call Context.SwapInterval directly, causing
the vsync property to fall out of sync.

Source/OpenTK/GameWindow.cs

index 323f97c..41029bc 100644 (file)
@@ -98,8 +98,6 @@ namespace OpenTK
 
         bool is_running_slowly; // true, when UpdatePeriod cannot reach TargetUpdatePeriod
 
-        VSyncMode vsync;
-
         FrameEventArgs update_args = new FrameEventArgs();
         FrameEventArgs render_args = new FrameEventArgs();
 
@@ -884,7 +882,18 @@ namespace OpenTK
             {
                 EnsureUndisposed();
                 GraphicsContext.Assert();
-                return vsync;
+                if (Context.SwapInterval < 0)
+                {
+                    return VSyncMode.Adaptive;
+                }
+                else if (Context.SwapInterval == 0)
+                {
+                    return VSyncMode.Off;
+                }
+                else
+                {
+                    return VSyncMode.On;
+                }
             }
             set
             {
@@ -904,7 +913,6 @@ namespace OpenTK
                         Context.SwapInterval = -1;
                         break;
                 }
-                vsync = value;
             }
         }