From 23b108d4366ddf3bf134c443b19bff609247c1fd Mon Sep 17 00:00:00 2001 From: David Partouche Date: Wed, 26 Nov 2014 14:38:42 +0100 Subject: Added swap interval to osx --- src/osx/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/osx') diff --git a/src/osx/mod.rs b/src/osx/mod.rs index 7209aa4..8ab3efd 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -75,7 +75,7 @@ impl Window { unimplemented!() } - Window::new_impl(builder.dimensions, builder.title.as_slice(), builder.monitor, true) + Window::new_impl(builder.dimensions, builder.title.as_slice(), builder.monitor, builder.vsync, true) } } @@ -98,7 +98,8 @@ extern fn window_should_close(this: id, _: id) -> id { } impl Window { - fn new_impl(dimensions: Option<(uint, uint)>, title: &str, monitor: Option, visible: bool) -> Result { + fn new_impl(dimensions: Option<(uint, uint)>, title: &str, monitor: Option, + vsync: bool, visible: bool) -> Result { let app = match Window::create_app() { Some(app) => app, None => { return Err(OsError(format!("Couldn't create NSApplication"))); }, @@ -112,7 +113,7 @@ impl Window { None => { return Err(OsError(format!("Couldn't create NSView"))); }, }; - let context = match Window::create_context(view) { + let context = match Window::create_context(view, vsync) { Some(context) => context, None => { return Err(OsError(format!("Couldn't create OpenGL context"))); }, }; @@ -219,7 +220,7 @@ impl Window { } } - fn create_context(view: id) -> Option { + fn create_context(view: id, vsync: bool) -> Option { unsafe { let attributes = [ NSOpenGLPFADoubleBuffer as uint, @@ -241,6 +242,10 @@ impl Window { None } else { context.setView_(view); + if vsync { + let value = 1; + context.setValues_forParameter_(&value, NSOpenGLCPSwapInterval); + } Some(context) } } -- cgit v1.2.3