Skip to content

Commit

Permalink
Attempt to implement context sharing on Mac (#1132)
Browse files Browse the repository at this point in the history
Attempt to implement context sharing on Mac
  • Loading branch information
tene authored and goddessfreya committed Apr 2, 2019
1 parent 2695ebc commit 7d345fa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions glutin/src/platform/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ impl Context {
let transparent = wb.window.transparent;
let win = wb.build(el)?;

if gl_attr.sharing.is_some() {
unimplemented!()
}
let share_ctx = gl_attr.sharing.map_or(nil, |c| *c.get_id());

match gl_attr.robustness {
Robustness::RobustNoResetNotification
Expand All @@ -86,10 +84,9 @@ impl Context {
Some(pf) => pf,
};

// TODO: Add context sharing
let gl_context = IdRef::new(
NSOpenGLContext::alloc(nil)
.initWithFormat_shareContext_(*pixel_format, nil),
.initWithFormat_shareContext_(*pixel_format, share_ctx),
);
let gl_context = match gl_context.non_nil() {
Some(gl_context) => gl_context,
Expand Down Expand Up @@ -296,6 +293,14 @@ impl Context {
Context::HeadlessContext(ref c) => *c.context.deref() as *mut _,
}
}

#[inline]
fn get_id(&self) -> IdRef {
match self {
Context::WindowedContext(w) => w.context.clone(),
Context::HeadlessContext(h) => h.context.clone(),
}
}
}

#[derive(Debug)]
Expand Down

0 comments on commit 7d345fa

Please sign in to comment.