]> git.tdb.fi Git - libs/vr.git/blob - source/stereocombiner.h
Move some common calculations to base classes
[libs/vr.git] / source / stereocombiner.h
1 #ifndef MSP_VR_STEREOCOMBINER_H_
2 #define MSP_VR_STEREOCOMBINER_H_
3
4 #include <msp/geometry/angle.h>
5 #include <msp/gl/texture2d.h>
6
7 namespace Msp {
8 namespace VR {
9
10 class StereoCombiner
11 {
12 protected:
13         struct Frustum
14         {
15                 float left;
16                 float right;
17                 float bottom;
18                 float top;
19
20                 Frustum();
21                 Frustum(float, float, float, float);
22         };
23
24         unsigned target_width;
25         unsigned target_height;
26         float render_aspect;
27         Geometry::Angle<float> fov;
28         float frustum_skew;
29
30         StereoCombiner();
31 public:
32         virtual ~StereoCombiner() { }
33
34 protected:
35         void configure_eye_frustums(const Frustum &, const Frustum &);
36 public:
37         float get_target_width() const { return target_width; }
38         float get_target_height() const { return target_height; }
39         float get_render_aspect() const { return render_aspect; }
40         const Geometry::Angle<float> &get_field_of_view() const { return fov; }
41         float get_frustum_skew() const { return frustum_skew; }
42
43         virtual void prepare() const { }
44         virtual void render(const GL::Texture2D &, const GL::Texture2D &) const = 0;
45 };
46
47 } // namespace VR
48 } // namespace Msp
49
50 #endif