diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-02-18 16:49:53 +0100 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2015-02-18 17:15:01 +0100 |
commit | f4f84c6566d99c297cddee3c712e94927f313204 (patch) | |
tree | f5ec7a833a54ed5371e8470b859dba14c41a553b /src/cocoa | |
parent | 8f8c1b71bcb8a41d15f421602fb61b293f62f175 (diff) | |
download | glutin-f4f84c6566d99c297cddee3c712e94927f313204.tar.gz glutin-f4f84c6566d99c297cddee3c712e94927f313204.zip |
Improve the OpenGL context request system
Diffstat (limited to 'src/cocoa')
-rw-r--r-- | src/cocoa/mod.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cocoa/mod.rs b/src/cocoa/mod.rs index 98b1879..2b8b342 100644 --- a/src/cocoa/mod.rs +++ b/src/cocoa/mod.rs @@ -5,7 +5,9 @@ use {CreationError, Event, MouseCursor}; use CreationError::OsError; use libc; +use Api; use BuilderAttribs; +use GlRequest; use cocoa::base::{Class, id, YES, NO, NSUInteger, nil, objc_allocateClassPair, class, objc_registerClassPair}; use cocoa::base::{selector, msg_send, msg_send_stret, class_addMethod, class_addIvar}; @@ -453,11 +455,18 @@ impl Window { } } - fn create_context(view: id, vsync: bool, gl_version: Option<(u32, u32)>) -> Option<id> { + fn create_context(view: id, vsync: bool, gl_version: GlRequest) -> 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, + GlRequest::Latest => NSOpenGLProfileVersion4_1Core as u32, + GlRequest::Specific(Api::OpenGl, (1 ... 2, _)) => NSOpenGLProfileVersionLegacy as u32, + GlRequest::Specific(Api::OpenGl, (3, 0)) => NSOpenGLProfileVersionLegacy as u32, + GlRequest::Specific(Api::OpenGl, (3, 1 ... 2)) => NSOpenGLProfileVersion3_2Core as u32, + GlRequest::Specific(Api::OpenGl, _) => NSOpenGLProfileVersion4_1Core as u32, + GlRequest::Specific(_, _) => panic!("Only the OpenGL API is supported"), // FIXME: return Result + GlRequest::GlThenGles { opengl_version: (1 ... 2, _), .. } => NSOpenGLProfileVersionLegacy as u32, + GlRequest::GlThenGles { opengl_version: (3, 0), .. } => NSOpenGLProfileVersionLegacy as u32, + GlRequest::GlThenGles { opengl_version: (3, 1 ... 2), .. } => NSOpenGLProfileVersion3_2Core as u32, + GlRequest::GlThenGles { .. } => NSOpenGLProfileVersion4_1Core as u32, }; unsafe { let attributes = [ |