NO_VR env var for monitor only mode
This commit is contained in:
@@ -8,15 +8,20 @@ extern crate gfx_device_gl;
|
||||
extern crate piston_window;
|
||||
|
||||
use self::piston_window::{PistonWindow, Window, WindowSettings};
|
||||
use std::env;
|
||||
|
||||
pub fn main() {
|
||||
env_logger::init().expect("env logger");
|
||||
let mut vr = vr::VR::new().expect("VR init");
|
||||
let mut vr = if env::var("NO_VR").is_ok() {
|
||||
None
|
||||
} else {
|
||||
Some(vr::VR::new().expect("VR init"))
|
||||
};
|
||||
|
||||
let mut window: PistonWindow =
|
||||
WindowSettings::new("Hello, Britannia!", [1024; 2])
|
||||
.exit_on_esc(true)
|
||||
.vsync(false)
|
||||
.vsync(vr.is_none()) // Let VR throttle framerate, if available
|
||||
.build().expect("Building Window");
|
||||
|
||||
let mut aux_command = window.factory.create_command_buffer();
|
||||
@@ -44,7 +49,7 @@ pub fn main() {
|
||||
}
|
||||
|
||||
// handle VR events
|
||||
while let Some(ev) = vr.poll_next_event() {
|
||||
while let Some(ev) = vr.as_mut().and_then(|vr| vr.poll_next_event()) {
|
||||
scene.event(Event::Vr(ev));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user