aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/osx/mod.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/osx/mod.rs b/src/osx/mod.rs
index 59d979a..86a891c 100644
--- a/src/osx/mod.rs
+++ b/src/osx/mod.rs
@@ -71,7 +71,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 +138,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<(u32, u32)>) -> Result<Window, CreationError> {
let app = match Window::create_app() {
Some(app) => app,
None => { return Err(OsError(format!("Couldn't create NSApplication"))); },
@@ -152,7 +152,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 +268,12 @@ impl Window {
}
}
- fn create_context(view: id, vsync: bool) -> Option<id> {
+ fn create_context(view: id, vsync: bool, gl_version: Option<(u32, u32)>) -> Option<id> {
+ let profile = match gl_version {
+ None | Some((0...2, _)) | Some((3, 0)) => NSOpenGLProfileVersionLegacy as u32,
+ Some((3, 1...2)) => NSOpenGLProfileVersion3_2Core as u32,
+ Some((_, _)) => NSOpenGLProfileVersion4_1Core as u32,
+ };
unsafe {
let attributes = [
NSOpenGLPFADoubleBuffer as u32,
@@ -277,6 +282,7 @@ impl Window {
NSOpenGLPFAAlphaSize as u32, 8,
NSOpenGLPFADepthSize as u32, 24,
NSOpenGLPFAStencilSize as u32, 8,
+ NSOpenGLPFAOpenGLProfile as u32, profile,
0
];