Made get/set_swap_interval take and return an enum instead of i32

This commit is contained in:
Simon Heath
2017-07-13 22:08:11 -07:00
committed by Cobrand
parent 8264c3f283
commit 71a3dad7ae
+16 -3
View File
@@ -532,6 +532,15 @@ impl WindowContext {
}
}
/// Represents a setting for vsync/swap interval.
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[repr(i32)]
pub enum SwapInterval {
Immediate = 0,
VSync = 1,
LateSwapTearing = -1,
}
/// Represents the "shell" of a `Window`.
///
/// You can set get and set many of the SDL_Window properties (i.e., border, size, `PixelFormat`, etc)
@@ -771,12 +780,16 @@ impl VideoSubsystem {
}
}
pub fn gl_set_swap_interval(&self, interval: i32) -> bool {
pub fn gl_set_swap_interval(&self, interval: SwapInterval) -> bool {
unsafe { ll::SDL_GL_SetSwapInterval(interval as c_int) == 0 }
}
pub fn gl_get_swap_interval(&self) -> i32 {
unsafe { ll::SDL_GL_GetSwapInterval() as i32 }
pub fn gl_get_swap_interval(&self) -> SwapInterval {
unsafe {
let interval = ll::SDL_GL_GetSwapInterval() as i32;
assert!(interval == -1 || interval == 0 || interval == 1);
mem::transmute(interval)
}
}
}