diff --git a/src/headless.rs b/src/headless.rs index a1e24a10a41..91125182f8c 100644 --- a/src/headless.rs +++ b/src/headless.rs @@ -33,7 +33,10 @@ impl<'a> HeadlessRendererBuilder<'a> { pub fn new(width: u32, height: u32) -> HeadlessRendererBuilder<'a> { HeadlessRendererBuilder { dimensions: (width, height), - pf_reqs: Default::default(), + pf_reqs: PixelFormatRequirements { + hardware_accelerated: None, + .. Default::default() + }, opengl: Default::default(), platform_specific: Default::default(), } diff --git a/src/platform/macos/helpers.rs b/src/platform/macos/helpers.rs index 81543c77f44..8ac965a9f99 100644 --- a/src/platform/macos/helpers.rs +++ b/src/platform/macos/helpers.rs @@ -10,14 +10,14 @@ use cocoa::base::nil; pub fn get_gl_profile( opengl: &GlAttributes<&T> -) -> Result, CreationError> { +) -> Result { let version = opengl.version.to_gl_version(); // first, compatibility profile support is strict if opengl.profile == Some(GlProfile::Compatibility) { // Note: we are not using ranges because of a rust bug that should be fixed here: // https://github.com/rust-lang/rust/pull/27050 if version.unwrap_or((2, 1)) < (3, 2) { - Ok(Some(NSOpenGLProfileVersionLegacy)) + Ok(NSOpenGLProfileVersionLegacy) } else { Err(CreationError::OpenGlVersionNotSupported) } @@ -26,9 +26,9 @@ pub fn get_gl_profile( if v < (3, 2) { Err(CreationError::OpenGlVersionNotSupported) } else if v == (3, 2) { - Ok(Some(NSOpenGLProfileVersion3_2Core)) + Ok(NSOpenGLProfileVersion3_2Core) } else { - Ok(Some(NSOpenGLProfileVersion4_1Core)) + Ok(NSOpenGLProfileVersion4_1Core) } } else if let GlRequest::Latest = opengl.version { // now, find the latest supported version automatically @@ -46,18 +46,18 @@ pub fn get_gl_profile( }; if id != nil { unsafe { msg_send![id, release] } - return Ok(Some(profile)); + return Ok(profile); } } // nothing else to do - Ok(None) + Ok(NSOpenGLProfileVersionLegacy) } else { Err(CreationError::OpenGlVersionNotSupported) } } pub fn build_nsattributes( - pf_reqs: &PixelFormatRequirements, profile: Option + pf_reqs: &PixelFormatRequirements, profile: NSOpenGLPFAOpenGLProfiles ) -> Result, CreationError> { // NOTE: OS X no longer has the concept of setting individual // color component's bit size. Instead we can only specify the @@ -68,6 +68,7 @@ pub fn build_nsattributes( let color_depth = pf_reqs.color_bits.unwrap_or(24) + alpha_depth; let mut attributes = vec![ + NSOpenGLPFAOpenGLProfile as u32, profile as u32, NSOpenGLPFAClosestPolicy as u32, NSOpenGLPFAColorSize as u32, color_depth as u32, NSOpenGLPFAAlphaSize as u32, alpha_depth as u32, @@ -80,10 +81,6 @@ pub fn build_nsattributes( attributes.push(NSOpenGLPFAAccelerated as u32); } - if let Some(profile) = profile { - attributes.push(NSOpenGLPFAOpenGLProfile as u32); attributes.push(profile as u32); - } - if let Some(true) = pf_reqs.double_buffer { attributes.push(NSOpenGLPFADoubleBuffer as u32); }