2015-10-26 13:08:18 +00:00
|
|
|
#ifndef GL_STEREO3D_H_
|
|
|
|
#define GL_STEREO3D_H_
|
|
|
|
|
|
|
|
#include <vector>
|
2015-12-30 22:54:54 +00:00
|
|
|
#include <cstring> // needed for memcpy on linux, which is needed by VSMatrix copy ctor
|
2015-10-31 00:51:35 +00:00
|
|
|
#include "gl/data/gl_matrix.h"
|
2015-10-26 13:08:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* stereoscopic 3D API */
|
|
|
|
namespace s3d {
|
|
|
|
|
|
|
|
|
|
|
|
/* Subregion of current display window */
|
|
|
|
class Viewport
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
int x, y;
|
|
|
|
int width, height;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Viewpoint of one eye */
|
|
|
|
class EyePose
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
EyePose() {}
|
|
|
|
virtual ~EyePose() {}
|
2015-10-31 11:46:36 +00:00
|
|
|
virtual VSMatrix GetProjection(FLOATTYPE fov, FLOATTYPE aspectRatio, FLOATTYPE fovRatio) const;
|
2015-10-26 13:08:18 +00:00
|
|
|
virtual Viewport GetViewport(const Viewport& fullViewport) const;
|
2015-10-31 00:51:35 +00:00
|
|
|
virtual void GetViewShift(FLOATTYPE yaw, FLOATTYPE outViewShift[3]) const;
|
2015-10-26 13:08:18 +00:00
|
|
|
virtual void SetUp() const {};
|
|
|
|
virtual void TearDown() const {};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Base class for stereoscopic 3D rendering modes */
|
|
|
|
class Stereo3DMode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/* const_iterator cycles through the various eye viewpoints */
|
|
|
|
typedef std::vector<const EyePose *>::const_iterator const_iterator;
|
|
|
|
|
|
|
|
/* static methods for managing the selected stereoscopic view state */
|
|
|
|
static const Stereo3DMode& getCurrentMode();
|
|
|
|
|
|
|
|
Stereo3DMode();
|
|
|
|
virtual ~Stereo3DMode();
|
|
|
|
/* const_iterator cycles through the various eye viewpoints */
|
|
|
|
virtual const_iterator begin() const { return eye_ptrs.begin(); }
|
|
|
|
virtual const_iterator end() const { return eye_ptrs.end(); }
|
|
|
|
/* hooks for setup and cleanup operations for each stereo mode */
|
|
|
|
virtual void SetUp() const {};
|
|
|
|
virtual void TearDown() const {};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::vector<const EyePose *> eye_ptrs;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static Stereo3DMode const * currentStereo3DMode;
|
|
|
|
static void setCurrentMode(const Stereo3DMode& mode);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ordinary non-3D rendering
|
|
|
|
*/
|
|
|
|
class MonoView : public Stereo3DMode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static const MonoView& getInstance();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
MonoView() { eye_ptrs.push_back(¢ralEye); }
|
|
|
|
EyePose centralEye;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} /* namespace st3d */
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* GL_STEREO3D_H_ */
|