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);
namespace Msp {
namespace VR {
-SideBySideCombiner::SideBySideCombiner(bool c):
+SideBySideCombiner::SideBySideCombiner(GL::View &view, bool c):
mesh(GL::VERTEX2),
shprog(vs_source, fs_source)
{
- width_factor = 0.5f;
- aspect_factor = 0.5f;
+ target_width = view.get_width()/2;
+ target_height = view.get_height()/2;
+ render_aspect = static_cast<float>(target_width)/target_height;
left_shdata.uniform("texture", 0);
right_shdata.uniform("texture", 0);
#include <msp/gl/mesh.h>
#include <msp/gl/program.h>
#include <msp/gl/programdata.h>
+#include <msp/gl/view.h>
#include "stereocombiner.h"
namespace Msp {
bool cross_eyed;
public:
- SideBySideCombiner(bool = false);
+ SideBySideCombiner(GL::View &, bool = false);
void set_cross_eyed(bool);
namespace VR {
StereoCombiner::StereoCombiner():
- width_factor(1.0f),
- height_factor(1.0f),
- aspect_factor(1.0f),
+ target_width(0),
+ target_height(0),
+ render_aspect(1.0f),
frustum_skew(0.0f)
{ }
class StereoCombiner
{
protected:
- float width_factor;
- float height_factor;
- float aspect_factor;
+ unsigned target_width;
+ unsigned target_height;
+ float render_aspect;
Geometry::Angle<float> fov;
float frustum_skew;
public:
virtual ~StereoCombiner() { }
- float get_width_factor() const { return width_factor; }
- float get_height_factor() const { return height_factor; }
- float get_aspect_factor() const { return aspect_factor; }
+ float get_target_width() const { return target_width; }
+ float get_target_height() const { return target_height; }
+ float get_render_aspect() const { return render_aspect; }
const Geometry::Angle<float> &get_field_of_view() const { return fov; }
float get_frustum_skew() const { return frustum_skew; }
namespace Msp {
namespace VR {
-StereoView::StereoView(unsigned w, unsigned h, const GL::Camera &c, const GL::Renderable &r, const StereoCombiner &m):
- width(w),
- height(h),
+StereoView::StereoView(const GL::Camera &c, const GL::Renderable &r, const StereoCombiner &m):
base_camera(c),
renderable(r),
combiner(0)
{
combiner = &c;
- unsigned w = width*combiner->get_width_factor();
- unsigned h = height*combiner->get_height_factor();
+ unsigned w = combiner->get_target_width();
+ unsigned h = combiner->get_target_height();
left.create_target(w, h);
right.create_target(w, h);
}
if(params.fov==Geometry::Angle<float>::zero())
params.fov = base_camera.get_field_of_view();
- params.aspect = base_camera.get_aspect()*combiner->get_aspect_factor();
+ params.aspect = combiner->get_render_aspect();
params.near_clip = base_camera.get_near_clip();
params.far_clip = base_camera.get_far_clip();
void render(const GL::Renderable &) const;
};
- unsigned width;
- unsigned height;
const GL::Camera &base_camera;
const GL::Renderable &renderable;
const StereoCombiner *combiner;
Geometry::Angle<float> strabismus;
public:
- StereoView(unsigned, unsigned, const GL::Camera &, const GL::Renderable &, const StereoCombiner &);
+ StereoView(const GL::Camera &, const GL::Renderable &, const StereoCombiner &);
void set_combiner(const StereoCombiner &);
void set_eye_spacing(float);