]> git.tdb.fi Git - libs/vr.git/blobdiff - source/stereocombiner.h
Fix memory leaks
[libs/vr.git] / source / stereocombiner.h
index 41c5a56945080b2edea0e0503b06128b62ee67b8..9dac08c626aa19ce2a04838c12e3347880f752bf 100644 (file)
@@ -2,6 +2,9 @@
 #define MSP_VR_STEREOCOMBINER_H_
 
 #include <msp/geometry/angle.h>
+#include <msp/gl/mesh.h>
+#include <msp/gl/program.h>
+#include <msp/gl/programdata.h>
 #include <msp/gl/texture2d.h>
 
 namespace Msp {
@@ -10,23 +13,54 @@ namespace VR {
 class StereoCombiner
 {
 protected:
-       float width_factor;
-       float height_factor;
-       float aspect_factor;
+       struct Frustum
+       {
+               float left;
+               float right;
+               float bottom;
+               float top;
+
+               Frustum();
+               Frustum(float, float, float, float);
+       };
+
+       struct MirrorView
+       {
+               GL::Mesh mesh;
+               GL::Program shader;
+               GL::ProgramData shdata;
+
+               MirrorView();
+       };
+
+       unsigned target_width;
+       unsigned target_height;
+       float render_aspect;
        Geometry::Angle<float> fov;
        float frustum_skew;
+       MirrorView *mirror;
 
        StereoCombiner();
 public:
-       virtual ~StereoCombiner() { }
+       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; }
+protected:
+       void configure_eye_frustums(const Frustum &, const Frustum &);
+public:
+       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; }
 
+       virtual bool is_mirroring_supported() const { return false; }
+       void set_mirroring(bool);
+       bool get_mirroring() const { return mirror; }
+
+       virtual void prepare() const { }
        virtual void render(const GL::Texture2D &, const GL::Texture2D &) const = 0;
+protected:
+       void render_mirror(const GL::Texture2D &) const;
 };
 
 } // namespace VR