From 7ebf5fe39a7d6348fd6ca85e19900b40279880f2 Mon Sep 17 00:00:00 2001 From: Simon Heath Date: Tue, 11 Jul 2017 09:57:04 -0400 Subject: [PATCH] Made gl_set_swap_interval() take Into --- src/sdl2/video.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/sdl2/video.rs b/src/sdl2/video.rs index 497807d7..666063bb 100644 --- a/src/sdl2/video.rs +++ b/src/sdl2/video.rs @@ -541,6 +541,17 @@ pub enum SwapInterval { LateSwapTearing = -1, } +impl From for SwapInterval { + fn from(i: i32) -> Self { + match i { + -1 => SwapInterval::LateSwapTearing, + 0 => SwapInterval::Immediate, + 1 => SwapInterval::VSync, + other => panic!("Invalid value for SwapInterval: {}; valid values are -1, 0, 1", other), + } + } +} + /// Represents the "shell" of a `Window`. /// /// You can set get and set many of the SDL_Window properties (i.e., border, size, `PixelFormat`, etc) @@ -780,8 +791,8 @@ impl VideoSubsystem { } } - pub fn gl_set_swap_interval(&self, interval: SwapInterval) -> bool { - unsafe { ll::SDL_GL_SetSwapInterval(interval as c_int) == 0 } + pub fn gl_set_swap_interval>(&self, interval: S) -> bool { + unsafe { ll::SDL_GL_SetSwapInterval(interval.into() as c_int) == 0 } } pub fn gl_get_swap_interval(&self) -> SwapInterval {