From f4f84c6566d99c297cddee3c712e94927f313204 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 18 Feb 2015 16:49:53 +0100 Subject: Improve the OpenGL context request system --- src/cocoa/mod.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/cocoa') 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 { + fn create_context(view: id, vsync: bool, gl_version: GlRequest) -> Option { 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 = [ -- cgit v1.2.3