aboutsummaryrefslogtreecommitdiffstats
path: root/src/osx/mod.rs
diff options
context:
space:
mode:
authorJames Gilles <jameshgilles@gmail.com>2015-01-17 20:42:44 -0500
committerJames Gilles <jameshgilles@gmail.com>2015-01-17 20:42:44 -0500
commit211a3260363df63f07e0224c4677b1b43b1d0022 (patch)
tree787f76218d2908388ea963e8f61ce15058d42c2c /src/osx/mod.rs
parent495f6f886d1b2a1d1a253d6b4ae7b1df060ed700 (diff)
parent0e64651db8f19378d7c183b21c0e7d692380e570 (diff)
downloadglutin-211a3260363df63f07e0224c4677b1b43b1d0022.tar.gz
glutin-211a3260363df63f07e0224c4677b1b43b1d0022.zip
Merge PixelPirate's changes and fix merge conflicts
Diffstat (limited to 'src/osx/mod.rs')
-rw-r--r--src/osx/mod.rs15
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
];