Permalink
Browse files

[All] Fixed checks for EXT_swap_control_tear

EGL and NSOpenGL do not offer an EXT_swap_control_tear equivalent so
use regular vsync for now. The relevant extension string is now
correctly checked on WGL and GLX.
  • Loading branch information...
1 parent ab6b3c2 commit 3da459b316e2cf513f4244d8873d170251ad3e6c @thefiddler thefiddler committed Apr 29, 2014
@@ -125,6 +125,12 @@ public override int SwapInterval
}
set
{
+ if (value < 0)
+ {
+ // EGL does not offer EXT_swap_control_tear yet
+ value = 1;
+ }
+
if (Egl.SwapInterval(WindowInfo.Display, value))
swap_interval = value;
else
@@ -257,6 +257,11 @@ public override int SwapInterval
}
set
{
+ if (value < 0)
+ {
+ // NSOpenGL does not offer EXT_swap_control_tear yet
+ value = 1;
+ }
SetContextValue(value, NSOpenGLContextParameter.SwapInterval);
}
}
@@ -351,7 +351,7 @@ public override void LoadAll()
Wgl.SupportsFunction("wglGetSwapIntervalEXT") &&
Wgl.SupportsFunction("wglSwapIntervalEXT");
vsync_tear_supported =
- Wgl.SupportsExtension(DeviceContext, "WGL_EXT_swap_tear");
+ Wgl.SupportsExtension(DeviceContext, "WGL_EXT_swap_control_tear");
}
base.LoadAll();
@@ -30,6 +30,7 @@ internal sealed class X11GLContext : DesktopGraphicsContext
IntPtr display;
X11WindowInfo currentWindow;
bool vsync_supported;
+ bool vsync_tear_supported;
int swap_interval = 1; // As defined in GLX_SGI_swap_control
readonly X11GraphicsMode ModeSelector = new X11GraphicsMode();
@@ -362,6 +363,11 @@ public override int SwapInterval
{
if (vsync_supported)
{
+ if (value < 0 && !vsync_tear_supported)
+ {
+ value = 1;
+ }
+
ErrorCode error_code = 0;
using (new XLock(Display))
error_code = Glx.Sgi.SwapInterval(value);
@@ -381,8 +387,10 @@ public override int SwapInterval
public override void LoadAll()
{
vsync_supported =
- SupportsExtension(display, currentWindow, "SupportsExtension") &&
+ SupportsExtension(display, currentWindow, "GLX_SGI_swap_control") &&
Glx.SupportsFunction("glXSwapIntervalSGI");
+ vsync_tear_supported =
+ SupportsExtension(display, currentWindow, "GLX_EXT_swap_control_tear");
Debug.Print("Context supports vsync: {0}.", vsync_supported);
base.LoadAll();

0 comments on commit 3da459b

Please sign in to comment.