right_mesh((GL::VERTEX2, GL::TEXCOORD2,0, GL::TEXCOORD2,1, GL::TEXCOORD2,2)),
shprog(vs_source, fs_source)
{
- width_div = 2;
-
const OculusRiftDevice::Private &dev_priv = device.get_private();
ovrHmd hmd = dev_priv.ovr_hmd;
create_distortion_mesh(right_mesh, hmd, ovrEye_Right, right_fov);
ovrSizei tex_size = ovrHmd_GetFovTextureSize(hmd, ovrEye_Left, left_fov, 1.0);
- oversize = max(tex_size.w*2.0f/hmd->Resolution.w, tex_size.h*1.0f/hmd->Resolution.h);
+ 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;
shdata.uniform("texture", 0);
mesh(GL::VERTEX2),
shprog(vs_source, fs_source)
{
- width_div = 2;
+ width_factor = 0.5f;
+ aspect_factor = 0.5f;
left_shdata.uniform("texture", 0);
right_shdata.uniform("texture", 0);
namespace VR {
StereoCombiner::StereoCombiner():
- width_div(1),
- height_div(1),
- keep_aspect(false),
- oversize(1.0f),
+ width_factor(1.0f),
+ height_factor(1.0f),
+ aspect_factor(1.0f),
frustum_skew(0.0f)
{ }
class StereoCombiner
{
protected:
- unsigned width_div;
- unsigned height_div;
- bool keep_aspect;
+ float width_factor;
+ float height_factor;
+ float aspect_factor;
Geometry::Angle<float> fov;
- float oversize;
float frustum_skew;
StereoCombiner();
public:
virtual ~StereoCombiner() { }
- unsigned get_width_divisor() const { return width_div; }
- unsigned get_height_divisor() const { return height_div; }
- bool is_aspect_kept() const { return keep_aspect; }
+ float get_width_factor() const { return width_factor; }
+ float get_height_factor() const { return height_factor; }
+ float get_aspect_factor() const { return aspect_factor; }
const Geometry::Angle<float> &get_field_of_view() const { return fov; }
- float get_oversize() const { return oversize; }
float get_frustum_skew() const { return frustum_skew; }
virtual void render(const GL::Texture2D &, const GL::Texture2D &) const = 0;
{
combiner = &c;
- unsigned w = width/combiner->get_width_divisor()*combiner->get_oversize();
- unsigned h = height/combiner->get_height_divisor()*combiner->get_oversize();
+ unsigned w = width*combiner->get_width_factor();
+ unsigned h = height*combiner->get_height_factor();
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();
- if(!combiner->is_aspect_kept())
- params.aspect = params.aspect*combiner->get_height_divisor()/combiner->get_width_divisor();
-
+ params.aspect = base_camera.get_aspect()*combiner->get_aspect_factor();
params.near_clip = base_camera.get_near_clip();
params.far_clip = base_camera.get_far_clip();