diff options
author | Pierre Krieger <pierre.krieger1708@gmail.com> | 2014-12-28 15:08:41 +0100 |
---|---|---|
committer | Pierre Krieger <pierre.krieger1708@gmail.com> | 2014-12-31 07:34:26 +0100 |
commit | b9710f05a9d1e7fd10536b604074baf748fb5bd7 (patch) | |
tree | d3f8c282bd302589b1e021064d2182371245ad3c /src/x11 | |
parent | fb42768a14228eba456cc8957820c14c105b1647 (diff) | |
download | glutin-b9710f05a9d1e7fd10536b604074baf748fb5bd7.tar.gz glutin-b9710f05a9d1e7fd10536b604074baf748fb5bd7.zip |
Unify WindowBuilder and HeadlessRendererBuilder for easier implementations
Diffstat (limited to 'src/x11')
-rw-r--r-- | src/x11/headless.rs | 12 | ||||
-rw-r--r-- | src/x11/mod.rs | 5 | ||||
-rw-r--r-- | src/x11/window/mod.rs | 6 |
3 files changed, 15 insertions, 8 deletions
diff --git a/src/x11/headless.rs b/src/x11/headless.rs index d6f1023..22d0654 100644 --- a/src/x11/headless.rs +++ b/src/x11/headless.rs @@ -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() { diff --git a/src/x11/mod.rs b/src/x11/mod.rs index 9ce789f..22184a9 100644 --- a/src/x11/mod.rs +++ b/src/x11/mod.rs @@ -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 diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs index 0a8c3d5..fc622ea 100644 --- a/src/x11/window/mod.rs +++ b/src/x11/window/mod.rs @@ -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() }; |