]> git.tdb.fi Git - libs/vr.git/blob - source/oculusriftcombiner.h
Rename to mspvr
[libs/vr.git] / source / oculusriftcombiner.h
1 #ifndef MSP_VR_OCULUSRIFTCOMBINER_H_
2 #define MSP_VR_OCULUSRIFTCOMBINER_H_
3
4 #include <msp/gl/mesh.h>
5 #include <msp/gl/program.h>
6 #include <msp/gl/programdata.h>
7 #include "stereocombiner.h"
8
9 namespace Msp {
10 namespace VR {
11
12 /**
13 Presents a stereo view in a way suitable for an Oculus Rift HMD.  All distances
14 are specified in multiples of the screen width.
15 */
16 class OculusRiftCombiner: public StereoCombiner
17 {
18 private:
19         GL::Mesh mesh;
20         GL::Program shprog;
21         GL::ProgramData left_shdata;
22         GL::ProgramData right_shdata;
23         float view_distance;
24         float lens_separation;
25         float eye_separation;
26         float distortion[4];
27         float fill_factor;
28
29 public:
30         OculusRiftCombiner();
31
32         void set_view_distance(float);
33         void set_lens_separation(float);
34         void set_eye_separation(float);
35         void set_distortion(float = 1.0f, float = 0.0f, float = 0.0f, float = 0.0f);
36         void set_fill_factor(float);
37 private:
38         void update_parameters();
39
40         float distort(float) const;
41         float undistort(float) const;
42
43 public:
44         virtual void render(const GL::Texture2D &, const GL::Texture2D &) const;
45 };
46
47 } // namespace VR
48 } // namespace Msp
49
50 #endif