Added VSync property to IGLContext.
This commit is contained in:
parent
29b6f1660e
commit
4e421d30fb
5 changed files with 47 additions and 0 deletions
|
@ -153,6 +153,15 @@ namespace OpenTK
|
|||
return implementation.GetDisplayModes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether VSync is enabled.
|
||||
/// </summary>
|
||||
public bool VSync
|
||||
{
|
||||
get { return implementation.VSync; }
|
||||
set { implementation.VSync = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
|
|
@ -34,6 +34,8 @@ namespace OpenTK.Platform
|
|||
public IntPtr GetAddress(string function) { return IntPtr.Zero; }
|
||||
public IEnumerable<DisplayMode> GetDisplayModes() { return null; }
|
||||
|
||||
public bool VSync { get { return false; } set { } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- IDisposable Members ---
|
||||
|
|
|
@ -87,5 +87,10 @@ namespace OpenTK.Platform
|
|||
/// </summary>
|
||||
/// <returns>An IEnumerable containing all supported display modes.</returns>
|
||||
IEnumerable<DisplayMode> GetDisplayModes();
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether VSyncing is enabled.
|
||||
/// </summary>
|
||||
bool VSync { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 ---
|
||||
|
|
|
@ -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 ---
|
||||
|
|
Loading…
Reference in a new issue