Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
OVR_CAPI.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 Filename : OVR_CAPI.h
4 Content : C Interface to Oculus sensors and rendering.
5 Created : November 23, 2013
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 #ifndef OVR_CAPI_h
27 #define OVR_CAPI_h
28 
29 #include <stdint.h>
30 
31 typedef char ovrBool;
32 
33 //-----------------------------------------------------------------------------------
34 // ***** OVR_EXPORT definition
35 
36 #if !defined(OVR_EXPORT)
37  #if defined(WIN32)
38  #define OVR_EXPORT __declspec(dllexport)
39  #else
40  #define OVR_EXPORT
41  #endif
42 #endif
43 
44 //-----------------------------------------------------------------------------------
45 // ***** Simple Math Structures
46 
47 // 2D integer
48 typedef struct ovrVector2i_
49 {
50  int x, y;
51 } ovrVector2i;
52 typedef struct ovrSizei_
53 {
54  int w, h;
55 } ovrSizei;
56 typedef struct ovrRecti_
57 {
60 } ovrRecti;
61 
62 // 3D
63 typedef struct ovrQuatf_
64 {
65  float x, y, z, w;
66 } ovrQuatf;
67 typedef struct ovrVector2f_
68 {
69  float x, y;
70 } ovrVector2f;
71 typedef struct ovrVector3f_
72 {
73  float x, y, z;
74 } ovrVector3f;
75 typedef struct ovrMatrix4f_
76 {
77  float M[4][4];
78 } ovrMatrix4f;
79 // Position and orientation together.
80 typedef struct ovrPosef_
81 {
84 } ovrPosef;
85 
86 // Full pose (rigid body) configuration with first and second derivatives.
87 typedef struct ovrPoseStatef_
88 {
94  double TimeInSeconds; // Absolute time of this state sample.
96 
97 // Field Of View (FOV) in tangent of the angle units.
98 // As an example, for a standard 90 degree vertical FOV, we would
99 // have: { UpTan = tan(90 degrees / 2), DownTan = tan(90 degrees / 2) }.
100 typedef struct ovrFovPort_
101 {
102  float UpTan;
103  float DownTan;
104  float LeftTan;
105  float RightTan;
106 } ovrFovPort;
107 
108 
109 //-----------------------------------------------------------------------------------
110 // ***** HMD Types
111 
112 // Enumerates all HMD types that we support.
113 typedef enum
114 {
120  ovrHmd_Other // Some HMD other then the one in the enumeration.
121 } ovrHmdType;
122 
123 // HMD capability bits reported by device.
124 //
125 typedef enum
126 {
127  // Read-only flags.
128  ovrHmdCap_Present = 0x0001, // This HMD exists (as opposed to being unplugged).
129  ovrHmdCap_Available = 0x0002, // HMD and is sensor is available for use
130  // (if not owned by another app).
131 
132  // These flags are intended for use with the new driver display mode.
133  /*
134  ovrHmdCap_ExtendDesktop = 0x0004, // Read only, means display driver is in compatibility mode.
135 
136  ovrHmdCap_DisplayOff = 0x0040, // Turns off Oculus HMD screen and output.
137  ovrHmdCap_NoMirrorToWindow = 0x2000, // Disables mirrowing of HMD output to the window;
138  // may improve rendering performance slightly.
139  */
140 
141  // Modifiable flags (through ovrHmd_SetEnabledCaps).
142  ovrHmdCap_LowPersistence = 0x0080, // Supports low persistence mode.
143  ovrHmdCap_LatencyTest = 0x0100, // Supports pixel reading for continuous latency testing.
144  ovrHmdCap_DynamicPrediction = 0x0200, // Adjust prediction dynamically based on DK2 Latency.
145  // Support rendering without VSync for debugging
148 
149  // These bits can be modified by ovrHmd_SetEnabledCaps.
151 } ovrHmdCaps;
152 
153 
154 // Sensor capability bits reported by device.
155 // Used with ovrHmd_StartSensor.
156 typedef enum
157 {
158  ovrSensorCap_Orientation = 0x0010, // Supports orientation tracking (IMU).
159  ovrSensorCap_YawCorrection = 0x0020, // Supports yaw correction through magnetometer or other means.
160  ovrSensorCap_Position = 0x0040, // Supports positional tracking.
161 
162 } ovrSensorCaps;
163 
164 // Distortion capability bits reported by device.
165 // Used with ovrHmd_ConfigureRendering and ovrHmd_CreateDistortionMesh.
166 typedef enum
167 {
168  ovrDistortionCap_Chromatic = 0x01, // Supports chromatic aberration correction.
169  ovrDistortionCap_TimeWarp = 0x02, // Supports timewarp.
170  ovrDistortionCap_Vignette = 0x08 // Supports vignetting around the edges of the view.
172 
173 
174 // Specifies which eye is being used for rendering.
175 // This type explicitly does not include a third "NoStereo" option, as such is
176 // not required for an HMD-centered API.
177 typedef enum
178 {
182 } ovrEyeType;
183 
184 
185 // Handle to HMD; returned by ovrHmd_Create.
186 typedef struct ovrHmdStruct* ovrHmd;
187 
188 // This is a complete descriptor of the HMD.
189 typedef struct ovrHmdDesc_
190 {
191  ovrHmd Handle; // Handle of this HMD.
193 
194  // Name string describing the product: "Oculus Rift DK1", etc.
195  const char* ProductName;
196  const char* Manufacturer;
197 
198  // Capability bits described by ovrHmdCaps.
199  unsigned int HmdCaps;
200  // Capability bits described by ovrSensorCaps.
201  unsigned int SensorCaps;
202  // Capability bits described by ovrDistortionCaps.
203  unsigned int DistortionCaps;
204 
205  // Resolution of the entire HMD screen (for both eyes) in pixels.
207  // Where monitor window should be on screen or (0,0).
209 
210  // These define the recommended and maximum optical FOVs for the HMD.
213 
214  // Preferred eye rendering order for best performance.
215  // Can help reduce latency on sideways-scanned screens.
217 
218  // Display that HMD should present on.
219  // TBD: It may be good to remove this information relying on WidowPos instead.
220  // Ultimately, we may need to come up with a more convenient alternative,
221  // such as a API-specific functions that return adapter, ot something that will
222  // work with our monitor driver.
223 
224  // Windows: "\\\\.\\DISPLAY3", etc. Can be used in EnumDisplaySettings/CreateDC.
225  const char* DisplayDeviceName;
226  // MacOS
228 } ovrHmdDesc;
229 
230 // Describes the type of positional tracking being done.
231 /*
232 typedef enum
233 {
234  ovrPose_None,
235  ovrPose_HeadModel,
236  ovrPose_Positional
237 } ovrPoseType;
238 */
239 
240 
241 // Bit flags describing the current status of sensor tracking.
242 typedef enum
243 {
244  ovrStatus_OrientationTracked = 0x0001, // Orientation is currently tracked (connected and in use).
245  ovrStatus_PositionTracked = 0x0002, // Position is currently tracked (FALSE if out of range).
246  ovrStatus_PositionConnected = 0x0020, // Position tracking HW is connected.
247  ovrStatus_HmdConnected = 0x0080 // HMD Display is available & connected.
248 } ovrStatusBits;
249 
250 
251 // State of the sensor at a given absolute time.
252 typedef struct ovrSensorState_
253 {
254  // Predicted pose configuration at requested absolute time.
255  // One can determine the time difference between predicted and actual
256  // readings by comparing ovrPoseState.TimeInSeconds.
258  // Actual recorded pose configuration based on the sensor sample at a
259  // moment closest to the requested time.
261 
262  // Sensor temperature reading, in degrees Celsius, as sample time.
263  float Temperature;
264  // Sensor status described by ovrStatusBits.
265  unsigned int StatusFlags;
267 
268 // For now.
269 // TBD: Decide if this becomes a part of HMDDesc
270 typedef struct ovrSensorDesc_
271 {
272  // HID Vendor and ProductId of the device.
273  short VendorId;
274  short ProductId;
275  // Sensor (and display) serial number.
276  char SerialNumber[24];
277 } ovrSensorDesc;
278 
279 
280 
281 // Frame data reported by ovrHmd_BeginFrameTiming().
282 typedef struct ovrFrameTiming_
283 {
284  // The amount of time that has passed since the previous frame returned
285  // BeginFrameSeconds value, usable for movement scaling.
286  // This will be clamped to no more than 0.1 seconds to prevent
287  // excessive movement after pauses for loading or initialization.
289 
290  // It is generally expected that the following hold:
291  // ThisFrameSeconds < TimewarpPointSeconds < NextFrameSeconds <
292  // EyeScanoutSeconds[EyeOrder[0]] <= ScanoutMidpointSeconds <= EyeScanoutSeconds[EyeOrder[1]]
293 
294  // Absolute time value of when rendering of this frame began or is expected to
295  // begin; generally equal to NextFrameSeconds of the previous frame. Can be used
296  // for animation timing.
298  // Absolute point when IMU expects to be sampled for this frame.
300  // Absolute time when frame Present + GPU Flush will finish, and the next frame starts.
302 
303  // Time when when half of the screen will be scanned out. Can be passes as a prediction
304  // value to ovrHmd_GetSensorState() go get general orientation.
306  // Timing points when each eye will be scanned out to display. Used for rendering each eye.
307  double EyeScanoutSeconds[2];
308 
310 
311 
312 
313 // Rendering information for each eye, computed by either ovrHmd_ConfigureRendering().
314 // or ovrHmd_GetRenderDesc() based on the specified Fov.
315 // Note that the rendering viewport is not included here as it can be
316 // specified separately and modified per frame though:
317 // (a) calling ovrHmd_GetRenderScaleAndOffset with game-rendered api,
318 // or (b) passing different values in ovrTexture in case of SDK-rendered distortion.
319 typedef struct ovrEyeRenderDesc_
320 {
323  ovrRecti DistortedViewport; // Distortion viewport
324  ovrVector2f PixelsPerTanAngleAtCenter; // How many display pixels will fit in tan(angle) = 1.
325  ovrVector3f ViewAdjust; // Translation to be applied to view matrix.
327 
328 
329 //-----------------------------------------------------------------------------------
330 // ***** Platform-independent Rendering Configuration
331 
332 // These types are used to hide platform-specific details when passing
333 // render device, OS and texture data to the APIs.
334 //
335 // The benefit of having these wrappers vs. platform-specific API functions is
336 // that they allow game glue code to be portable. A typical example is an
337 // engine that has multiple back ends, say GL and D3D. Portable code that calls
338 // these back ends may also use LibOVR. To do this, back ends can be modified
339 // to return portable types such as ovrTexture and ovrRenderAPIConfig.
340 
341 typedef enum
342 {
345  ovrRenderAPI_Android_GLES, // May include extra native window pointers, etc.
351 
352 // Platform-independent part of rendering API-configuration data.
353 // It is a part of ovrRenderAPIConfig, passed to ovrHmd_Configure.
355 {
360 
361 typedef struct ovrRenderAPIConfig_
362 {
364  uintptr_t PlatformData[8];
366 
367 // Platform-independent part of eye texture descriptor.
368 // It is a part of ovrTexture, passed to ovrHmd_EndFrame.
369 // - If RenderViewport is all zeros, will be used.
370 typedef struct ovrTextureHeader_
371 {
374  ovrRecti RenderViewport; // Pixel viewport in texture that holds eye image.
376 
377 typedef struct ovrTexture_
378 {
380  uintptr_t PlatformData[8];
381 } ovrTexture;
382 
383 
384 // -----------------------------------------------------------------------------------
385 // ***** API Interfaces
386 
387 // Basic steps to use the API:
388 //
389 // Setup:
390 // 1. ovrInitialize();
391 // 2. ovrHMD hmd = ovrHmd_Create(0); ovrHmd_GetDesc(hmd, &hmdDesc);
392 // 3. Use hmdDesc and ovrHmd_GetFovTextureSize() to determine graphics configuration.
393 // 4. Call ovrHmd_StartSensor() to configure and initialize tracking.
394 // 5. Call ovrHmd_ConfigureRendering() to setup graphics for SDK rendering,
395 // which is the preferred approach.
396 // Please refer to "Game-Side Rendering" below if you prefer to do that instead.
397 // 5. Allocate textures as needed.
398 //
399 // Game Loop:
400 // 6. Call ovrHmd_BeginFrame() to get frame timing and orientation information.
401 // 7. Render each eye in between ovrHmd_BeginEyeRender and ovrHmd_EndEyeRender calls,
402 // providing the result texture to the API.
403 // 8. Call ovrHmd_EndFrame() to render distorted textures to the back buffer
404 // and present them on the Hmd.
405 //
406 // Shutdown:
407 // 9. ovrHmd_Destroy(hmd)
408 // 10. ovr_Shutdown()
409 //
410 
411 #ifdef __cplusplus
412 extern "C" {
413 #endif
414 
415 // Library init/shutdown, must be called around all other OVR code.
416 // No other functions calls are allowed before ovr_Initialize succeeds or after ovr_Shutdown.
418 OVR_EXPORT void ovr_Shutdown();
419 
420 
421 // Detects or re-detects HMDs and reports the total number detected.
422 // Users can get information about each HMD by calling ovrHmd_Create with an index.
424 
425 
426 // Creates a handle to an HMD and optionally fills in data about it.
427 // Index can [0 .. ovrHmd_Detect()-1]; index mappings can cange after each ovrHmd_Detect call.
428 // If not null, returned handle must be freed with ovrHmd_Destroy.
429 OVR_EXPORT ovrHmd ovrHmd_Create(int index);
430 OVR_EXPORT void ovrHmd_Destroy(ovrHmd hmd);
431 
432 // Creates a "fake" HMD used for debugging only. This is not tied to specific hardware,
433 // but may be used to debug some of the related rendering.
435 
436 
437 // Returns last error for HMD state. Returns null for no error.
438 // String is valid until next call or GetLastError or HMD is destroyed.
439 // Pass null hmd to get global error (for create, etc).
440 OVR_EXPORT const char* ovrHmd_GetLastError(ovrHmd hmd);
441 
442 
443 //-------------------------------------------------------------------------------------
444 
445 // Returns capability bits that are enabled at this time; described by ovrHmdCaps.
446 // Note that this value is different font ovrHmdDesc::HmdCaps, which describes what
447 // capabilities are available.
448 OVR_EXPORT unsigned int ovrHmd_GetEnabledCaps(ovrHmd hmd);
449 
450 // Modifies capability bits described by ovrHmdCaps that can be modified,
451 // such as ovrHmd_LowPersistance.
452 OVR_EXPORT void ovrHmd_SetEnabledCaps(ovrHmd hmd, unsigned int hmdCaps);
453 
454 
455 //-------------------------------------------------------------------------------------
456 // ***** Sensor Interface
457 
458 // All sensor interface functions are thread-safe, allowing sensor state to be sampled
459 // from different threads.
460 // Starts sensor sampling, enabling specified capabilities, described by ovrSensorCaps.
461 // - supportedSensorCaps specifies support that is requested. The function will succeed
462 // even if these caps are not available (i.e. sensor or camera is unplugged). Support
463 // will automatically be enabled if such device is plugged in later. Software should
464 // check ovrSensorState.StatusFlags for real-time status.
465 // - requiredSensorCaps specify sensor capabilities required at the time of the call.
466 // If they are not available, the function will fail. Pass 0 if only specifying
467 // supportedSensorCaps.
468 OVR_EXPORT ovrBool ovrHmd_StartSensor(ovrHmd hmd, unsigned int supportedSensorCaps,
469  unsigned int requiredSensorCaps);
470 // Stops sensor sampling, shutting down internal resources.
471 OVR_EXPORT void ovrHmd_StopSensor(ovrHmd hmd);
472 // Resets sensor orientation.
473 OVR_EXPORT void ovrHmd_ResetSensor(ovrHmd hmd);
474 
475 // Returns sensor state reading based on the specified absolute system time.
476 // Pass absTime value of 0.0 to request the most recent sensor reading; in this case
477 // both PredictedPose and SamplePose will have the same value.
478 // ovrHmd_GetEyePredictedSensorState relies on this internally.
479 // This may also be used for more refined timing of FrontBuffer rendering logic, etc.
480 OVR_EXPORT ovrSensorState ovrHmd_GetSensorState(ovrHmd hmd, double absTime);
481 
482 // Returns information about a sensor.
483 // Only valid after StartSensor.
485 
486 
487 //-------------------------------------------------------------------------------------
488 // ***** Graphics Setup
489 
490 // Fills in description about HMD; this is the same as filled in by ovrHmd_Create.
491 OVR_EXPORT void ovrHmd_GetDesc(ovrHmd hmd, ovrHmdDesc* desc);
492 
493 // Calculates texture size recommended for rendering one eye within HMD, given FOV cone.
494 // Higher FOV will generally require larger textures to maintain quality.
495 // - pixelsPerDisplayPixel specifies that number of render target pixels per display
496 // pixel at center of distortion; 1.0 is the default value. Lower values
497 // can improve performance.
499  float pixelsPerDisplayPixel);
500 
501 
502 
503 //-------------------------------------------------------------------------------------
504 // ***** Rendering API Thread Safety
505 
506 // All of rendering APIs, inclusing Configure and frame functions are *NOT
507 // Thread Safe*. It is ok to use ConfigureRendering on one thread and handle
508 // frames on another thread, but explicit synchronization must be done since
509 // functions that depend on configured state are not reentrant.
510 //
511 // As an extra requirement, any of the following calls must be done on
512 // the render thread, which is the same thread that calls ovrHmd_BeginFrame
513 // or ovrHmd_BeginFrameTiming.
514 // - ovrHmd_EndFrame
515 // - ovrHmd_BeginEyeRender
516 // - ovrHmd_EndEyeRender
517 // - ovrHmd_GetFramePointTime
518 // - ovrHmd_GetEyePose
519 // - ovrHmd_GetEyeTimewarpMatrices
520 
521 
522 //-------------------------------------------------------------------------------------
523 // ***** SDK-Rendering Functions
524 
525 // These functions support rendering of distortion by the SDK through direct
526 // access to the underlying rendering HW, such as D3D or GL.
527 // This is the recommended approach, as it allows for better support or future
528 // Oculus hardware and a range of low-level optimizations.
529 
530 
531 // Configures rendering; fills in computed render parameters.
532 // This function can be called multiple times to change rendering settings.
533 // The users pass in two eye view descriptors that are used to
534 // generate complete rendering information for each eye in eyeRenderDescOut[2].
535 //
536 // - apiConfig provides D3D/OpenGL specific parameters. Pass null
537 // to shutdown rendering and release all resources.
538 // - distortionCaps describe distortion settings that will be applied.
539 //
541  const ovrRenderAPIConfig* apiConfig,
542  unsigned int distortionCaps,
543  const ovrFovPort eyeFovIn[2],
544  ovrEyeRenderDesc eyeRenderDescOut[2] );
545 
546 
547 // Begins a frame, returning timing and orientation information useful for simulation.
548 // This should be called in the beginning of game rendering loop (on render thread).
549 // This function relies on ovrHmd_BeginFrameTiming for some of its functionality.
550 // Pass 0 for frame index if not using GetFrameTiming.
551 OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrame(ovrHmd hmd, unsigned int frameIndex);
552 
553 // Ends frame, rendering textures to frame buffer. This may perform distortion and scaling
554 // internally, assuming is it not delegated to another thread.
555 // Must be called on the same thread as BeginFrame. Calls ovrHmd_BeginEndTiming internally.
556 // *** This Function will to Present/SwapBuffers and potentially wait for GPU Sync ***.
557 OVR_EXPORT void ovrHmd_EndFrame(ovrHmd hmd);
558 
559 
560 // Marks beginning of eye rendering. Must be called on the same thread as BeginFrame.
561 // This function uses ovrHmd_GetEyePose to predict sensor state that should be
562 // used rendering the specified eye.
563 // This combines current absolute time with prediction that is appropriate for this HMD.
564 // It is ok to call ovrHmd_BeginEyeRender() on both eyes before calling ovrHmd_EndEyeRender.
565 // If rendering one eye at a time, it is best to render eye specified by
566 // HmdDesc.EyeRenderOrder[0] first.
568 
569 // Marks the end of eye rendering and submits the eye texture for display after it is ready.
570 // Rendering viewport within the texture can change per frame if necessary.
571 // Specified texture may be presented immediately or wait until ovrHmd_EndFrame based
572 // on the implementation. The API performs distortion and scaling internally.
573 // 'renderPose' will typically be the value returned from ovrHmd_BeginEyeRender, but can
574 // be different if a different pose was used for rendering.
575 OVR_EXPORT void ovrHmd_EndEyeRender(ovrHmd hmd, ovrEyeType eye,
576  ovrPosef renderPose, ovrTexture* eyeTexture);
577 
578 
579 
580 //-------------------------------------------------------------------------------------
581 // ***** Game-Side Rendering Functions
582 
583 // These functions provide distortion data and render timing support necessary to allow
584 // game rendering of distortion. Game-side rendering involves the following steps:
585 //
586 // 1. Setup ovrEyeDesc based on desired texture size and Fov.
587 // Call ovrHmd_GetRenderDesc to get the necessary rendering parameters for each eye.
588 //
589 // 2. Use ovrHmd_CreateDistortionMesh to generate distortion mesh.
590 //
591 // 3. Use ovrHmd_BeginFrameTiming, ovrHmd_GetEyePose and ovrHmd_BeginFrameTiming
592 // in the rendering loop to obtain timing and predicted view orientation for
593 // each eye.
594 // - If relying on timewarp, use ovr_WaitTillTime after rendering+flush, followed
595 // by ovrHmd_GetEyeTimewarpMatrices to obtain timewarp matrices used
596 // in distortion pixel shader to reduce latency.
597 //
598 
599 // Computes distortion viewport, view adjust and other rendering for the specified
600 // eye. This can be used instead of ovrHmd_ConfigureRendering to help setup rendering on
601 // the game side.
603  ovrEyeType eyeType, ovrFovPort fov);
604 
605 
606 // Describes a vertex used for distortion; this is intended to be converted into
607 // the engine-specific format.
608 // Some fields may be unused based on ovrDistortionCaps selected. TexG and TexB, for example,
609 // are not used if chromatic correction is not requested.
610 typedef struct ovrDistortionVertex_
611 {
613  float TimeWarpFactor; // Lerp factor between time-warp matrices. Can be encoded in Pos.z.
614  float VignetteFactor; // Vignette fade factor. Can be encoded in Pos.w.
619 
620 // Describes a full set of distortion mesh data, filled in by ovrHmd_CreateDistortionMesh.
621 // Contents of this data structure, if not null, should be freed by ovrHmd_DestroyDistortionMesh.
622 typedef struct ovrDistortionMesh_
623 {
625  unsigned short* pIndexData;
626  unsigned int VertexCount;
627  unsigned int IndexCount;
629 
630 // Generate distortion mesh per eye.
631 // Distortion capabilities will depend on 'distortionCaps' flags; user should rely on
632 // appropriate shaders based on their settings.
633 // Distortion mesh data will be allocated and stored into the ovrDistortionMesh data structure,
634 // which should be explicitly freed with ovrHmd_DestroyDistortionMesh.
635 // Users should call ovrHmd_GetRenderScaleAndOffset to get uvScale and Offset values for rendering.
636 // The function shouldn't fail unless theres is a configuration or memory error, in which case
637 // ovrDistortionMesh values will be set to null.
639  ovrEyeType eyeType, ovrFovPort fov,
640  unsigned int distortionCaps,
641  ovrDistortionMesh *meshData );
642 
643 // Frees distortion mesh allocated by ovrHmd_GenerateDistortionMesh. meshData elements
644 // are set to null and zeroes after the call.
646 
647 // Computes updated 'uvScaleOffsetOut' to be used with a distortion if render target size or
648 // viewport changes after the fact. This can be used to adjust render size every frame, if desired.
650  ovrSizei textureSize, ovrRecti renderViewport,
651  ovrVector2f uvScaleOffsetOut[2] );
652 
653 
654 // Thread-safe timing function for the main thread. Caller should increment frameIndex
655 // with every frame and pass the index to RenderThread for processing.
656 OVR_EXPORT ovrFrameTiming ovrHmd_GetFrameTiming(ovrHmd hmd, unsigned int frameIndex);
657 
658 // Called at the beginning of the frame on the Render Thread.
659 // Pass frameIndex == 0 if ovrHmd_GetFrameTiming isn't being used. Otherwise,
660 // pass the same frame index as was used for GetFrameTiming on the main thread.
661 OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrameTiming(ovrHmd hmd, unsigned int frameIndex);
662 
663 // Marks the end of game-rendered frame, tracking the necessary timing information. This
664 // function must be called immediately after Present/SwapBuffers + GPU sync. GPU sync is important
665 // before this call to reduce latency and ensure proper timing.
666 OVR_EXPORT void ovrHmd_EndFrameTiming(ovrHmd hmd);
667 
668 // Initializes and resets frame time tracking. This is typically not necessary, but
669 // is helpful if game changes vsync state or video mode. vsync is assumed to be on if this
670 // isn't called. Resets internal frame index to the specified number.
671 OVR_EXPORT void ovrHmd_ResetFrameTiming(ovrHmd hmd, unsigned int frameIndex);
672 
673 
674 // Predicts and returns Pose that should be used rendering the specified eye.
675 // Must be called between ovrHmd_BeginFrameTiming & ovrHmd_EndFrameTiming.
677 
678 // Computes timewarp matrices used by distortion mesh shader, these are used to adjust
679 // for orientation change since the last call to ovrHmd_GetEyePose for this eye.
680 // The ovrDistortionVertex::TimeWarpFactor is used to blend between the matrices,
681 // usually representing two different sides of the screen.
682 // Must be called on the same thread as ovrHmd_BeginFrameTiming.
684  ovrPosef renderPose, ovrMatrix4f twmOut[2]);
685 
686 
687 
688 //-------------------------------------------------------------------------------------
689 // ***** Stateless math setup functions
690 
691 // Used to generate projection from ovrEyeDesc::Fov.
693  float znear, float zfar, ovrBool rightHanded );
694 
695 // Used for 2D rendering, Y is down
696 // orthoScale = 1.0f / pixelsPerTanAngleAtCenter
697 // orthoDistance = distance from camera, such as 0.8m
699  float orthoDistance, float eyeViewAdjustX);
700 
701 // Returns global, absolute high-resolution time in seconds. This is the same
702 // value as used in sensor messages.
704 
705 // Waits until the specified absolute time.
706 OVR_EXPORT double ovr_WaitTillTime(double absTime);
707 
708 
709 
710 // -----------------------------------------------------------------------------------
711 // ***** Latency Test interface
712 
713 // Does latency test processing and returns 'TRUE' if specified rgb color should
714 // be used to clear the screen.
715 OVR_EXPORT ovrBool ovrHmd_ProcessLatencyTest(ovrHmd hmd, unsigned char rgbColorOut[3]);
716 
717 // Returns non-null string once with latency test result, when it is available.
718 // Buffer is valid until next call.
719 OVR_EXPORT const char* ovrHmd_GetLatencyTestResult(ovrHmd hmd);
720 
721 // Returns latency for HMDs that support internal latency testing via the
722 // pixel-read back method (-1 for invalid or N/A)
723 OVR_EXPORT double ovrHmd_GetMeasuredLatencyTest2(ovrHmd hmd);
724 
725 
726 // -----------------------------------------------------------------------------------
727 // ***** Property Access
728 
729 // NOTICE: This is experimental part of API that is likely to go away or change.
730 
731 // These allow accessing different properties of the HMD and profile.
732 // Some of the properties may go away with profile/HMD versions, so software should
733 // use defaults and/or proper fallbacks.
734 //
735 
736 // For now, access profile entries; this will change.
737 #if !defined(OVR_KEY_USER)
738 
739  #define OVR_KEY_USER "User"
740  #define OVR_KEY_NAME "Name"
741  #define OVR_KEY_GENDER "Gender"
742  #define OVR_KEY_PLAYER_HEIGHT "PlayerHeight"
743  #define OVR_KEY_EYE_HEIGHT "EyeHeight"
744  #define OVR_KEY_IPD "IPD"
745  #define OVR_KEY_NECK_TO_EYE_HORIZONTAL "NeckEyeHori"
746  #define OVR_KEY_NECK_TO_EYE_VERTICAL "NeckEyeVert"
747 
748  #define OVR_DEFAULT_GENDER "Male"
749  #define OVR_DEFAULT_PLAYER_HEIGHT 1.778f
750  #define OVR_DEFAULT_EYE_HEIGHT 1.675f
751  #define OVR_DEFAULT_IPD 0.064f
752  #define OVR_DEFAULT_NECK_TO_EYE_HORIZONTAL 0.12f
753  #define OVR_DEFAULT_NECK_TO_EYE_VERTICAL 0.12f
754 #endif
755 
756 
757 // Get float property. Returns first element if property is a float array.
758 // Returns defaultValue if property doesn't exist.
759 OVR_EXPORT float ovrHmd_GetFloat(ovrHmd hmd, const char* propertyName, float defaultVal);
760 
761 // Modify float property; false if property doesn't exist or is readonly.
762 OVR_EXPORT ovrBool ovrHmd_SetFloat(ovrHmd hmd, const char* propertyName, float value);
763 
764 
765 // Get float[] property. Returns the number of elements filled in, 0 if property doesn't exist.
766 // Maximum of arraySize elements will be written.
767 OVR_EXPORT unsigned int ovrHmd_GetFloatArray(ovrHmd hmd, const char* propertyName,
768  float values[], unsigned int arraySize);
769 
770 // Modify float[] property; false if property doesn't exist or is readonly.
771 OVR_EXPORT ovrBool ovrHmd_SetFloatArray(ovrHmd hmd, const char* propertyName,
772  float values[], unsigned int arraySize);
773 
774 // Get string property. Returns first element if property is a string array.
775 // Returns defaultValue if property doesn't exist.
776 // String memory is guaranteed to exist until next call to GetString or GetStringArray, or HMD is destroyed.
777 OVR_EXPORT const char* ovrHmd_GetString(ovrHmd hmd, const char* propertyName,
778  const char* defaultVal);
779 
780 // Returns array size of a property, 0 if property doesn't exist.
781 // Can be used to check existence of a property.
782 OVR_EXPORT unsigned int ovrHmd_GetArraySize(ovrHmd hmd, const char* propertyName);
783 
784 
785 #ifdef __cplusplus
786 } // extern "C"
787 #endif
788 
789 
790 #endif // OVR_CAPI_h
float UpTan
Definition: OVR_CAPI.h:102
struct ovrPosef_ ovrPosef
float z
Definition: OVR_CAPI.h:73
ovrRecti DistortedViewport
Definition: OVR_CAPI.h:323
OVR_EXPORT void ovrHmd_ResetFrameTiming(ovrHmd hmd, unsigned int frameIndex)
Definition: OVR_CAPI.cpp:607
ovrVector3f Position
Definition: OVR_CAPI.h:83
OVR_EXPORT ovrPosef ovrHmd_BeginEyeRender(ovrHmd hmd, ovrEyeType eye)
Definition: OVR_CAPI.cpp:509
ovrEyeType Eye
Definition: OVR_CAPI.h:321
ovrHmdType
Definition: OVR_CAPI.h:113
ovrPoseStatef Predicted
Definition: OVR_CAPI.h:257
OVR_EXPORT ovrFrameTiming ovrHmd_GetFrameTiming(ovrHmd hmd, unsigned int frameIndex)
Definition: OVR_CAPI.cpp:529
float M[4][4]
Definition: OVR_CAPI.h:77
double NextFrameSeconds
Definition: OVR_CAPI.h:301
float x
Definition: OVR_CAPI.h:73
OVR_EXPORT int ovrHmd_Detect()
Definition: OVR_CAPI.cpp:255
struct ovrSensorState_ ovrSensorState
ovrRenderAPIType API
Definition: OVR_CAPI.h:356
OVR_EXPORT ovrEyeRenderDesc ovrHmd_GetRenderDesc(ovrHmd hmd, ovrEyeType eyeType, ovrFovPort fov)
Definition: OVR_CAPI.cpp:656
ovrEyeType EyeRenderOrder[ovrEye_Count]
Definition: OVR_CAPI.h:216
int h
Definition: OVR_CAPI.h:54
OVR_EXPORT ovrBool ovrHmd_ConfigureRendering(ovrHmd hmd, const ovrRenderAPIConfig *apiConfig, unsigned int distortionCaps, const ovrFovPort eyeFovIn[2], ovrEyeRenderDesc eyeRenderDescOut[2])
Definition: OVR_CAPI.cpp:418
OVR_EXPORT unsigned int ovrHmd_GetEnabledCaps(ovrHmd hmd)
Definition: OVR_CAPI.cpp:327
OVR_EXPORT ovrBool ovrHmd_StartSensor(ovrHmd hmd, unsigned int supportedSensorCaps, unsigned int requiredSensorCaps)
Definition: OVR_CAPI.cpp:358
short VendorId
Definition: OVR_CAPI.h:273
ovrVector3f AngularAcceleration
Definition: OVR_CAPI.h:92
struct ovrVector3f_ ovrVector3f
ovrFovPort Fov
Definition: OVR_CAPI.h:322
struct ovrTexture_ ovrTexture
ovrVector2f TexG
Definition: OVR_CAPI.h:616
float y
Definition: OVR_CAPI.h:69
OVR_EXPORT void ovr_Shutdown()
Definition: OVR_CAPI.cpp:228
unsigned int VertexCount
Definition: OVR_CAPI.h:626
ovrHmdCaps
Definition: OVR_CAPI.h:125
float w
Definition: OVR_CAPI.h:65
unsigned int StatusFlags
Definition: OVR_CAPI.h:265
struct ovrVector2f_ ovrVector2f
ovrHmd Handle
Definition: OVR_CAPI.h:191
ovrVector2i WindowsPos
Definition: OVR_CAPI.h:208
OVR_EXPORT ovrMatrix4f ovrMatrix4f_Projection(ovrFovPort fov, float znear, float zfar, ovrBool rightHanded)
Definition: OVR_CAPI.cpp:105
struct ovrSensorDesc_ ovrSensorDesc
OVR_EXPORT ovrPosef ovrHmd_GetEyePose(ovrHmd hmd, ovrEyeType eye)
Definition: OVR_CAPI.cpp:621
OVR_EXPORT void ovrHmd_GetEyeTimewarpMatrices(ovrHmd hmd, ovrEyeType eye, ovrPosef renderPose, ovrMatrix4f twmOut[2])
Definition: OVR_CAPI.cpp:631
unsigned int HmdCaps
Definition: OVR_CAPI.h:199
OVR_EXPORT double ovr_WaitTillTime(double absTime)
Definition: OVR_CAPI.cpp:188
ovrDistortionVertex * pVertexData
Definition: OVR_CAPI.h:624
struct ovrSizei_ ovrSizei
ovrTextureHeader Header
Definition: OVR_CAPI.h:379
OVR_EXPORT void ovrHmd_EndFrame(ovrHmd hmd)
Definition: OVR_CAPI.cpp:463
OVR_EXPORT void ovrHmd_SetEnabledCaps(ovrHmd hmd, unsigned int hmdCaps)
Definition: OVR_CAPI.cpp:335
char SerialNumber[24]
Definition: OVR_CAPI.h:276
OVR_EXPORT void ovrHmd_StopSensor(ovrHmd hmd)
Definition: OVR_CAPI.cpp:365
ovrEyeType
Definition: OVR_CAPI.h:177
double ThisFrameSeconds
Definition: OVR_CAPI.h:297
struct ovrPoseStatef_ ovrPoseStatef
struct ovrVector2i_ ovrVector2i
OVR_EXPORT void ovrHmd_EndFrameTiming(ovrHmd hmd)
Definition: OVR_CAPI.cpp:592
OVR_EXPORT ovrBool ovrHmd_CreateDistortionMesh(ovrHmd hmd, ovrEyeType eyeType, ovrFovPort fov, unsigned int distortionCaps, ovrDistortionMesh *meshData)
Definition: OVR_CAPI.cpp:679
ovrDistortionCaps
Definition: OVR_CAPI.h:166
struct ovrRecti_ ovrRecti
OVR_EXPORT ovrBool ovr_Initialize()
Definition: OVR_CAPI.cpp:211
ovrVector2f TexB
Definition: OVR_CAPI.h:617
float y
Definition: OVR_CAPI.h:65
struct ovrTextureHeader_ ovrTextureHeader
struct ovrHmdStruct * ovrHmd
Definition: OVR_CAPI.h:186
OVR_EXPORT double ovrHmd_GetMeasuredLatencyTest2(ovrHmd hmd)
Definition: OVR_CAPI.cpp:789
double TimewarpPointSeconds
Definition: OVR_CAPI.h:299
OVR_EXPORT void ovrHmd_GetDesc(ovrHmd hmd, ovrHmdDesc *desc)
Definition: OVR_CAPI.cpp:396
double ScanoutMidpointSeconds
Definition: OVR_CAPI.h:305
ovrFovPort MaxEyeFov[ovrEye_Count]
Definition: OVR_CAPI.h:212
float LeftTan
Definition: OVR_CAPI.h:104
ovrHmdType Type
Definition: OVR_CAPI.h:192
char ovrBool
Definition: OVR_CAPI.h:31
struct ovrEyeRenderDesc_ ovrEyeRenderDesc
ovrFovPort DefaultEyeFov[ovrEye_Count]
Definition: OVR_CAPI.h:211
unsigned int IndexCount
Definition: OVR_CAPI.h:627
float x
Definition: OVR_CAPI.h:69
float DownTan
Definition: OVR_CAPI.h:103
ovrSizei Resolution
Definition: OVR_CAPI.h:206
struct ovrRenderAPIConfig_ ovrRenderAPIConfig
uintptr_t PlatformData[8]
Definition: OVR_CAPI.h:380
struct ovrFovPort_ ovrFovPort
OVR_EXPORT const char * ovrHmd_GetLastError(ovrHmd hmd)
Definition: OVR_CAPI.cpp:308
OVR_EXPORT void ovrHmd_ResetSensor(ovrHmd hmd)
Definition: OVR_CAPI.cpp:371
ovrVector3f LinearVelocity
Definition: OVR_CAPI.h:91
ovrSizei Size
Definition: OVR_CAPI.h:59
ovrVector3f ViewAdjust
Definition: OVR_CAPI.h:325
float x
Definition: OVR_CAPI.h:65
OVR_EXPORT void ovrHmd_DestroyDistortionMesh(ovrDistortionMesh *meshData)
Definition: OVR_CAPI.cpp:740
const char * Manufacturer
Definition: OVR_CAPI.h:196
ovrVector2f Pos
Definition: OVR_CAPI.h:612
ovrVector2f TexR
Definition: OVR_CAPI.h:615
OVR_EXPORT ovrBool ovrHmd_GetSensorDesc(ovrHmd hmd, ovrSensorDesc *descOut)
Definition: OVR_CAPI.cpp:384
ovrStatusBits
Definition: OVR_CAPI.h:242
ovrRecti RenderViewport
Definition: OVR_CAPI.h:374
ovrVector2f PixelsPerTanAngleAtCenter
Definition: OVR_CAPI.h:324
ovrVector2i Pos
Definition: OVR_CAPI.h:58
ovrSizei TextureSize
Definition: OVR_CAPI.h:373
OVR_EXPORT ovrSizei ovrHmd_GetFovTextureSize(ovrHmd hmd, ovrEyeType eye, ovrFovPort fov, float pixelsPerDisplayPixel)
Definition: OVR_CAPI.cpp:404
ovrRenderAPIConfigHeader Header
Definition: OVR_CAPI.h:363
OVR_EXPORT ovrBool ovrHmd_SetFloatArray(ovrHmd hmd, const char *propertyName, float values[], unsigned int arraySize)
Definition: OVR_CAPI.cpp:841
OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrameTiming(ovrHmd hmd, unsigned int frameIndex)
Definition: OVR_CAPI.cpp:557
unsigned int DistortionCaps
Definition: OVR_CAPI.h:203
float y
Definition: OVR_CAPI.h:73
uintptr_t PlatformData[8]
Definition: OVR_CAPI.h:364
float RightTan
Definition: OVR_CAPI.h:105
OVR_EXPORT ovrFrameTiming ovrHmd_BeginFrame(ovrHmd hmd, unsigned int frameIndex)
Definition: OVR_CAPI.cpp:440
struct ovrQuatf_ ovrQuatf
struct ovrMatrix4f_ ovrMatrix4f
struct ovrFrameTiming_ ovrFrameTiming
double EyeScanoutSeconds[2]
Definition: OVR_CAPI.h:307
ovrVector3f AngularVelocity
Definition: OVR_CAPI.h:90
OVR_EXPORT void ovrHmd_EndEyeRender(ovrHmd hmd, ovrEyeType eye, ovrPosef renderPose, ovrTexture *eyeTexture)
Definition: OVR_CAPI.cpp:516
OVR_EXPORT ovrHmd ovrHmd_CreateDebug(ovrHmdType type)
Definition: OVR_CAPI.cpp:283
OVR_EXPORT double ovr_GetTimeInSeconds()
Definition: OVR_CAPI.cpp:182
ovrRenderAPIType
Definition: OVR_CAPI.h:341
struct ovrDistortionVertex_ ovrDistortionVertex
OVR_EXPORT void ovrHmd_Destroy(ovrHmd hmd)
Definition: OVR_CAPI.cpp:292
OVR_EXPORT ovrSensorState ovrHmd_GetSensorState(ovrHmd hmd, double absTime)
Definition: OVR_CAPI.cpp:377
OVR_EXPORT ovrMatrix4f ovrMatrix4f_OrthoSubProjection(ovrMatrix4f projection, ovrVector2f orthoScale, float orthoDistance, float eyeViewAdjustX)
Definition: OVR_CAPI.cpp:111
OVR_EXPORT unsigned int ovrHmd_GetArraySize(ovrHmd hmd, const char *propertyName)
Definition: OVR_CAPI.cpp:894
ovrVector3f LinearAcceleration
Definition: OVR_CAPI.h:93
OVR_EXPORT void ovrHmd_GetRenderScaleAndOffset(ovrFovPort fov, ovrSizei textureSize, ovrRecti renderViewport, ovrVector2f uvScaleOffsetOut[2])
Definition: OVR_CAPI.cpp:755
unsigned short * pIndexData
Definition: OVR_CAPI.h:625
int DisplayId
Definition: OVR_CAPI.h:227
OVR_EXPORT const char * ovrHmd_GetString(ovrHmd hmd, const char *propertyName, const char *defaultVal)
Definition: OVR_CAPI.cpp:853
int char * index(const char *__s, int __c) __THROW __attribute_pure__ __nonnull((1))
float DeltaSeconds
Definition: OVR_CAPI.h:288
float z
Definition: OVR_CAPI.h:65
const char * ProductName
Definition: OVR_CAPI.h:195
OVR_EXPORT float ovrHmd_GetFloat(ovrHmd hmd, const char *propertyName, float defaultVal)
Definition: OVR_CAPI.cpp:804
int w
Definition: OVR_CAPI.h:54
ovrPosef Pose
Definition: OVR_CAPI.h:89
struct ovrDistortionMesh_ ovrDistortionMesh
struct ovrHmdDesc_ ovrHmdDesc
ovrRenderAPIType API
Definition: OVR_CAPI.h:372
unsigned int SensorCaps
Definition: OVR_CAPI.h:201
const char * DisplayDeviceName
Definition: OVR_CAPI.h:225
ovrSensorCaps
Definition: OVR_CAPI.h:156
short ProductId
Definition: OVR_CAPI.h:274
OVR_EXPORT ovrBool ovrHmd_ProcessLatencyTest(ovrHmd hmd, unsigned char rgbColorOut[3])
OVR_EXPORT const char * ovrHmd_GetLatencyTestResult(ovrHmd hmd)
Definition: OVR_CAPI.cpp:783
ovrPoseStatef Recorded
Definition: OVR_CAPI.h:260
float Temperature
Definition: OVR_CAPI.h:263
struct ovrRenderAPIConfigHeader_ ovrRenderAPIConfigHeader
OVR_EXPORT ovrHmd ovrHmd_Create(int index)
Definition: OVR_CAPI.cpp:268
OVR_EXPORT ovrBool ovrHmd_SetFloat(ovrHmd hmd, const char *propertyName, float value)
Definition: OVR_CAPI.cpp:815
OVR_EXPORT unsigned int ovrHmd_GetFloatArray(ovrHmd hmd, const char *propertyName, float values[], unsigned int arraySize)
Definition: OVR_CAPI.cpp:827
ovrQuatf Orientation
Definition: OVR_CAPI.h:82
double TimeInSeconds
Definition: OVR_CAPI.h:94
#define OVR_EXPORT
Definition: OVR_CAPI.h:40