Merge pull request #138 from DavidPartouche/cocoa_offscreen
Added headless rendering on osx
This commit is contained in:
commit
596132dc93
2 changed files with 115 additions and 19 deletions
|
|
@ -1,3 +1,6 @@
|
|||
#[cfg(feature = "headless")]
|
||||
pub use self::headless::HeadlessContext;
|
||||
|
||||
use {CreationError, Event};
|
||||
use CreationError::OsError;
|
||||
use libc;
|
||||
|
|
@ -5,9 +8,6 @@ use libc;
|
|||
#[cfg(feature = "window")]
|
||||
use WindowBuilder;
|
||||
|
||||
#[cfg(feature = "headless")]
|
||||
use HeadlessRendererBuilder;
|
||||
|
||||
use cocoa::base::{id, NSUInteger, nil, objc_allocateClassPair, class, objc_registerClassPair};
|
||||
use cocoa::base::{selector, msg_send, class_addMethod, class_addIvar};
|
||||
use cocoa::base::{object_setInstanceVariable, object_getInstanceVariable};
|
||||
|
|
@ -33,6 +33,9 @@ pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
|
|||
mod monitor;
|
||||
mod event;
|
||||
|
||||
#[cfg(feature = "headless")]
|
||||
mod headless;
|
||||
|
||||
static mut shift_pressed: bool = false;
|
||||
static mut ctrl_pressed: bool = false;
|
||||
static mut win_pressed: bool = false;
|
||||
|
|
@ -60,14 +63,6 @@ pub struct Window {
|
|||
state: Box<InternalState>,
|
||||
}
|
||||
|
||||
pub struct HeadlessContext(Window);
|
||||
|
||||
impl Deref<Window> for HeadlessContext {
|
||||
fn deref(&self) -> &Window {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "window")]
|
||||
impl Window {
|
||||
pub fn new(builder: WindowBuilder) -> Result<Window, CreationError> {
|
||||
|
|
@ -79,14 +74,6 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "headless")]
|
||||
impl HeadlessContext {
|
||||
pub fn new(builder: HeadlessRendererBuilder) -> Result<HeadlessContext, CreationError> {
|
||||
Window::new_impl(Some(builder.dimensions), "", None, false)
|
||||
.map(|w| HeadlessContext(w))
|
||||
}
|
||||
}
|
||||
|
||||
extern fn window_should_close(this: id, _: id) -> id {
|
||||
unsafe {
|
||||
let mut stored_value = ptr::null_mut();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue