diff --git a/Source/OpenTK/GLContext.cs b/Source/OpenTK/GLContext.cs
index c5e59145..dbe5e6cd 100644
--- a/Source/OpenTK/GLContext.cs
+++ b/Source/OpenTK/GLContext.cs
@@ -153,6 +153,15 @@ namespace OpenTK
return implementation.GetDisplayModes();
}
+ ///
+ /// Gets or sets a value indicating whether VSync is enabled.
+ ///
+ public bool VSync
+ {
+ get { return implementation.VSync; }
+ set { implementation.VSync = value; }
+ }
+
#endregion
#region IDisposable Members
diff --git a/Source/OpenTK/Platform/DummyGLContext.cs b/Source/OpenTK/Platform/DummyGLContext.cs
index a3916087..a46a3270 100644
--- a/Source/OpenTK/Platform/DummyGLContext.cs
+++ b/Source/OpenTK/Platform/DummyGLContext.cs
@@ -34,6 +34,8 @@ namespace OpenTK.Platform
public IntPtr GetAddress(string function) { return IntPtr.Zero; }
public IEnumerable GetDisplayModes() { return null; }
+ public bool VSync { get { return false; } set { } }
+
#endregion
#region --- IDisposable Members ---
diff --git a/Source/OpenTK/Platform/IGLContext.cs b/Source/OpenTK/Platform/IGLContext.cs
index 9797c0d2..b90f4afd 100644
--- a/Source/OpenTK/Platform/IGLContext.cs
+++ b/Source/OpenTK/Platform/IGLContext.cs
@@ -87,5 +87,10 @@ namespace OpenTK.Platform
///
/// An IEnumerable containing all supported display modes.
IEnumerable GetDisplayModes();
+
+ ///
+ /// Gets or sets a value indicating whether VSyncing is enabled.
+ ///
+ bool VSync { get; set; }
}
}
diff --git a/Source/OpenTK/Platform/Windows/WinGLContext.cs b/Source/OpenTK/Platform/Windows/WinGLContext.cs
index 411f412f..f3529f96 100644
--- a/Source/OpenTK/Platform/Windows/WinGLContext.cs
+++ b/Source/OpenTK/Platform/Windows/WinGLContext.cs
@@ -32,6 +32,7 @@ namespace OpenTK.Platform.Windows
private WindowInfo windowInfo = new WindowInfo();
private DisplayMode mode;
+ private bool vsync_supported;
private bool disposed;
@@ -232,6 +233,11 @@ namespace OpenTK.Platform.Windows
Wgl.Imports.MakeCurrent(deviceContext, renderContext);
Wgl.LoadAll();
+ vsync_supported =
+ (Wgl.ARB.SupportsExtension(this.deviceContext, "WGL_EXT_swap_control") ||
+ Wgl.EXT.SupportsExtension(this.deviceContext, "WGL_EXT_swap_control")) &&
+ Wgl.Load("wglGetSwapIntervalEXT") && Wgl.Load("wglSwapIntervalEXT");
+
if (source != null)
{
Debug.Print("Sharing state with context {0}", (source as WinGLContext).Context);
@@ -322,6 +328,19 @@ namespace OpenTK.Platform.Windows
#endregion
+ public bool VSync
+ {
+ get
+ {
+ //return vsync != 0;
+ return Wgl.EXT.GetSwapInterval() != 0;
+ }
+ set
+ {
+ Wgl.EXT.SwapInterval(value ? 1 : 0);
+ }
+ }
+
#endregion
#region --- IDisposable Members ---
diff --git a/Source/OpenTK/Platform/X11/X11GLContext.cs b/Source/OpenTK/Platform/X11/X11GLContext.cs
index d0cb8642..060e0a25 100644
--- a/Source/OpenTK/Platform/X11/X11GLContext.cs
+++ b/Source/OpenTK/Platform/X11/X11GLContext.cs
@@ -267,6 +267,18 @@ namespace OpenTK.Platform.X11
throw new Exception("The method or operation is not implemented.");
}
+ public bool VSync
+ {
+ get
+ {
+ return false;
+ }
+ set
+ {
+
+ }
+ }
+
#endregion
#region --- IDisposable Members ---