aboutsummaryrefslogtreecommitdiffstats
path: root/src/osx
diff options
context:
space:
mode:
Diffstat (limited to 'src/osx')
-rw-r--r--src/osx/mod.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/osx/mod.rs b/src/osx/mod.rs
index c4b047d..0cb4553 100644
--- a/src/osx/mod.rs
+++ b/src/osx/mod.rs
@@ -70,7 +70,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)
}
}
@@ -85,7 +85,8 @@ extern fn window_should_close(this: id, _: id) -> id {
}
impl Window {
- fn new_impl(dimensions: Option<(uint, uint)>, title: &str, monitor: Option<MonitorID>, visible: bool) -> Result<Window, CreationError> {
+ fn new_impl(dimensions: Option<(uint, uint)>, title: &str, monitor: Option<MonitorID>,
+ vsync: bool, visible: bool) -> Result<Window, CreationError> {
let app = match Window::create_app() {
Some(app) => app,
None => { return Err(OsError(format!("Couldn't create NSApplication"))); },
@@ -99,7 +100,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"))); },
};
@@ -206,7 +207,7 @@ impl Window {
}
}
- fn create_context(view: id) -> Option<id> {
+ fn create_context(view: id, vsync: bool) -> Option<id> {
unsafe {
let attributes = [
NSOpenGLPFADoubleBuffer as uint,
@@ -228,6 +229,10 @@ impl Window {
None
} else {
context.setView_(view);
+ if vsync {
+ let value = 1;
+ context.setValues_forParameter_(&value, NSOpenGLCPSwapInterval);
+ }
Some(context)
}
}