2 #include "openvrcombiner.h"
3 #include "openvrsystem.h"
8 struct OpenVRCombiner::Private
10 static Frustum get_projection(vr::EVREye);
14 OpenVRCombiner::OpenVRCombiner(OpenVRSystem &d, GL::View &v):
18 vr::IVRSystem *vr_sys = vr::VRSystem();
20 vr_sys->GetRecommendedRenderTargetSize(&w, &h);
24 Frustum left_frustum = Private::get_projection(vr::Eye_Left);
25 Frustum right_frustum = Private::get_projection(vr::Eye_Right);
26 configure_eye_frustums(left_frustum, right_frustum);
28 view.get_context().set_swap_interval(0);
32 void OpenVRCombiner::prepare() const
34 system.update_pose_matrices();
37 void OpenVRCombiner::render(const GL::Texture2D &left, const GL::Texture2D &right) const
40 tex.eType = vr::API_OpenGL;
41 tex.eColorSpace = vr::ColorSpace_Gamma;
43 vr::IVRCompositor *compositor = vr::VRCompositor();
44 tex.handle = reinterpret_cast<void *>(left.get_id());
45 compositor->Submit(vr::Eye_Left, &tex);
46 tex.handle = reinterpret_cast<void *>(right.get_id());
47 compositor->Submit(vr::Eye_Right, &tex);
51 mirror->shdata.uniform("scale", view.get_aspect()/render_aspect/2, 0.5f);
53 view.get_context().swap_buffers();
58 StereoCombiner::Frustum OpenVRCombiner::Private::get_projection(vr::EVREye eye)
61 /* The parameter order is documented as left, right, top, bottom; however
62 the third parameter is actually negative and fourth one positive. */
63 vr::VRSystem()->GetProjectionRaw(eye, &frustum.left, &frustum.right, &frustum.bottom, &frustum.top);