X-Git-Url: http://git.tdb.fi/?p=libs%2Fvr.git;a=blobdiff_plain;f=source%2Fovr%2Foculusriftcombiner.cpp;h=edbe08ae56e4ce9b0dcc833df9109b65d9ce9b85;hp=0d883fa575f9e7b09450f9f87a1ad4ab4fd668a4;hb=11d105c5183b401e5f52e9abb16cf659298cf035;hpb=12044b218363bdd93f9fc1b3c71167d700144e45 diff --git a/source/ovr/oculusriftcombiner.cpp b/source/ovr/oculusriftcombiner.cpp index 0d883fa..edbe08a 100644 --- a/source/ovr/oculusriftcombiner.cpp +++ b/source/ovr/oculusriftcombiner.cpp @@ -76,8 +76,9 @@ void create_distortion_mesh(Msp::GL::Mesh &mesh, ovrHmd hmd, ovrEyeType eye, con namespace Msp { namespace VR { -OculusRiftCombiner::OculusRiftCombiner(const OculusRiftDevice &d): +OculusRiftCombiner::OculusRiftCombiner(OculusRiftDevice &d, GL::View &v): device(d), + view(v), left_mesh((GL::VERTEX2, GL::TEXCOORD2,0, GL::TEXCOORD2,1, GL::TEXCOORD2,2, GL::TEXCOORD2,3)), right_mesh((GL::VERTEX2, GL::TEXCOORD2,0, GL::TEXCOORD2,1, GL::TEXCOORD2,2, GL::TEXCOORD2,3)), shprog(vs_source, fs_source) @@ -102,10 +103,9 @@ OculusRiftCombiner::OculusRiftCombiner(const OculusRiftDevice &d): create_distortion_mesh(right_mesh, hmd, ovrEye_Right, right_fov); ovrSizei tex_size = ovrHmd_GetFovTextureSize(hmd, ovrEye_Left, left_fov, 1.0); - width_factor = tex_size.w*1.0f/hmd->Resolution.w; - height_factor = tex_size.h*1.0f/hmd->Resolution.h; - float aspect = (inner+outer)/(vertical*2); - aspect_factor = aspect*hmd->Resolution.h/hmd->Resolution.w; + target_width = tex_size.w; + target_height = tex_size.h; + render_aspect = (inner+outer)/(vertical*2); left_shdata.uniform("texture", 0); right_shdata.uniform("texture", 0); @@ -123,6 +123,11 @@ OculusRiftCombiner::OculusRiftCombiner(const OculusRiftDevice &d): right_shdata.uniform("uv_offset", uv_scale_offset[1].x, 1-uv_scale_offset[1].y); } +void OculusRiftCombiner::prepare() const +{ + device.begin_frame(); +} + void OculusRiftCombiner::render(const GL::Texture2D &left, const GL::Texture2D &right) const { GL::Bind bind_shprog(shprog); @@ -155,6 +160,9 @@ void OculusRiftCombiner::render(const GL::Texture2D &left, const GL::Texture2D & right.bind(); right_shdata.apply(); right_mesh.draw(); + + view.get_context().swap_buffers(); + device.end_frame(); } } // namespace VR