aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32/mod.rs
diff options
context:
space:
mode:
authorTomaka17 <pierre.krieger1708@gmail.com>2014-10-04 19:17:02 +0200
committerTomaka17 <pierre.krieger1708@gmail.com>2014-10-09 15:55:42 +0200
commite565bfeb1372b885f8cced6a42596b731cb382b2 (patch)
tree4a788e43172cd968c2a2cd1bd7d3102ea6937c80 /src/win32/mod.rs
parentcfb0cb70013772492c1930ced62f48aa6cb372ff (diff)
downloadglutin-e565bfeb1372b885f8cced6a42596b731cb382b2.tar.gz
glutin-e565bfeb1372b885f8cced6a42596b731cb382b2.zip
Implement headless rendering
Diffstat (limited to 'src/win32/mod.rs')
-rw-r--r--src/win32/mod.rs39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/win32/mod.rs b/src/win32/mod.rs
index faff374..af28011 100644
--- a/src/win32/mod.rs
+++ b/src/win32/mod.rs
@@ -1,6 +1,12 @@
use std::sync::atomics::AtomicBool;
use std::ptr;
-use {Event, WindowBuilder};
+use Event;
+
+#[cfg(feature = "window")]
+use WindowBuilder;
+
+#[cfg(feature = "headless")]
+use HeadlessRendererBuilder;
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
@@ -9,6 +15,30 @@ mod ffi;
mod init;
mod monitor;
+///
+#[cfg(feature = "headless")]
+pub struct HeadlessContext(Window);
+
+#[cfg(feature = "headless")]
+impl HeadlessContext {
+ /// See the docs in the crate root file.
+ pub fn new(builder: HeadlessRendererBuilder) -> Result<HeadlessContext, String> {
+ let HeadlessRendererBuilder { dimensions, gl_version } = builder;
+ init::new_window(Some(dimensions), "".to_string(), None, gl_version, true)
+ .map(|w| HeadlessContext(w))
+ }
+
+ /// See the docs in the crate root file.
+ pub unsafe fn make_current(&self) {
+ self.0.make_current()
+ }
+
+ /// See the docs in the crate root file.
+ pub fn get_proc_address(&self, addr: &str) -> *const () {
+ self.0.get_proc_address(addr)
+ }
+}
+
/// The Win32 implementation of the main `Window` object.
pub struct Window {
/// Main handle for the window.
@@ -33,12 +63,16 @@ pub struct Window {
is_closed: AtomicBool,
}
+#[cfg(feature = "window")]
impl Window {
/// See the docs in the crate root file.
pub fn new(builder: WindowBuilder) -> Result<Window, String> {
- init::new_window(builder)
+ let WindowBuilder { dimensions, title, monitor, gl_version } = builder;
+ init::new_window(dimensions, title, monitor, gl_version, false)
}
+}
+impl Window {
/// See the docs in the crate root file.
pub fn is_closed(&self) -> bool {
use std::sync::atomics::Relaxed;
@@ -200,6 +234,7 @@ impl Window {
}
}
+#[cfg(feature = "window")]
#[unsafe_destructor]
impl Drop for Window {
fn drop(&mut self) {