Update camera pose as part of the render call
[libs/vr.git] / source / stereoview.cpp
index 7a72a452c279a31b1e64b663441a8621aefc04a3..5945016da1ac8d1e20d01c0a4e25f0ceb0300954 100644 (file)
@@ -1,4 +1,5 @@
 #include <msp/gl/renderer.h>
+#include "headtrackingcamera.h"
 #include "stereocombiner.h"
 #include "stereoview.h"
 
@@ -10,8 +11,23 @@ namespace VR {
 StereoView::StereoView(const StereoCombiner &c, const GL::Camera &a):
        combiner(c),
        base_camera(a),
-       content(0)
+       head_camera(0)
 {
+       init();
+}
+
+StereoView::StereoView(const StereoCombiner &c, HeadTrackingCamera &a):
+       combiner(c),
+       base_camera(a),
+       head_camera(&a)
+{
+       init();
+}
+
+void StereoView::init()
+{
+       content = 0;
+
        unsigned w = combiner.get_target_width();
        unsigned h = combiner.get_target_height();
        left.create_target(w, h);
@@ -38,6 +54,9 @@ void StereoView::set_strabismus(const Geometry::Angle<float> &s)
 
 void StereoView::setup_frame() const
 {
+       if(head_camera)
+               head_camera->update();
+
        GL::Vector3 offset_axis = normalize(cross(base_camera.get_look_direction(), base_camera.get_up_direction()))*0.5f;
 
        EyeParams params;