aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/osx/mod.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/osx/mod.rs b/src/osx/mod.rs
index 7df6603..59b6577 100644
--- a/src/osx/mod.rs
+++ b/src/osx/mod.rs
@@ -44,6 +44,15 @@ static mut alt_pressed: bool = false;
static DELEGATE_NAME: &'static [u8] = b"glutin_window_delegate\0";
static DELEGATE_STATE_IVAR: &'static [u8] = b"glutin_state";
+// TODO: Should be added to cocoa bindings
+#[allow(non_camel_case_types)]
+#[deriving(Show)]
+enum NSOpenGLPFAOpenGLProfiles {
+ NSOpenGLProfileVersionLegacy = 0x1000,
+ NSOpenGLProfileVersion3_2Core = 0x3200,
+ NSOpenGLProfileVersion4_1Core = 0x4100
+}
+
struct DelegateState<'a> {
is_closed: bool,
context: id,
@@ -68,7 +77,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)
}
}
@@ -130,7 +139,7 @@ extern fn window_did_resize(this: id, _: id) -> id {
impl Window {
fn new_impl(dimensions: Option<(uint, uint)>, 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"))); },
@@ -144,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"))); },
};
@@ -260,7 +269,16 @@ 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 => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersionLegacy as uint,
+ Some((0...2, _)) => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersionLegacy as uint,
+ Some((3, 0)) => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersionLegacy as uint,
+ Some((3, 1...2)) => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersion3_2Core as uint,
+ Some((_, _)) => NSOpenGLPFAOpenGLProfiles::NSOpenGLProfileVersion4_1Core as uint,
+ }
+ };
unsafe {
let attributes = [
NSOpenGLPFADoubleBuffer as uint,
@@ -269,6 +287,7 @@ impl Window {
NSOpenGLPFAAlphaSize as uint, 8,
NSOpenGLPFADepthSize as uint, 24,
NSOpenGLPFAStencilSize as uint, 8,
+ NSOpenGLPFAOpenGLProfile as uint, profile,
0
];