Fix VSync not being disabled when requested
@@ -413,7 +413,8 @@ impl<'a> ContextPrototype<'a> {
let (extra_functions, context) = self.create_context()?;
// vsync
- if self.opengl.vsync {
+ let swap_mode = if self.opengl.vsync { 1 } else { 0 };
+
let _guard = MakeCurrentGuard::new(&self.xconn, window, context)
.map_err(|err| CreationError::OsError(err))?;
@@ -425,7 +426,7 @@ impl<'a> ContextPrototype<'a> {
extra_functions.SwapIntervalEXT(
self.xconn.display as *mut _,
window,
- 1,
+ swap_mode,
);
}
@@ -439,27 +440,26 @@ impl<'a> ContextPrototype<'a> {
);
}
- if swap != 1 {
- return Err(CreationError::OsError(format!("Couldn't setup vsync: expected interval `1` but got `{}`", swap)));
+ if swap != swap_mode as u32 {
+ return Err(CreationError::OsError(format!("Couldn't setup vsync: expected interval `{}` but got `{}`", swap_mode, swap)));
}
} else if check_ext(&self.extensions, "GLX_MESA_swap_control")
&& extra_functions.SwapIntervalMESA.is_loaded()
{
unsafe {
- extra_functions.SwapIntervalMESA(1);
+ extra_functions.SwapIntervalMESA(swap_mode as u32);
}
} else if check_ext(&self.extensions, "GLX_SGI_swap_control")
&& extra_functions.SwapIntervalSGI.is_loaded()
{
unsafe {
- extra_functions.SwapIntervalSGI(1);
+ extra_functions.SwapIntervalSGI(swap_mode);
}
} else {
return Err(CreationError::OsError(
"Couldn't find any available vsync extension".to_string(),
));
}
- }
Ok(Context {
xconn: self.xconn,
