diff options
Diffstat (limited to 'src/osx/mod.rs')
-rw-r--r-- | src/osx/mod.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/osx/mod.rs b/src/osx/mod.rs index 59d979a..4b111bf 100644 --- a/src/osx/mod.rs +++ b/src/osx/mod.rs @@ -4,6 +4,7 @@ pub use self::headless::HeadlessContext; use {CreationError, Event, MouseCursor}; use CreationError::OsError; use libc; +use std::ascii::AsciiExt; use BuilderAttribs; @@ -71,7 +72,7 @@ impl Window { unimplemented!() } - Window::new_impl(builder.dimensions, builder.title.as_slice(), builder.monitor, builder.vsync, builder.visible) + Window::new_impl(builder.dimensions, builder.title.as_slice(), builder.monitor, builder.vsync, builder.visible, builder.gl_version) } } @@ -138,7 +139,7 @@ extern fn window_did_resize(this: id, _: id) -> id { impl Window { fn new_impl(dimensions: Option<(u32, u32)>, title: &str, monitor: Option<MonitorID>, - vsync: bool, visible: bool) -> Result<Window, CreationError> { + vsync: bool, visible: bool, gl_version: Option<(uint, uint)>) -> Result<Window, CreationError> { let app = match Window::create_app() { Some(app) => app, None => { return Err(OsError(format!("Couldn't create NSApplication"))); }, @@ -152,7 +153,7 @@ impl Window { None => { return Err(OsError(format!("Couldn't create NSView"))); }, }; - let context = match Window::create_context(view, vsync) { + let context = match Window::create_context(view, vsync, gl_version) { Some(context) => context, None => { return Err(OsError(format!("Couldn't create OpenGL context"))); }, }; @@ -268,7 +269,12 @@ impl Window { } } - fn create_context(view: id, vsync: bool) -> Option<id> { + fn create_context(view: id, vsync: bool, gl_version: Option<(uint, uint)>) -> Option<id> { + let profile = match gl_version { + None | Some((0...2, _)) | Some((3, 0)) => NSOpenGLProfileVersionLegacy as uint, + Some((3, 1...2)) => NSOpenGLProfileVersion3_2Core as uint, + Some((_, _)) => NSOpenGLProfileVersion4_1Core as uint, + }; unsafe { let attributes = [ NSOpenGLPFADoubleBuffer as u32, @@ -277,6 +283,7 @@ impl Window { NSOpenGLPFAAlphaSize as u32, 8, NSOpenGLPFADepthSize as u32, 24, NSOpenGLPFAStencilSize as u32, 8, + NSOpenGLPFAOpenGLProfile as u32, profile, 0 ]; |