ovr_sdk

annotate LibOVR/Src/CAPI/CAPI_HSWDisplay.cpp @ 0:1b39a1b46319

initial 0.4.4
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 Jan 2015 06:51:16 +0200
parents
children
rev   line source
nuclear@0 1 /************************************************************************************
nuclear@0 2
nuclear@0 3 Filename : CAPI_HSWDisplay.cpp
nuclear@0 4 Content : Implements Health and Safety Warning system.
nuclear@0 5 Created : July 3, 2014
nuclear@0 6 Authors : Paul Pedriana
nuclear@0 7
nuclear@0 8 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
nuclear@0 9
nuclear@0 10 Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
nuclear@0 11 you may not use the Oculus VR Rift SDK except in compliance with the License,
nuclear@0 12 which is provided at the time of installation or download, or which
nuclear@0 13 otherwise accompanies this software in either electronic or hard copy form.
nuclear@0 14
nuclear@0 15 You may obtain a copy of the License at
nuclear@0 16
nuclear@0 17 http://www.oculusvr.com/licenses/LICENSE-3.2
nuclear@0 18
nuclear@0 19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
nuclear@0 20 distributed under the License is distributed on an "AS IS" BASIS,
nuclear@0 21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nuclear@0 22 See the License for the specific language governing permissions and
nuclear@0 23 limitations under the License.
nuclear@0 24
nuclear@0 25 ************************************************************************************/
nuclear@0 26
nuclear@0 27 #include "CAPI_HSWDisplay.h"
nuclear@0 28 #include "CAPI_HMDState.h"
nuclear@0 29 #include "../Kernel/OVR_Log.h"
nuclear@0 30 #include "../Kernel/OVR_String.h"
nuclear@0 31 #include "Textures/healthAndSafety.tga.h" // TGA file as a C array declaration.
nuclear@0 32 #include <stdlib.h>
nuclear@0 33
nuclear@0 34 //-------------------------------------------------------------------------------------
nuclear@0 35 // ***** HSWDISPLAY_DEBUGGING
nuclear@0 36 //
nuclear@0 37 // Defined as 0 or 1. Enables debugging features of this module.
nuclear@0 38
nuclear@0 39 #if !defined(HSWDISPLAY_DEBUGGING)
nuclear@0 40 #if defined(AUTHOR_PPEDRIANA)
nuclear@0 41 #define HSWDISPLAY_DEBUGGING 1
nuclear@0 42 #else
nuclear@0 43 #define HSWDISPLAY_DEBUGGING 0
nuclear@0 44 #endif
nuclear@0 45 #endif
nuclear@0 46
nuclear@0 47 #if HSWDISPLAY_DEBUGGING
nuclear@0 48 OVR_DISABLE_ALL_MSVC_WARNINGS()
nuclear@0 49 #include <winsock2.h>
nuclear@0 50 #include <Windows.h>
nuclear@0 51 OVR_RESTORE_ALL_MSVC_WARNINGS()
nuclear@0 52 #endif
nuclear@0 53
nuclear@0 54 OVR_DISABLE_MSVC_WARNING(4996) // "This function or variable may be unsafe..."
nuclear@0 55
nuclear@0 56
nuclear@0 57 //-------------------------------------------------------------------------------------
nuclear@0 58 // ***** HSWDISPLAY_DEFAULT_ENABLED
nuclear@0 59 //
nuclear@0 60 // Defined as 0 or 1. 1 is default. If 0 then by default HSWDisplay is disabled.
nuclear@0 61 // Developers can set it to 0 to disable HSW display.
nuclear@0 62 //
nuclear@0 63 #if !defined(HSWDISPLAY_DEFAULT_ENABLED)
nuclear@0 64 #define HSWDISPLAY_DEFAULT_ENABLED 1
nuclear@0 65 #endif
nuclear@0 66
nuclear@0 67
nuclear@0 68
nuclear@0 69 //-------------------------------------------------------------------------------------
nuclear@0 70 // ***** Experimental C API functions
nuclear@0 71 //
nuclear@0 72
nuclear@0 73 extern "C"
nuclear@0 74 {
nuclear@0 75 OVR_EXPORT void ovrhmd_EnableHSWDisplaySDKRender(ovrHmd hmd, ovrBool enabled)
nuclear@0 76 {
nuclear@0 77 OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)hmd->Handle;
nuclear@0 78
nuclear@0 79 if (pHMDState)
nuclear@0 80 {
nuclear@0 81 OVR::CAPI::HSWDisplay* pHSWDisplay = pHMDState->pHSWDisplay;
nuclear@0 82
nuclear@0 83 if(pHSWDisplay)
nuclear@0 84 pHSWDisplay->EnableRender((enabled == 0) ? false : true);
nuclear@0 85 }
nuclear@0 86 }
nuclear@0 87 }
nuclear@0 88
nuclear@0 89
nuclear@0 90
nuclear@0 91
nuclear@0 92 //-------------------------------------------------------------------------------------
nuclear@0 93 // ***** HSWDisplay implementation
nuclear@0 94 //
nuclear@0 95
nuclear@0 96 namespace OVR { namespace CAPI {
nuclear@0 97
nuclear@0 98
nuclear@0 99 static const time_t HSWDisplayTimeNever = (time_t)0; // Constant which denotes the time of "never", as in the display has never been shown yet.
nuclear@0 100
nuclear@0 101 #define HSWDISPLAY_POLL_INTERVAL 0.400 // Seconds between polling for whether the display should be shown.
nuclear@0 102 #define OVR_KEY_HSWDISPLAYLASTDISPLAYEDTIME "HASWLastDisplayedTime"
nuclear@0 103
nuclear@0 104
nuclear@0 105 #if defined(OVR_BUILD_DEBUG)
nuclear@0 106 #define HSWDISPLAY_FIRST_DISMISSAL_TIME 4 // Earliest time in seconds until the user can dismiss the display.
nuclear@0 107 #define HSWDISPLAY_REGULAR_DISMISSAL_TIME 2
nuclear@0 108 #else
nuclear@0 109 #define HSWDISPLAY_FIRST_DISMISSAL_TIME 15
nuclear@0 110 #define HSWDISPLAY_REGULAR_DISMISSAL_TIME 6
nuclear@0 111 #endif
nuclear@0 112
nuclear@0 113
nuclear@0 114 HSWDisplay::HSWDisplay(ovrRenderAPIType renderAPIType, ovrHmd hmd, const HMDRenderState& hmdRenderState)
nuclear@0 115 : Enabled(HSWDISPLAY_DEFAULT_ENABLED ? true : false),
nuclear@0 116 Displayed(false),
nuclear@0 117 SDKRendered(false),
nuclear@0 118 DismissRequested(false),
nuclear@0 119 RenderEnabled(true),
nuclear@0 120 UnloadGraphicsRequested(false),
nuclear@0 121 StartTime(0.0),
nuclear@0 122 DismissibleTime(0.0),
nuclear@0 123 LastPollTime(0.0),
nuclear@0 124 HMD(hmd),
nuclear@0 125 HMDMounted(false),
nuclear@0 126 HMDNewlyMounted(false),
nuclear@0 127 RenderAPIType(renderAPIType),
nuclear@0 128 RenderState(hmdRenderState),
nuclear@0 129 LastProfileName(),
nuclear@0 130 LastHSWTime(0)
nuclear@0 131 {
nuclear@0 132 }
nuclear@0 133
nuclear@0 134
nuclear@0 135 HSWDisplay::~HSWDisplay()
nuclear@0 136 {
nuclear@0 137 // To consider: assert that we are already shut down.
nuclear@0 138 HSWDisplay::Shutdown();
nuclear@0 139 }
nuclear@0 140
nuclear@0 141
nuclear@0 142 void HSWDisplay::Enable(bool enable)
nuclear@0 143 {
nuclear@0 144 Enabled = enable;
nuclear@0 145
nuclear@0 146 if(!enable && Displayed) // If it's visible but should not be...
nuclear@0 147 Dismiss();
nuclear@0 148 }
nuclear@0 149
nuclear@0 150
nuclear@0 151 void HSWDisplay::EnableRender(bool enable)
nuclear@0 152 {
nuclear@0 153 RenderEnabled = enable;
nuclear@0 154 }
nuclear@0 155
nuclear@0 156
nuclear@0 157 void HSWDisplay::Display()
nuclear@0 158 {
nuclear@0 159 HSWDISPLAY_LOG(("[HSWDisplay] Display()"));
nuclear@0 160
nuclear@0 161 DisplayInternal();
nuclear@0 162
nuclear@0 163 HMDNewlyMounted = false;
nuclear@0 164 Displayed = true;
nuclear@0 165 SDKRendered = RenderEnabled;
nuclear@0 166 StartTime = ovr_GetTimeInSeconds();
nuclear@0 167
nuclear@0 168 const time_t lastDisplayedTime = HSWDisplay::GetCurrentProfileLastHSWTime();
nuclear@0 169 DismissibleTime = StartTime + ((lastDisplayedTime == HSWDisplayTimeNever) ? HSWDISPLAY_FIRST_DISMISSAL_TIME : HSWDISPLAY_REGULAR_DISMISSAL_TIME);
nuclear@0 170
nuclear@0 171 SetCurrentProfileLastHSWTime(time(NULL));
nuclear@0 172 }
nuclear@0 173
nuclear@0 174
nuclear@0 175 bool HSWDisplay::IsDisplayViewable() const
nuclear@0 176 {
nuclear@0 177 // This function is called IsDisplayViewable, but currently it refers only to whether the
nuclear@0 178 // HMD is mounted on the user's head.
nuclear@0 179
nuclear@0 180 return HMDMounted;
nuclear@0 181 }
nuclear@0 182
nuclear@0 183
nuclear@0 184 bool HSWDisplay::Dismiss()
nuclear@0 185 {
nuclear@0 186 #if HSWDISPLAY_DEBUGGING && defined(OVR_OS_WIN32)
nuclear@0 187 if(GetKeyState(VK_SCROLL) & 0x0001) // If the scroll lock key is toggled on...
nuclear@0 188 return false; // Make it so that the display doesn't dismiss, so we can debug this.
nuclear@0 189 #endif
nuclear@0 190
nuclear@0 191 // If dismissal is not requested yet, mark it as such.
nuclear@0 192 bool newlyRequested = false;
nuclear@0 193
nuclear@0 194 if(!DismissRequested)
nuclear@0 195 {
nuclear@0 196 DismissRequested = true;
nuclear@0 197 newlyRequested = true;
nuclear@0 198 }
nuclear@0 199
nuclear@0 200 // If displayed and time has elapsed, do the dismissal.
nuclear@0 201 OVR_ASSERT(DismissibleTime <= (ovr_GetTimeInSeconds() + HSWDISPLAY_FIRST_DISMISSAL_TIME)); // Make sure the dismissal time is sane.
nuclear@0 202 if (Displayed && (ovr_GetTimeInSeconds() >= DismissibleTime))
nuclear@0 203 {
nuclear@0 204 DismissInternal();
nuclear@0 205 Displayed = false;
nuclear@0 206 DismissRequested = false;
nuclear@0 207 SDKRendered = false;
nuclear@0 208 return true;
nuclear@0 209 }
nuclear@0 210
nuclear@0 211 if(newlyRequested)
nuclear@0 212 { HSWDISPLAY_LOG(("[HSWDisplay] Dismiss(): Not permitted yet. Queued for timeout in %.1f seconds.", DismissibleTime - ovr_GetTimeInSeconds())); }
nuclear@0 213
nuclear@0 214 return false; // Cannot dismiss yet.
nuclear@0 215 }
nuclear@0 216
nuclear@0 217
nuclear@0 218 bool HSWDisplay::TickState(ovrHSWDisplayState *hswDisplayState, bool graphicsContext)
nuclear@0 219 {
nuclear@0 220 bool newlyDisplayed = false;
nuclear@0 221 const double currentTime = ovr_GetTimeInSeconds();
nuclear@0 222
nuclear@0 223 // See if we need to be currently displayed. By design we automatically display but don't automatically dismiss.
nuclear@0 224 if (Displayed)
nuclear@0 225 {
nuclear@0 226 if (DismissRequested) // If dismiss was previously requested, see if it can be executed.
nuclear@0 227 Dismiss();
nuclear@0 228
nuclear@0 229 if (Displayed) // If not already dismissed above...
nuclear@0 230 {
nuclear@0 231 // We currently have the debug behavior that we permit dismiss very soon after launch.
nuclear@0 232 #if defined(OVR_BUILD_DEBUG)
nuclear@0 233 if(currentTime >= (StartTime + 2))
nuclear@0 234 {
nuclear@0 235 DismissibleTime = StartTime;
nuclear@0 236 //Dismiss();
nuclear@0 237 }
nuclear@0 238 #endif
nuclear@0 239 }
nuclear@0 240
nuclear@0 241 if (Displayed) // If not already dismissed above...
nuclear@0 242 {
nuclear@0 243 const ovrTrackingState ts = ((OVR::CAPI::HMDState*)HMD->Handle)->PredictedTrackingState(currentTime);
nuclear@0 244
nuclear@0 245 if (ts.StatusFlags & ovrStatus_OrientationTracked) // If the Accelerometer data is valid...
nuclear@0 246 {
nuclear@0 247 const OVR::Vector3f v(ts.HeadPose.LinearAcceleration.x, ts.HeadPose.LinearAcceleration.y, ts.HeadPose.LinearAcceleration.z);
nuclear@0 248
nuclear@0 249 const float minTapMagnitude = 350.0f; // Empirically determined by some testing.
nuclear@0 250
nuclear@0 251 if (v.LengthSq() > minTapMagnitude)
nuclear@0 252 Dismiss(); // This will do nothing if the display is not present.
nuclear@0 253 }
nuclear@0 254 }
nuclear@0 255 }
nuclear@0 256 else if (Enabled && (currentTime >= (LastPollTime + HSWDISPLAY_POLL_INTERVAL)))
nuclear@0 257 {
nuclear@0 258 LastPollTime = currentTime;
nuclear@0 259
nuclear@0 260 // We need to display if any of the following are true:
nuclear@0 261 // - The application is just started in Event Mode while the HMD is mounted (warning display would be viewable) and this app was not spawned from a launcher.
nuclear@0 262 // - The current user has never seen the display yet while the HMD is mounted (warning display would be viewable).
nuclear@0 263 // - The HMD is newly mounted (or the warning display is otherwise newly viewable).
nuclear@0 264 // - The warning display hasn't shown in 24 hours (need to verify this as a requirement).
nuclear@0 265 // Event Mode refers to when the app is being run in a public demo event such as a trade show.
nuclear@0 266
nuclear@0 267 OVR::CAPI::HMDState* pHMDState = (OVR::CAPI::HMDState*)HMD->Handle;
nuclear@0 268
nuclear@0 269 if(pHMDState)
nuclear@0 270 {
nuclear@0 271 const time_t lastDisplayedTime = HSWDisplay::GetCurrentProfileLastHSWTime();
nuclear@0 272
nuclear@0 273 // We currently unilaterally set HMDMounted to true because we don't yet have the ability to detect this. To do: Implement this when possible.
nuclear@0 274 const bool previouslyMounted = HMDMounted;
nuclear@0 275 HMDMounted = true;
nuclear@0 276 HMDNewlyMounted = (!previouslyMounted && HMDMounted); // We set this back to false in the Display function or if the HMD is unmounted before then.
nuclear@0 277
nuclear@0 278 if((lastDisplayedTime == HSWDisplayTimeNever) || HMDNewlyMounted)
nuclear@0 279 {
nuclear@0 280 if(IsDisplayViewable()) // If the HMD is mounted and otherwise being viewed by the user...
nuclear@0 281 {
nuclear@0 282 Display();
nuclear@0 283 newlyDisplayed = true;
nuclear@0 284 }
nuclear@0 285 }
nuclear@0 286 }
nuclear@0 287 }
nuclear@0 288 else if(graphicsContext && UnloadGraphicsRequested)
nuclear@0 289 {
nuclear@0 290 UnloadGraphics();
nuclear@0 291 UnloadGraphicsRequested = false;
nuclear@0 292 }
nuclear@0 293
nuclear@0 294 if(hswDisplayState)
nuclear@0 295 GetState(hswDisplayState);
nuclear@0 296
nuclear@0 297 return newlyDisplayed;
nuclear@0 298 }
nuclear@0 299
nuclear@0 300
nuclear@0 301 void HSWDisplay::GetState(ovrHSWDisplayState *hswDisplayState) const
nuclear@0 302 {
nuclear@0 303 // Return the state to the caller.
nuclear@0 304 OVR_ASSERT(hswDisplayState != NULL);
nuclear@0 305 if(hswDisplayState)
nuclear@0 306 {
nuclear@0 307 hswDisplayState->Displayed = Displayed;
nuclear@0 308 hswDisplayState->StartTime = StartTime;
nuclear@0 309 hswDisplayState->DismissibleTime = DismissibleTime;
nuclear@0 310 }
nuclear@0 311 }
nuclear@0 312
nuclear@0 313
nuclear@0 314 void HSWDisplay::Render(ovrEyeType eye, const ovrTexture* eyeTexture)
nuclear@0 315 {
nuclear@0 316 SDKRendered = true;
nuclear@0 317 RenderInternal(eye, eyeTexture);
nuclear@0 318 }
nuclear@0 319
nuclear@0 320 // Persist the HSW settings on the server, since it needs to be synchronized across all applications.
nuclear@0 321 // Note that the profile manager singleton cannot be used for this task because it overwrites the global
nuclear@0 322 // settings for which the rift config tool is supposed to be authoritative. That also would step on the
nuclear@0 323 // settings generated by other rift apps. The server settings, however, are synchronized for all apps
nuclear@0 324 // and so are appropriate for this task.
nuclear@0 325 static String getHSWTimeKey(const char* userName)
nuclear@0 326 {
nuclear@0 327 String keyName = "server:";
nuclear@0 328 keyName += OVR_KEY_HSWDISPLAYLASTDISPLAYEDTIME;
nuclear@0 329 keyName += ":";
nuclear@0 330 if (userName)
nuclear@0 331 {
nuclear@0 332 keyName += userName;
nuclear@0 333 }
nuclear@0 334 return keyName;
nuclear@0 335 }
nuclear@0 336
nuclear@0 337 // Returns HSWDisplayTimeNever (0) if there is no profile or this is the first time we are seeing this profile.
nuclear@0 338 time_t HSWDisplay::GetCurrentProfileLastHSWTime() const
nuclear@0 339 {
nuclear@0 340 // We store the timeout value in HMDState's pProfile.
nuclear@0 341 HMDState* pHMDState = (HMDState*)HMD->Handle;
nuclear@0 342
nuclear@0 343 if (pHMDState)
nuclear@0 344 {
nuclear@0 345 const char* profileName = pHMDState->pProfile ? pHMDState->pProfile->GetValue(OVR_KEY_USER) : NULL;
nuclear@0 346
nuclear@0 347 if (profileName)
nuclear@0 348 {
nuclear@0 349 if (LastProfileName == profileName)
nuclear@0 350 {
nuclear@0 351 return LastHSWTime;
nuclear@0 352 }
nuclear@0 353
nuclear@0 354 LastProfileName = profileName;
nuclear@0 355 String timeKey = getHSWTimeKey(profileName);
nuclear@0 356 int lastTime = pHMDState->getIntValue(timeKey.ToCStr(), (int)HSWDisplayTimeNever);
nuclear@0 357
nuclear@0 358 LastHSWTime = lastTime;
nuclear@0 359 return lastTime;
nuclear@0 360 }
nuclear@0 361 }
nuclear@0 362
nuclear@0 363 return HSWDisplayTimeNever;
nuclear@0 364 }
nuclear@0 365
nuclear@0 366 void HSWDisplay::SetCurrentProfileLastHSWTime(time_t t)
nuclear@0 367 {
nuclear@0 368 // The timeout value is stored in HMDState's pProfile.
nuclear@0 369 HMDState* pHMDState = (HMDState*)HMD->Handle;
nuclear@0 370
nuclear@0 371 if (pHMDState)
nuclear@0 372 {
nuclear@0 373 const char* profileName = pHMDState->pProfile ? pHMDState->pProfile->GetValue(OVR_KEY_USER) : NULL;
nuclear@0 374
nuclear@0 375 if (profileName)
nuclear@0 376 {
nuclear@0 377 LastProfileName = profileName;
nuclear@0 378 LastHSWTime = (int)t;
nuclear@0 379
nuclear@0 380 String timeKey = getHSWTimeKey(profileName);
nuclear@0 381 pHMDState->setIntValue(timeKey.ToCStr(), (int)t);
nuclear@0 382 }
nuclear@0 383 }
nuclear@0 384 }
nuclear@0 385
nuclear@0 386
nuclear@0 387 // Generates an appropriate stereo ortho projection matrix.
nuclear@0 388 void HSWDisplay::GetOrthoProjection(const HMDRenderState& RenderState, Matrix4f OrthoProjection[2])
nuclear@0 389 {
nuclear@0 390 Matrix4f perspectiveProjection[2];
nuclear@0 391 perspectiveProjection[0] = ovrMatrix4f_Projection(RenderState.EyeRenderDesc[0].Fov, 0.01f, 10000.f, true);
nuclear@0 392 perspectiveProjection[1] = ovrMatrix4f_Projection(RenderState.EyeRenderDesc[1].Fov, 0.01f, 10000.f, true);
nuclear@0 393
nuclear@0 394 const float orthoDistance = HSWDISPLAY_DISTANCE; // This is meters from the camera (viewer) that we place the ortho plane.
nuclear@0 395 const Vector2f orthoScale0 = Vector2f(1.f) / Vector2f(RenderState.EyeRenderDesc[0].PixelsPerTanAngleAtCenter);
nuclear@0 396 const Vector2f orthoScale1 = Vector2f(1.f) / Vector2f(RenderState.EyeRenderDesc[1].PixelsPerTanAngleAtCenter);
nuclear@0 397
nuclear@0 398 OrthoProjection[0] = ovrMatrix4f_OrthoSubProjection(perspectiveProjection[0], orthoScale0, orthoDistance, RenderState.EyeRenderDesc[0].HmdToEyeViewOffset.x);
nuclear@0 399 OrthoProjection[1] = ovrMatrix4f_OrthoSubProjection(perspectiveProjection[1], orthoScale1, orthoDistance, RenderState.EyeRenderDesc[1].HmdToEyeViewOffset.x);
nuclear@0 400 }
nuclear@0 401
nuclear@0 402
nuclear@0 403 const uint8_t* HSWDisplay::GetDefaultTexture(size_t& TextureSize)
nuclear@0 404 {
nuclear@0 405 TextureSize = sizeof(healthAndSafety_tga);
nuclear@0 406 return healthAndSafety_tga;
nuclear@0 407 }
nuclear@0 408
nuclear@0 409
nuclear@0 410
nuclear@0 411 }} // namespace OVR::CAPI
nuclear@0 412
nuclear@0 413
nuclear@0 414
nuclear@0 415
nuclear@0 416 //-------------------------------------------------------------------------------------
nuclear@0 417 // ***** HSWDisplay factory
nuclear@0 418 //
nuclear@0 419
nuclear@0 420 #if defined (OVR_OS_WIN32)
nuclear@0 421 #define OVR_D3D_VERSION 9
nuclear@0 422 #include "D3D9/CAPI_D3D9_HSWDisplay.h"
nuclear@0 423 #undef OVR_D3D_VERSION
nuclear@0 424
nuclear@0 425 #define OVR_D3D_VERSION 10
nuclear@0 426 #include "D3D1X/CAPI_D3D10_HSWDisplay.h"
nuclear@0 427 #undef OVR_D3D_VERSION
nuclear@0 428
nuclear@0 429 #define OVR_D3D_VERSION 11
nuclear@0 430 #include "D3D1X/CAPI_D3D11_HSWDisplay.h"
nuclear@0 431 #undef OVR_D3D_VERSION
nuclear@0 432 #endif
nuclear@0 433
nuclear@0 434 #include "GL/CAPI_GL_HSWDisplay.h"
nuclear@0 435
nuclear@0 436
nuclear@0 437 OVR::CAPI::HSWDisplay* OVR::CAPI::HSWDisplay::Factory(ovrRenderAPIType apiType, ovrHmd hmd, const OVR::CAPI::HMDRenderState& renderState)
nuclear@0 438 {
nuclear@0 439 OVR::CAPI::HSWDisplay* pHSWDisplay = NULL;
nuclear@0 440
nuclear@0 441 switch (apiType)
nuclear@0 442 {
nuclear@0 443 case ovrRenderAPI_None:
nuclear@0 444 pHSWDisplay = new OVR::CAPI::HSWDisplay(apiType, hmd, renderState);
nuclear@0 445 break;
nuclear@0 446
nuclear@0 447 case ovrRenderAPI_OpenGL:
nuclear@0 448 pHSWDisplay = new OVR::CAPI::GL::HSWDisplay(apiType, hmd, renderState);
nuclear@0 449 break;
nuclear@0 450
nuclear@0 451 #if defined(OVR_OS_WIN32)
nuclear@0 452 case ovrRenderAPI_D3D9:
nuclear@0 453 pHSWDisplay = new OVR::CAPI::D3D9::HSWDisplay(apiType, hmd, renderState);
nuclear@0 454 break;
nuclear@0 455
nuclear@0 456 case ovrRenderAPI_D3D10:
nuclear@0 457 pHSWDisplay = new OVR::CAPI::D3D10::HSWDisplay(apiType, hmd, renderState);
nuclear@0 458 break;
nuclear@0 459
nuclear@0 460 case ovrRenderAPI_D3D11:
nuclear@0 461 pHSWDisplay = new OVR::CAPI::D3D11::HSWDisplay(apiType, hmd, renderState);
nuclear@0 462 break;
nuclear@0 463 #else
nuclear@0 464 case ovrRenderAPI_D3D9:
nuclear@0 465 case ovrRenderAPI_D3D10:
nuclear@0 466 case ovrRenderAPI_D3D11: // Fall through
nuclear@0 467 #endif
nuclear@0 468
nuclear@0 469 // Handle unsupported cases.
nuclear@0 470 case ovrRenderAPI_Android_GLES:
nuclear@0 471 case ovrRenderAPI_Count: // This is not actually a type.
nuclear@0 472 default:
nuclear@0 473 break;
nuclear@0 474 }
nuclear@0 475
nuclear@0 476 return pHSWDisplay;
nuclear@0 477 }
nuclear@0 478
nuclear@0 479
nuclear@0 480
nuclear@0 481
nuclear@0 482