/
vrconfig.h
187 lines (156 loc) · 5.07 KB
/
vrconfig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/** @file vrconfig.h Virtual reality configuration.
*
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright (c) 2013 Christopher Bruns <cmbruns@rotatingpenguin.com>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, see:
* http://www.gnu.org/licenses</small>
*/
#ifndef LIBAPPFW_VRCONFIG_H
#define LIBAPPFW_VRCONFIG_H
#include <de/OculusRift>
namespace de {
/**
* Virtual reality configuration settings.
*/
class LIBAPPFW_PUBLIC VRConfig
{
public:
/**
* Stereoscopic 3D rendering mode. This enumeration determines the integer value in
* the console variable.
*/
enum StereoMode
{
Mono, // 0
GreenMagenta,
RedCyan,
LeftOnly,
RightOnly,
TopBottom, // 5
SideBySide,
Parallel,
CrossEye,
OculusRift,
RowInterleaved, // 10 // NOT IMPLEMENTED YET
ColumnInterleaved, // NOT IMPLEMENTED YET
Checkerboard, // NOT IMPLEMENTED YET
QuadBuffered,
NUM_STEREO_MODES
};
public:
VRConfig();
/**
* Sets the current stereoscopic rendering mode.
*
* @param newMode Rendering mode.
*/
void setMode(StereoMode newMode);
/**
* Sets the distance from the eye to the screen onto which projection is being
* done. This used when calculating a frustum-shifted projection matrix.
* This is not used with Oculus Rift.
*
* @param distance Distance.
*/
void setScreenDistance(float distance);
/**
* Sets the height of the eye in map units. This is used to determine how big an
* eye shift is needed.
*
* @param eyeHeightInMapUnits Height of the eye in map units, measured from the
* "ground".
*/
void setEyeHeightInMapUnits(float eyeHeightInMapUnits);
/**
* Sets the currently used physical IPD. This is used to determine how big an
* eye shift is needed.
*
* @param ipd IPD in mm.
*/
void setInterpupillaryDistance(float ipd);
/**
* Sets the height of the player in the real world. This is used as a scaling
* factor to convert physical units to map units.
*
* @param heightInMeters Height of the player in meters.
*/
void setPhysicalPlayerHeight(float heightInMeters);
enum Eye {
NeitherEye,
LeftEye,
RightEye
};
/**
* Sets the eye currently used for rendering a frame. In stereoscopic modes,
* the frame is drawn twice; once for each eye.
*
* @param eye Eye to render. In non-stereoscopic modes, NeitherEye is used.
*/
void setCurrentEye(Eye eye);
/**
* Enables or disables projection frustum shifting.
*
* @param enable @c true to enable.
*/
void enableFrustumShift(bool enable = true);
/**
* Sets the number of multisampling samples used in the offscreen framebuffer
* where Oculus Rift frames are first drawn. This framebuffer is typically some
* multiple of the Oculus Rift display resolution.
*
* @param samples Number of samples to use for multisampling the Oculus Rift
* framebuffer.
*/
void setRiftFramebufferSampleCount(int samples);
/**
* Sets the eyes-swapped mode.
*
* @param swapped @c true to swap left and right (default: false).
*/
void setSwapEyes(bool swapped);
void setDominantEye(float value);
/**
* Currently active stereo rendering mode.
*/
StereoMode mode() const;
float screenDistance() const;
/**
* Determines if the current stereoscopic rendering mode needs support from
* the graphics hardware for quad-buffering (left/right back and front
* buffers stored and drawn separately).
*/
bool needsStereoGLFormat() const;
float interpupillaryDistance() const;
float physicalPlayerHeight() const;
/**
* Local viewpoint relative eye position in map units.
*/
float eyeShift() const;
/**
* Determines if frustum shift is enabled.
*/
bool frustumShift() const;
bool swapEyes() const;
float dominantEye() const;
/// Multisampling used in unwarped Rift framebuffer.
int riftFramebufferSampleCount() const;
de::OculusRift &oculusRift();
de::OculusRift const &oculusRift() const;
public:
static bool modeNeedsStereoGLFormat(StereoMode mode);
private:
DENG2_PRIVATE(d)
};
} // namespace de
#endif // LIBAPPFW_VRCONFIG_H