]> git.tdb.fi Git - libs/vr.git/blobdiff - source/oculusriftcombiner.h
Add a StereoCombiner subclass for the Oculus Rift
[libs/vr.git] / source / oculusriftcombiner.h
diff --git a/source/oculusriftcombiner.h b/source/oculusriftcombiner.h
new file mode 100644 (file)
index 0000000..ede2fe9
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef MSP_GL_OCULUSRIFTCOMBINER_H_
+#define MSP_GL_OCULUSRIFTCOMBINER_H_
+
+#include "mesh.h"
+#include "program.h"
+#include "programdata.h"
+#include "stereocombiner.h"
+
+namespace Msp {
+namespace GL {
+
+/**
+Presents a stereo view in a way suitable for an Oculus Rift HMD.  All distances
+are specified in multiples of the screen width.
+*/
+class OculusRiftCombiner: public StereoCombiner
+{
+private:
+       Mesh mesh;
+       Program shprog;
+       ProgramData left_shdata;
+       ProgramData right_shdata;
+       float view_distance;
+       float lens_separation;
+       float eye_separation;
+       float distortion[4];
+       float fill_factor;
+
+public:
+       OculusRiftCombiner();
+
+       void set_view_distance(float);
+       void set_lens_separation(float);
+       void set_eye_separation(float);
+       void set_distortion(float = 1.0f, float = 0.0f, float = 0.0f, float = 0.0f);
+       void set_fill_factor(float);
+private:
+       void update_parameters();
+
+       float distort(float) const;
+       float undistort(float) const;
+
+public:
+       virtual void render(const Texture2D &, const Texture2D &) const;
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif