2 #include "openvrcombiner.h"
3 #include "openvrdevice.h"
8 struct OpenVRCombiner::Private
10 static Frustum get_projection(vr::EVREye);
14 OpenVRCombiner::OpenVRCombiner(OpenVRDevice &d):
17 vr::IVRSystem *vr_sys = vr::VRSystem();
19 vr_sys->GetRecommendedRenderTargetSize(&w, &h);
23 Frustum left_frustum = Private::get_projection(vr::Eye_Left);
24 Frustum right_frustum = Private::get_projection(vr::Eye_Right);
25 configure_eye_frustums(left_frustum, right_frustum);
28 void OpenVRCombiner::prepare() const
30 device.update_pose_matrices();
33 void OpenVRCombiner::render(const GL::Texture2D &left, const GL::Texture2D &right) const
36 tex.eType = vr::API_OpenGL;
37 tex.eColorSpace = vr::ColorSpace_Gamma;
39 vr::IVRCompositor *compositor = vr::VRCompositor();
40 tex.handle = reinterpret_cast<void *>(left.get_id());
41 compositor->Submit(vr::Eye_Left, &tex);
42 tex.handle = reinterpret_cast<void *>(right.get_id());
43 compositor->Submit(vr::Eye_Right, &tex);
47 StereoCombiner::Frustum OpenVRCombiner::Private::get_projection(vr::EVREye eye)
50 /* The parameter order is documented as left, right, top, bottom; however
51 the third parameter is actually negative and fourth one positive. */
52 vr::VRSystem()->GetProjectionRaw(eye, &frustum.left, &frustum.right, &frustum.bottom, &frustum.top);