From 62bafe2130db5aaf32bd46091581086ae435e4cf Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Mon, 21 Sep 2015 13:15:43 +0200 Subject: Remove BuilderAttribs --- src/api/cocoa/headless.rs | 8 +++++--- src/api/cocoa/mod.rs | 17 +++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src/api/cocoa') diff --git a/src/api/cocoa/headless.rs b/src/api/cocoa/headless.rs index ad1a464..f9bbffd 100644 --- a/src/api/cocoa/headless.rs +++ b/src/api/cocoa/headless.rs @@ -1,8 +1,9 @@ use ContextError; use CreationError; use CreationError::OsError; -use BuilderAttribs; +use GlAttributes; use GlContext; +use PixelFormatRequirements; use libc; use std::ptr; @@ -27,8 +28,9 @@ pub struct HeadlessContext { } impl HeadlessContext { - pub fn new(builder: BuilderAttribs) -> Result { - let (width, height) = builder.window.dimensions.unwrap_or((1024, 768)); + pub fn new((width, height): (u32, u32), pf_reqs: &PixelFormatRequirements, + opengl: &GlAttributes<&HeadlessContext>) -> Result + { let context = unsafe { let attributes = [ NSOpenGLPFAAccelerated as u32, diff --git a/src/api/cocoa/mod.rs b/src/api/cocoa/mod.rs index 35b7046..539545c 100644 --- a/src/api/cocoa/mod.rs +++ b/src/api/cocoa/mod.rs @@ -7,7 +7,6 @@ use CreationError::OsError; use libc; use Api; -use BuilderAttribs; use ContextError; use GlAttributes; use GlContext; @@ -269,12 +268,14 @@ impl<'a> Iterator for WaitEventsIterator<'a> { impl Window { #[cfg(feature = "window")] - pub fn new(builder: BuilderAttribs) -> Result { - if builder.opengl.sharing.is_some() { + pub fn new(win_attribs: &WindowAttributes, pf_reqs: &PixelFormatRequirements, + opengl: &GlAttributes<&Window>) -> Result + { + if opengl.sharing.is_some() { unimplemented!() } - match builder.opengl.robustness { + match opengl.robustness { Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => { return Err(CreationError::RobustnessNotSupported); }, @@ -286,7 +287,7 @@ impl Window { None => { return Err(OsError(format!("Couldn't create NSApplication"))); }, }; - let window = match Window::create_window(&builder.window) + let window = match Window::create_window(win_attribs) { Some(window) => window, None => { return Err(OsError(format!("Couldn't create NSWindow"))); }, @@ -298,13 +299,13 @@ impl Window { // TODO: perhaps we should return error from create_context so we can // determine the cause of failure and possibly recover? - let (context, pf) = match Window::create_context(*view, &builder.pf_reqs, &builder.opengl) { + let (context, pf) = match Window::create_context(*view, pf_reqs, opengl) { Ok((context, pf)) => (context, pf), Err(e) => { return Err(OsError(format!("Couldn't create OpenGL context: {}", e))); }, }; unsafe { - if builder.window.transparent { + if win_attribs.transparent { let clear_col = { let cls = Class::get("NSColor").unwrap(); @@ -320,7 +321,7 @@ impl Window { } app.activateIgnoringOtherApps_(YES); - if builder.window.visible { + if win_attribs.visible { window.makeKeyAndOrderFront_(nil); } else { window.makeKeyWindow(); -- cgit v1.2.3