aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32/mod.rs
diff options
context:
space:
mode:
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) {