depth testing

This commit is contained in:
2016-09-15 00:21:13 -07:00
parent a7562b449c
commit 9f7246efba
2 changed files with 24 additions and 16 deletions

View File

@@ -5,10 +5,11 @@ extern crate num_traits;
extern crate openvr as vr;
extern crate openvr_sys;
use self::gfx::{tex, Factory, Typed};
pub use self::vr::Eye;
pub use self::vr::tracking::TrackedDeviceClass;
use self::gfx::{tex, Factory, Typed};
use self::gfx_device_gl::Resources as GLResources;
use self::na::Inverse;
use self::num_traits::identities::Zero;
use self::num_traits::identities::One;
@@ -16,7 +17,7 @@ use self::num_traits::identities::One;
pub struct VR {
system: vr::IVRSystem,
compositor: vr::IVRCompositor,
gfx_handles: gfx::handle::Manager<gfx_device_gl::Resources>,
gfx_handles: gfx::handle::Manager<GLResources>,
}
impl VR {
@@ -33,7 +34,7 @@ impl VR {
self.compositor.wait_get_poses()
}
pub fn submit<T>(&mut self, eye: Eye, tex: &gfx::handle::Texture<gfx_device_gl::Resources, T>) {
pub fn submit<T>(&mut self, eye: Eye, tex: &gfx::handle::Texture<GLResources, T>) {
let tex_id = match self.gfx_handles.ref_texture(tex.raw()) {
&gfx_device_gl::NewTexture::Surface(id) => id,
_ => panic!("Not a surface")
@@ -86,14 +87,14 @@ impl<N: Copy> AsMatrix4<N> for [[N; 4]; 4] {
}
}
pub fn create_eyebuffer<T>(factory: &mut gfx_device_gl::Factory,
size: vr::common::Size)
-> Result<(gfx::handle::Texture<gfx_device_gl::Resources,
T::Surface>,
gfx::handle::RenderTargetView<gfx_device_gl::Resources,
T>),
gfx::CombinedError>
where T: gfx::format::RenderFormat + gfx::format::TextureFormat {
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>
where T: gfx::format::RenderFormat + gfx::format::TextureFormat,
D: gfx::format::DepthFormat + gfx::format::TextureFormat {
let tex = try!(factory.create_texture(
tex::Kind::D2(size.width as tex::Size, size.height as tex::Size, tex::AaMode::Single),
1, // levels
@@ -101,5 +102,7 @@ pub fn create_eyebuffer<T>(factory: &mut gfx_device_gl::Factory,
gfx::Usage::GpuOnly, // Usage
Some(<T::Channel as gfx::format::ChannelTyped>::get_channel_type()))); // hint: format::ChannelType?
let tgt = try!(factory.view_texture_as_render_target(&tex, 0, None));
Ok((tex, tgt))
let depth = try!(factory.create_depth_stencil_view_only(size.width as tex::Size,
size.height as tex::Size));
Ok((tex, tgt, depth))
}