refactor view/scene to separate modules

This commit is contained in:
2016-09-21 19:38:27 -07:00
parent b8b5bf8ab7
commit 7a9f65115c
10 changed files with 311 additions and 224 deletions

View File

@@ -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 })
}