SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLGLOculus.h
Go to the documentation of this file.
1 /**
2  * \file SLOculus.h
3  * \brief Wrapper around Oculus Rift
4  * \date July 2014
5  * \remarks Please use clangformat to format the code. See more code style on
6  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
7  * \authors Marc Wacker, Roman Kuehne, Marcus Hudritsch
8  * \copyright http://opensource.org/licenses/GPL-3.0
9 */
10 
11 #ifndef SLOCULUS_H
12 #define SLOCULUS_H
13 
14 #include <SLCamera.h>
15 
16 //-----------------------------------------------------------------------------
17 //! Distorted vertex used to draw in the Oculus frame buffer.
19 {
26 };
27 
28 typedef vector<SLVertexOculus> SLVVertexOculus;
29 
30 //-----------------------------------------------------------------------------
31 //! Wrapper around Oculus Rift Devkit 2.
32 /*! This class is depricated since the lib_ovr from Oculus completely changed
33 The lib_ovr that connects the Oculus hardware was removed since it only worked
34 for devkit2 under windows.
35 */
37 {
38 public:
39  SLGLOculus(SLstring shaderDir);
40  ~SLGLOculus();
41 
42  void init();
43 
44  const SLQuat4f& orientation(SLEyeType eye);
45  const SLVec3f& position(SLEyeType eye);
46 
47  const SLVec3f& viewAdjust(SLEyeType eye);
48  const SLMat4f& projection(SLEyeType eye);
49  const SLMat4f& orthoProjection(SLEyeType eye);
50 
52  void renderResolution(SLint width, SLint height);
53  void beginFrame();
54  void renderDistortion(SLint width,
55  SLint height,
56  SLuint tex,
57  const SLCol4f& background);
58  // Setters
59  void lowPersistance(SLbool val);
60  void timeWarp(SLbool val);
61  void positionTracking(SLbool val);
62  void displaySleep(SLbool val);
63 
64  // Getters
68 
72 
73 private:
74  void dispose();
75  void calculateHmdValues(); //!< recalculate HMD settings changed
76 
77  // SL variables that can be accessed via getters
78  SLVec2i _outputRes; //!< output resolution used for ortho projection
79 
80  SLQuat4f _orientation[2]; //!< eye orientation
81  SLVec3f _position[2]; //!< eye position
82  SLMat4f _projection[2]; //!< projection matrices for left and right eye
83  SLMat4f _orthoProjection[2]; //!< projection for 2d elements
84  SLVec3f _viewAdjust[2]; //!< view adjust vector
85  SLGLVertexArray _distortionMeshVAO[2]; //!< distortion meshes for left and right eye
86 
87  SLfloat _resolutionScale; //!< required resolution scale for a 1.0 min pixel density
88 
89  // distortion
90  SLbool _usingDebugHmd; //!< we're using a debug HMD
91  SLbool _positionTrackingEnabled; //!< is position tracking enabled
92  SLbool _lowPersistanceEnabled; //!< low persistence rendering enabled
93  SLbool _timeWarpEnabled; //!< time warp correction enabled
94  SLbool _displaySleep; //!< is the display of the rift currently off
95 
96  SLbool _isConnected; //!< is HMD connected
97  SLbool _isCameraConnected; //!< is position tracker camera connected
98  SLbool _isPositionTracked; //!< is the position tracked (false if out of range)
99 
100  SLVec2i _resolution; //!< Resolution of the HMD
101  SLVec2i _rtSize; //!< Required resolution for the render target
102 
103  SLbool _hmdSettingsChanged; //!< settings need to be updated flag
104 
106 
108 };
109 //-----------------------------------------------------------------------------
110 
111 #endif
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
string SLstring
Definition: SL.h:158
int SLint
Definition: SL.h:170
SLEyeType
Enumeration for stereo eye type used for camera projection.
Definition: SLEnums.h:152
vector< SLVertexOculus > SLVVertexOculus
Definition: SLGLOculus.h:28
Wrapper around Oculus Rift Devkit 2.
Definition: SLGLOculus.h:37
SLbool isConnected()
Definition: SLGLOculus.h:65
SLbool isLowPersistanceEnabled()
Definition: SLGLOculus.h:70
void positionTracking(SLbool val)
Definition: SLGLOculus.cpp:247
SLbool isPositionTracked()
Definition: SLGLOculus.h:67
const SLVec3f & viewAdjust(SLEyeType eye)
Definition: SLGLOculus.cpp:118
const SLQuat4f & orientation(SLEyeType eye)
Definition: SLGLOculus.cpp:205
void lowPersistance(SLbool val)
Definition: SLGLOculus.cpp:225
SLbool _hmdSettingsChanged
settings need to be updated flag
Definition: SLGLOculus.h:103
void init()
Definition: SLGLOculus.cpp:53
SLstring _shaderFileDir
Definition: SLGLOculus.h:107
const SLVec3f & position(SLEyeType eye)
Definition: SLGLOculus.cpp:215
void beginFrame()
Definition: SLGLOculus.cpp:195
SLbool _usingDebugHmd
we're using a debug HMD
Definition: SLGLOculus.h:90
SLVec2i _resolution
Resolution of the HMD.
Definition: SLGLOculus.h:100
SLVec3f _viewAdjust[2]
view adjust vector
Definition: SLGLOculus.h:84
SLfloat resolutionScale()
Definition: SLGLOculus.h:51
SLGLVertexArray _distortionMeshVAO[2]
distortion meshes for left and right eye
Definition: SLGLOculus.h:85
const SLMat4f & orthoProjection(SLEyeType eye)
Definition: SLGLOculus.cpp:140
const SLMat4f & projection(SLEyeType eye)
Definition: SLGLOculus.cpp:129
void renderDistortion(SLint width, SLint height, SLuint tex, const SLCol4f &background)
Definition: SLGLOculus.cpp:79
SLbool isCameraConnected()
Definition: SLGLOculus.h:66
SLVec2i _outputRes
output resolution used for ortho projection
Definition: SLGLOculus.h:78
void dispose()
Definition: SLGLOculus.cpp:47
SLVec3f _position[2]
eye position
Definition: SLGLOculus.h:81
SLbool isTimeWarpEnabled()
Definition: SLGLOculus.h:71
SLVec2i _rtSize
Required resolution for the render target.
Definition: SLGLOculus.h:101
SLbool isPositionTrackingEnabled()
Definition: SLGLOculus.h:69
SLMat4f _projection[2]
projection matrices for left and right eye
Definition: SLGLOculus.h:82
void calculateHmdValues()
recalculate HMD settings changed
Definition: SLGLOculus.cpp:151
SLbool _isConnected
is HMD connected
Definition: SLGLOculus.h:96
SLbool _displaySleep
is the display of the rift currently off
Definition: SLGLOculus.h:94
SLbool _timeWarpEnabled
time warp correction enabled
Definition: SLGLOculus.h:93
SLbool _lowPersistanceEnabled
low persistence rendering enabled
Definition: SLGLOculus.h:92
SLQuat4f _orientation[2]
eye orientation
Definition: SLGLOculus.h:80
SLGLOculus(SLstring shaderDir)
Definition: SLGLOculus.cpp:19
SLfloat _resolutionScale
required resolution scale for a 1.0 min pixel density
Definition: SLGLOculus.h:87
void timeWarp(SLbool val)
Definition: SLGLOculus.cpp:236
SLGLProgram * _stereoOculusDistProgram
Definition: SLGLOculus.h:105
void renderResolution(SLint width, SLint height)
Definition: SLGLOculus.cpp:182
void displaySleep(SLbool val)
Definition: SLGLOculus.cpp:258
SLbool _isPositionTracked
is the position tracked (false if out of range)
Definition: SLGLOculus.h:98
SLbool _isCameraConnected
is position tracker camera connected
Definition: SLGLOculus.h:97
SLMat4f _orthoProjection[2]
projection for 2d elements
Definition: SLGLOculus.h:83
SLbool _positionTrackingEnabled
is position tracking enabled
Definition: SLGLOculus.h:91
Encapsulation of an OpenGL shader program object.
Definition: SLGLProgram.h:56
SLGLVertexArray encapsulates the core OpenGL drawing.
Distorted vertex used to draw in the Oculus frame buffer.
Definition: SLGLOculus.h:19
SLVec2f tanEyeAnglesG
Definition: SLGLOculus.h:24
SLVec2f tanEyeAnglesR
Definition: SLGLOculus.h:23
SLVec2f screenPosNDC
Definition: SLGLOculus.h:20
float timeWarpFactor
Definition: SLGLOculus.h:21
float vignetteFactor
Definition: SLGLOculus.h:22
SLVec2f tanEyeAnglesB
Definition: SLGLOculus.h:25