send events to scene

This commit is contained in:
2016-09-30 14:15:24 -07:00
parent 235b5d58bd
commit 0b8db8d9b4
4 changed files with 16 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
extern crate vrtue;
use vrtue::{scenes, view, vr};
use vrtue::scene::Scene;
use vrtue::scene::{Event, Scene};
extern crate env_logger;
extern crate gfx_device_gl;
@@ -35,6 +35,8 @@ pub fn main() {
piston_window::Input::Text(_) => break 'main,
_ => debug!("\t{:?}", ev)
}
scene.event(Event::Piston(ev));
}
}

View File

@@ -1,4 +1,5 @@
use view;
use vr;
extern crate gfx;
extern crate gfx_device_gl;
@@ -6,6 +7,7 @@ extern crate piston_window;
pub trait Scene<D: gfx::Device,
F: gfx::Factory<D::Resources>> {
fn event(&mut self, event: Event);
fn update(&mut self);
fn render(&self,
factory: &mut F,
@@ -14,3 +16,8 @@ pub trait Scene<D: gfx::Device,
target: &gfx::handle::RenderTargetView<D::Resources, view::ColorFormat>,
depth: &gfx::handle::DepthStencilView<D::Resources, view::DepthFormat>);
}
pub enum Event {
Vr(vr::Event),
Piston(piston_window::Input),
}

View File

@@ -64,6 +64,9 @@ impl<D: gfx::Device, F: gfx::Factory<D::Resources>> WorldScene<D, F> {
impl<D: gfx::Device,
F: gfx::Factory<D::Resources>> scene::Scene<D, F> for WorldScene<D, F> {
fn event(&mut self, event: scene::Event) {
}
fn update(&mut self) {
}

View File

@@ -20,6 +20,9 @@ pub struct VR {
gfx_handles: gfx::handle::Manager<GLResources>,
}
pub struct Event {
}
impl VR {
pub fn new() -> Result<VR, vr::Error<openvr_sys::EVRInitError>> {
Ok(VR {