Unify WindowBuilder and HeadlessRendererBuilder for easier implementations
This commit is contained in:
parent
fb42768a14
commit
b9710f05a9
8 changed files with 76 additions and 61 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use HeadlessRendererBuilder;
|
||||
use BuilderAttribs;
|
||||
use CreationError;
|
||||
use CreationError::OsError;
|
||||
use libc;
|
||||
|
|
@ -13,11 +13,13 @@ pub struct HeadlessContext {
|
|||
}
|
||||
|
||||
impl HeadlessContext {
|
||||
pub fn new(builder: HeadlessRendererBuilder) -> Result<HeadlessContext, CreationError> {
|
||||
pub fn new(builder: BuilderAttribs) -> Result<HeadlessContext, CreationError> {
|
||||
let dimensions = builder.dimensions.unwrap();
|
||||
|
||||
Ok(HeadlessContext {
|
||||
width: builder.dimensions.0,
|
||||
height: builder.dimensions.1,
|
||||
buffer: Vec::from_elem(builder.dimensions.0 * builder.dimensions.1, unsafe { mem::uninitialized() }),
|
||||
width: dimensions.0,
|
||||
height: dimensions.1,
|
||||
buffer: Vec::from_elem(dimensions.0 * dimensions.1, unsafe { mem::uninitialized() }),
|
||||
context: unsafe {
|
||||
let ctxt = ffi::OSMesaCreateContext(0x1908, ptr::null());
|
||||
if ctxt.is_null() {
|
||||
|
|
|
|||
|
|
@ -11,3 +11,8 @@ mod headless;
|
|||
|
||||
#[cfg(feature = "window")]
|
||||
mod window;
|
||||
|
||||
#[cfg(not(feature = "window"))]
|
||||
pub type Window = (); // TODO: hack to make things work
|
||||
#[cfg(not(feature = "window"))]
|
||||
pub type MonitorID = (); // TODO: hack to make things work
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use {Event, WindowBuilder};
|
||||
use {Event, BuilderAttribs};
|
||||
use CreationError;
|
||||
use CreationError::OsError;
|
||||
use libc;
|
||||
|
|
@ -89,7 +89,7 @@ pub struct Window {
|
|||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(builder: WindowBuilder) -> Result<Window, CreationError> {
|
||||
pub fn new(builder: BuilderAttribs) -> Result<Window, CreationError> {
|
||||
ensure_thread_init();
|
||||
let dimensions = builder.dimensions.unwrap_or((800, 600));
|
||||
|
||||
|
|
@ -308,7 +308,7 @@ impl Window {
|
|||
});
|
||||
|
||||
let share = if let Some(win) = builder.sharing {
|
||||
win.window.x.context
|
||||
win.x.context
|
||||
} else {
|
||||
ptr::null()
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue