]> git.tdb.fi Git - libs/vr.git/blobdiff - source/stereoview.h
Fix memory leaks
[libs/vr.git] / source / stereoview.h
index f9e9a560ea7eefc21b8f4081cf627267e4e601db..75361ba13abd56acf8cc50feb0585e75daa41f24 100644 (file)
@@ -11,6 +11,8 @@
 namespace Msp {
 namespace VR {
 
+class HeadTrackingCamera;
+class MotionController;
 class StereoCombiner;
 
 class StereoView
@@ -36,32 +38,43 @@ private:
        struct Eye
        {
                mutable GL::Camera camera;
+               GL::Matrix offset_matrix;
                RenderTarget *target;
 
                Eye();
+               ~Eye();
 
                void create_target(unsigned, unsigned);
-               void setup_frame(const GL::Camera &, const GL::Vector3 &, float, const EyeParams &) const;
+               void setup_frame(const GL::Camera &, float, const EyeParams &) const;
                void render(const GL::Renderable &) const;
        };
 
-       unsigned width;
-       unsigned height;
+       const StereoCombiner &combiner;
        const GL::Camera &base_camera;
-       const GL::Renderable &renderable;
-       const StereoCombiner *combiner;
+       HeadTrackingCamera *head_camera;
+       const GL::Renderable *content;
        Eye left;
        Eye right;
-       float eye_spacing;
        Geometry::Angle<float> strabismus;
+       std::vector<MotionController *> controllers;
 
 public:
-       StereoView(unsigned, unsigned, const GL::Camera &, const GL::Renderable &, const StereoCombiner &);
+       StereoView(const StereoCombiner &, const GL::Camera &);
+       StereoView(const StereoCombiner &, HeadTrackingCamera &);
+private:
+       void init();
 
-       void set_combiner(const StereoCombiner &);
+public:
+       const GL::Camera &get_base_camera() const { return base_camera; }
+       const HeadTrackingCamera *get_head_camera() const { return head_camera; }
+       void set_content(const GL::Renderable *);
        void set_eye_spacing(float);
+       void set_eye_matrices(const GL::Matrix &, const GL::Matrix &);
        void set_strabismus(const Geometry::Angle<float> &);
 
+       void add_controller(MotionController &);
+       void remove_controller(MotionController &);
+
 private:
        void setup_frame() const;
 public: