view doesn't own scene
This commit is contained in:
21
src/view.rs
21
src/view.rs
@@ -1,4 +1,3 @@
|
||||
use scenes;
|
||||
use vr;
|
||||
use vr::{AsMatrix4, VR};
|
||||
|
||||
@@ -34,7 +33,6 @@ pub struct ViewRoot<Dev, T, D>
|
||||
left: vr::EyeBuffer<T, D>,
|
||||
right: vr::EyeBuffer<T, D>,
|
||||
trans: gfx::handle::Buffer<Dev::Resources, Trans>,
|
||||
scene: Box<::scene::Scene<Dev, gfx_device_gl::Factory>>,
|
||||
}
|
||||
|
||||
impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
|
||||
@@ -54,13 +52,13 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
|
||||
left: left,
|
||||
right: right,
|
||||
trans: trans.clone(),
|
||||
scene: Box::new(scenes::world::WorldScene::new(&mut window.factory, &trans)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw(&self,
|
||||
window: &mut PistonWindow,
|
||||
vr: &mut vr::VR) {
|
||||
vr: &mut vr::VR,
|
||||
scene: &::scene::Scene<gfx_device_gl::Device, gfx_device_gl::Factory>) {
|
||||
// Get the current sensor state
|
||||
let poses = vr.poses();
|
||||
|
||||
@@ -85,10 +83,11 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
|
||||
let trans = Trans { matrix: *(proj_mat * eye_mat * hmd_mat * model_mat).as_ref() };
|
||||
window.encoder.update_constant_buffer(&self.trans, &trans);
|
||||
|
||||
self.scene.render(&mut window.factory,
|
||||
&mut window.encoder,
|
||||
&buffers.target,
|
||||
&buffers.depth);
|
||||
scene.render(&mut window.factory,
|
||||
&mut window.encoder,
|
||||
&self.trans,
|
||||
&buffers.target,
|
||||
&buffers.depth);
|
||||
},
|
||||
_ => ()
|
||||
}
|
||||
@@ -100,7 +99,11 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
|
||||
&Trans { matrix: *na::Matrix4::one().as_ref() });
|
||||
window.encoder.clear(&window.output_color, [0.1, 0.2, 0.3, 1.0]);
|
||||
window.encoder.clear_depth(&window.output_stencil, 1.0);
|
||||
self.scene.render(&mut window.factory, &mut window.encoder, &window.output_color, &window.output_stencil);
|
||||
scene.render(&mut window.factory,
|
||||
&mut window.encoder,
|
||||
&self.trans,
|
||||
&window.output_color,
|
||||
&window.output_stencil);
|
||||
|
||||
window.encoder.flush(&mut window.device);
|
||||
vr.submit(vr::Eye::Left, &self.left.tex);
|
||||
|
||||
Reference in New Issue
Block a user