Implement lists sharing
This commit is contained in:
parent
9668878f26
commit
4c0413bc7c
6 changed files with 55 additions and 21 deletions
|
|
@ -15,7 +15,8 @@ local_data_key!(WINDOW: (ffi::HWND, Sender<Event>))
|
|||
pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: String,
|
||||
builder_monitor: Option<super::MonitorID>,
|
||||
builder_gl_version: Option<(uint, uint)>, builder_debug: bool,
|
||||
builder_vsync: bool, builder_hidden: bool) -> Result<Window, CreationError>
|
||||
builder_vsync: bool, builder_hidden: bool,
|
||||
builder_sharelists: Option<ffi::HGLRC>) -> Result<Window, CreationError>
|
||||
{
|
||||
use std::mem;
|
||||
use std::os;
|
||||
|
|
@ -305,10 +306,16 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
|
|||
|
||||
let ctxt = unsafe {
|
||||
if extra_functions.CreateContextAttribsARB.is_loaded() {
|
||||
extra_functions.CreateContextAttribsARB(hdc, ptr::null(),
|
||||
attributes.as_slice().as_ptr())
|
||||
let share = if let Some(c) = builder_sharelists { c } else { ptr::null() };
|
||||
extra_functions.CreateContextAttribsARB(hdc, share,
|
||||
attributes.as_slice().as_ptr())
|
||||
|
||||
} else {
|
||||
ffi::wgl::CreateContext(hdc)
|
||||
let ctxt = ffi::wgl::CreateContext(hdc);
|
||||
if let Some(c) = builder_sharelists {
|
||||
ffi::wgl::ShareLists(c, ctxt);
|
||||
};
|
||||
ctxt
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,8 +25,9 @@ impl HeadlessContext {
|
|||
/// See the docs in the crate root file.
|
||||
pub fn new(builder: HeadlessRendererBuilder) -> Result<HeadlessContext, CreationError> {
|
||||
let HeadlessRendererBuilder { dimensions, gl_version, gl_debug } = builder;
|
||||
init::new_window(Some(dimensions), "".to_string(), None, gl_version, gl_debug, false, true)
|
||||
.map(|w| HeadlessContext(w))
|
||||
init::new_window(Some(dimensions), "".to_string(), None, gl_version, gl_debug, false, true,
|
||||
None)
|
||||
.map(|w| HeadlessContext(w))
|
||||
}
|
||||
|
||||
/// See the docs in the crate root file.
|
||||
|
|
@ -69,8 +70,9 @@ impl Window {
|
|||
/// See the docs in the crate root file.
|
||||
pub fn new(builder: WindowBuilder) -> Result<Window, CreationError> {
|
||||
let WindowBuilder { dimensions, title, monitor, gl_version,
|
||||
gl_debug, vsync, visible } = builder;
|
||||
init::new_window(dimensions, title, monitor, gl_version, gl_debug, vsync, !visible)
|
||||
gl_debug, vsync, visible, sharing } = builder;
|
||||
init::new_window(dimensions, title, monitor, gl_version, gl_debug, vsync,
|
||||
!visible, sharing.map(|w| w.window.context))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue