]> git.tdb.fi Git - libs/vr.git/blob - source/oculusriftcombiner.h
ede2fe91e481585de3e72bb165a8b4481a96b44f
[libs/vr.git] / source / oculusriftcombiner.h
1 #ifndef MSP_GL_OCULUSRIFTCOMBINER_H_
2 #define MSP_GL_OCULUSRIFTCOMBINER_H_
3
4 #include "mesh.h"
5 #include "program.h"
6 #include "programdata.h"
7 #include "stereocombiner.h"
8
9 namespace Msp {
10 namespace GL {
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         Mesh mesh;
20         Program shprog;
21         ProgramData left_shdata;
22         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 Texture2D &, const Texture2D &) const;
45 };
46
47 } // namespace GL
48 } // namespace Msp
49
50 #endif