refactor view/scene to separate modules
This commit is contained in:
16
src/vr.rs
16
src/vr.rs
@@ -87,12 +87,18 @@ impl<N: Copy> AsMatrix4<N> for [[N; 4]; 4] {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EyeBuffer<T, D>
|
||||
where T: gfx::format::RenderFormat + gfx::format::TextureFormat,
|
||||
D: gfx::format::DepthFormat + gfx::format::TextureFormat {
|
||||
|
||||
pub tex: gfx::handle::Texture<GLResources, T::Surface>,
|
||||
pub target: gfx::handle::RenderTargetView<GLResources, T>,
|
||||
pub depth: gfx::handle::DepthStencilView<GLResources, D>,
|
||||
}
|
||||
|
||||
pub fn create_eyebuffer<T, D>(factory: &mut gfx_device_gl::Factory,
|
||||
size: vr::common::Size)
|
||||
-> Result<(gfx::handle::Texture<GLResources, T::Surface>,
|
||||
gfx::handle::RenderTargetView<GLResources, T>,
|
||||
gfx::handle::DepthStencilView<GLResources, D>),
|
||||
gfx::CombinedError>
|
||||
-> Result<EyeBuffer<T, D>, gfx::CombinedError>
|
||||
where T: gfx::format::RenderFormat + gfx::format::TextureFormat,
|
||||
D: gfx::format::DepthFormat + gfx::format::TextureFormat {
|
||||
let tex = try!(factory.create_texture(
|
||||
@@ -104,5 +110,5 @@ pub fn create_eyebuffer<T, D>(factory: &mut gfx_device_gl::Factory,
|
||||
let tgt = try!(factory.view_texture_as_render_target(&tex, 0, None));
|
||||
let depth = try!(factory.create_depth_stencil_view_only(size.width as tex::Size,
|
||||
size.height as tex::Size));
|
||||
Ok((tex, tgt, depth))
|
||||
Ok(EyeBuffer { tex: tex, target: tgt, depth: depth })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user