Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CAPI_HMDRenderState.cpp
Go to the documentation of this file.
1 /************************************************************************************
2 
3 Filename : OVR_CAPI_HMDRenderState.cpp
4 Content : Combines all of the rendering state associated with the HMD
5 Created : February 2, 2014
6 Authors : Michael Antonov
7 
8 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
9 
10 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
12 which is provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
14 
15 You may obtain a copy of the License at
16 
17 http://www.oculusvr.com/licenses/LICENSE-3.1
18 
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
24 
25 ************************************************************************************/
26 
27 #include "CAPI_HMDRenderState.h"
28 
29 namespace OVR { namespace CAPI {
30 
31 
32 //-------------------------------------------------------------------------------------
33 // ***** HMDRenderState
34 
35 
36 HMDRenderState::HMDRenderState(ovrHmd hmd, Profile* userProfile, const OVR::HMDInfo& hmdInfo)
37  : HMD(hmd), HMDInfo(hmdInfo)
38 {
40 
43 
44  ClearColor[0] = ClearColor[1] = ClearColor[2] = ClearColor[3] =0.0f;
45 
46  EnabledHmdCaps = 0;
47 }
48 
50 {
51 }
52 
54 {
55  ovrHmdDesc d;
56  memset(&d, 0, sizeof(d));
57 
58  d.Type = ovrHmd_Other;
59 
68 
72 
73  if (strstr(HMDInfo.ProductName, "DK1"))
74  {
75  d.Type = ovrHmd_DK1;
76  }
77  else if (strstr(HMDInfo.ProductName, "DK2"))
78  {
79  d.Type = ovrHmd_DK2;
83  }
84 
85  DistortionRenderDesc& leftDistortion = Distortion[0];
86  DistortionRenderDesc& rightDistortion = Distortion[1];
87 
88  // The suggested FOV (assuming eye rotation)
91 
92  // FOV extended across the entire screen
93  d.MaxEyeFov[0] = GetPhysicalScreenFov(StereoEye_Left, leftDistortion);
94  d.MaxEyeFov[1] = GetPhysicalScreenFov(StereoEye_Right, rightDistortion);
95 
97  {
100  }
101  else
102  {
105  }
106 
107  return d;
108 }
109 
110 
111 ovrSizei HMDRenderState::GetFOVTextureSize(int eye, ovrFovPort fov, float pixelsPerDisplayPixel)
112 {
113  OVR_ASSERT((unsigned)eye < 2);
115  return CalculateIdealPixelSize(seye, Distortion[eye], fov, pixelsPerDisplayPixel);
116 }
117 
119 {
120  HmdRenderInfo& hmdri = RenderInfo;
121  StereoEye eye = (eyeType == ovrEye_Left) ? StereoEye_Left : StereoEye_Right;
122  ovrEyeRenderDesc e0;
123 
124  e0.Eye = eyeType;
125  e0.Fov = fov;
126  e0.ViewAdjust = CalculateEyeVirtualCameraOffset(hmdri, eye, false);
127  e0.DistortedViewport = GetFramebufferViewport(eye, hmdri);
129 
130  return e0;
131 }
132 
133 
135  const ovrFovPort eyeFovIn[2] )
136 {
137  eyeRenderDescOut[0] = EyeRenderDesc[0] = calcRenderDesc(ovrEye_Left, eyeFovIn[0]);
138  eyeRenderDescOut[1] = EyeRenderDesc[1] = calcRenderDesc(ovrEye_Right, eyeFovIn[1]);
139 }
140 
141 
142 }} // namespace OVR::CAPI
143 
ovrRecti DistortedViewport
Definition: OVR_CAPI.h:323
ovrEyeType Eye
Definition: OVR_CAPI.h:321
const float OVR_DEFAULT_EXTRA_EYE_ROTATION
Definition: OVR_Stereo.h:346
Recti GetFramebufferViewport(StereoEye eyeType, HmdRenderInfo const &hmd)
ovrEyeType EyeRenderOrder[ovrEye_Count]
Definition: OVR_CAPI.h:216
int h
Definition: OVR_CAPI.h:54
ovrFovPort Fov
Definition: OVR_CAPI.h:322
FovPort CalculateFovFromHmdInfo(StereoEye eyeType, DistortionRenderDesc const &distortion, HmdRenderInfo const &hmd, float extraEyeRotationInRadians)
HmdShutterTypeEnum Type
Definition: OVR_Device.h:333
ovrVector2i WindowsPos
Definition: OVR_CAPI.h:208
DistortionRenderDesc Distortion[2]
unsigned int HmdCaps
Definition: OVR_CAPI.h:199
Sizei CalculateIdealPixelSize(StereoEye eyeType, DistortionRenderDesc const &distortion, FovPort tanHalfFov, float pixelsPerDisplayPixel)
ovrEyeType
Definition: OVR_CAPI.h:177
char DisplayDeviceName[32]
Definition: OVR_Device.h:347
DistortionRenderDesc CalculateDistortionRenderDesc(StereoEye eyeType, HmdRenderInfo const &hmd, const LensConfig *pLensOverride)
ovrFovPort MaxEyeFov[ovrEye_Count]
Definition: OVR_CAPI.h:212
FovPort GetPhysicalScreenFov(StereoEye eyeType, DistortionRenderDesc const &distortion)
ovrHmdType Type
Definition: OVR_CAPI.h:192
String ProductName
Definition: OVR_Device.h:154
ovrFovPort DefaultEyeFov[ovrEye_Count]
Definition: OVR_CAPI.h:211
#define OVR_ASSERT(p)
ovrSizei Resolution
Definition: OVR_CAPI.h:206
void setupRenderDesc(ovrEyeRenderDesc eyeRenderDescOut[2], const ovrFovPort eyeFovIn[2])
Vector3f CalculateEyeVirtualCameraOffset(HmdRenderInfo const &hmd, StereoEye eyeType, bool bmonoRenderingMode)
ovrVector3f ViewAdjust
Definition: OVR_CAPI.h:325
const char * Manufacturer
Definition: OVR_CAPI.h:196
ovrVector2f PixelsPerTanAngleAtCenter
Definition: OVR_CAPI.h:324
ovrEyeRenderDesc calcRenderDesc(ovrEyeType eyeType, const ovrFovPort &fov)
unsigned int DistortionCaps
Definition: OVR_CAPI.h:203
__BEGIN_NAMESPACE_STD void void __END_NAMESPACE_STD void __BEGIN_NAMESPACE_STD void * memset(void *__s, int __c, size_t __n) __THROW __nonnull((1))
int DisplayId
Definition: OVR_CAPI.h:227
struct OVR::HMDInfo::ShutterInfo Shutter
String Manufacturer
Definition: OVR_Device.h:155
Size< int > ResolutionInPixels
Definition: OVR_Device.h:324
const char * ProductName
Definition: OVR_CAPI.h:195
int w
Definition: OVR_CAPI.h:54
ovrSizei GetFOVTextureSize(int eye, ovrFovPort fov, float pixelsPerDisplayPixel)
unsigned int SensorCaps
Definition: OVR_CAPI.h:201
Vector2f PixelsPerTanAngleAtCenter
Definition: OVR_Stereo.h:247
const char * DisplayDeviceName
Definition: OVR_CAPI.h:225
HmdRenderInfo GenerateHmdRenderInfoFromHmdInfo(HMDInfo const &hmdInfo, Profile const *profile, DistortionEqnType distortionType, EyeCupType eyeCupOverride)
Definition: OVR_Stereo.cpp:662
StereoEye
Definition: OVR_Stereo.h:44
__END_NAMESPACE_STD __BEGIN_NAMESPACE_STD size_t size_t char char * strstr(const char *__haystack, const char *__needle) __THROW __attribute_pure__ __nonnull((1
HMDRenderState(ovrHmd hmd, Profile *userProfile, const OVR::HMDInfo &hmdInfo)
ovrEyeRenderDesc EyeRenderDesc[2]