OVR_CAPI_0_8_0.h 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009
  1. /********************************************************************************//**
  2. \file OVR_CAPI_0_8_0.h
  3. \brief C Interface to the Oculus PC SDK tracking and rendering library.
  4. \copyright Copyright 2014 Oculus VR, LLC All Rights reserved.
  5. ************************************************************************************/
  6. #ifndef OVR_CAPI_h // We don't use version numbers within this name, as all versioned variations of this file are currently mutually exclusive.
  7. #define OVR_CAPI_h ///< Header include guard
  8. #include "OVR_CAPI_Keys.h"
  9. #include "OVR_Version.h"
  10. #include "OVR_ErrorCode.h"
  11. #include <stdint.h>
  12. #if defined(_MSC_VER)
  13. #pragma warning(push)
  14. #pragma warning(disable: 4324) // structure was padded due to __declspec(align())
  15. #pragma warning(disable: 4359) // The alignment specified for a type is less than the alignment of the type of one of its data members
  16. #endif
  17. //-----------------------------------------------------------------------------------
  18. // ***** OVR_OS
  19. //
  20. #if !defined(OVR_OS_WIN32) && defined(_WIN32)
  21. #define OVR_OS_WIN32
  22. #endif
  23. #if !defined(OVR_OS_MAC) && defined(__APPLE__)
  24. #define OVR_OS_MAC
  25. #endif
  26. #if !defined(OVR_OS_LINUX) && defined(__linux__)
  27. #define OVR_OS_LINUX
  28. #endif
  29. //-----------------------------------------------------------------------------------
  30. // ***** OVR_CPP
  31. //
  32. #if !defined(OVR_CPP)
  33. #if defined(__cplusplus)
  34. #define OVR_CPP(x) x
  35. #else
  36. #define OVR_CPP(x) /* Not C++ */
  37. #endif
  38. #endif
  39. //-----------------------------------------------------------------------------------
  40. // ***** OVR_CDECL
  41. //
  42. /// LibOVR calling convention for 32-bit Windows builds.
  43. //
  44. #if !defined(OVR_CDECL)
  45. #if defined(_WIN32)
  46. #define OVR_CDECL __cdecl
  47. #else
  48. #define OVR_CDECL
  49. #endif
  50. #endif
  51. //-----------------------------------------------------------------------------------
  52. // ***** OVR_EXTERN_C
  53. //
  54. /// Defined as extern "C" when built from C++ code.
  55. //
  56. #if !defined(OVR_EXTERN_C)
  57. #ifdef __cplusplus
  58. #define OVR_EXTERN_C extern "C"
  59. #else
  60. #define OVR_EXTERN_C
  61. #endif
  62. #endif
  63. //-----------------------------------------------------------------------------------
  64. // ***** OVR_PUBLIC_FUNCTION / OVR_PRIVATE_FUNCTION
  65. //
  66. // OVR_PUBLIC_FUNCTION - Functions that externally visible from a shared library. Corresponds to Microsoft __dllexport.
  67. // OVR_PUBLIC_CLASS - C++ structs and classes that are externally visible from a shared library. Corresponds to Microsoft __dllexport.
  68. // OVR_PRIVATE_FUNCTION - Functions that are not visible outside of a shared library. They are private to the shared library.
  69. // OVR_PRIVATE_CLASS - C++ structs and classes that are not visible outside of a shared library. They are private to the shared library.
  70. //
  71. // OVR_DLL_BUILD - Used to indicate that the current compilation unit is of a shared library.
  72. // OVR_DLL_IMPORT - Used to indicate that the current compilation unit is a user of the corresponding shared library.
  73. // OVR_DLL_BUILD - used to indicate that the current compilation unit is not a shared library but rather statically linked code.
  74. //
  75. #if !defined(OVR_PUBLIC_FUNCTION)
  76. #if defined(OVR_DLL_BUILD)
  77. #if defined(_WIN32)
  78. #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C __declspec(dllexport) rval OVR_CDECL
  79. #define OVR_PUBLIC_CLASS __declspec(dllexport)
  80. #define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL
  81. #define OVR_PRIVATE_CLASS
  82. #else
  83. #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C __attribute__((visibility("default"))) rval OVR_CDECL /* Requires GCC 4.0+ */
  84. #define OVR_PUBLIC_CLASS __attribute__((visibility("default"))) /* Requires GCC 4.0+ */
  85. #define OVR_PRIVATE_FUNCTION(rval) __attribute__((visibility("hidden"))) rval OVR_CDECL
  86. #define OVR_PRIVATE_CLASS __attribute__((visibility("hidden")))
  87. #endif
  88. #elif defined(OVR_DLL_IMPORT)
  89. #if defined(_WIN32)
  90. #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C __declspec(dllimport) rval OVR_CDECL
  91. #define OVR_PUBLIC_CLASS __declspec(dllimport)
  92. #else
  93. #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C rval OVR_CDECL
  94. #define OVR_PUBLIC_CLASS
  95. #endif
  96. #define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL
  97. #define OVR_PRIVATE_CLASS
  98. #else // OVR_STATIC_BUILD
  99. #define OVR_PUBLIC_FUNCTION(rval) OVR_EXTERN_C rval OVR_CDECL
  100. #define OVR_PUBLIC_CLASS
  101. #define OVR_PRIVATE_FUNCTION(rval) rval OVR_CDECL
  102. #define OVR_PRIVATE_CLASS
  103. #endif
  104. #endif
  105. //-----------------------------------------------------------------------------------
  106. // ***** OVR_EXPORT
  107. //
  108. /// Provided for backward compatibility with older versions of this library.
  109. //
  110. #if !defined(OVR_EXPORT)
  111. #ifdef OVR_OS_WIN32
  112. #define OVR_EXPORT __declspec(dllexport)
  113. #else
  114. #define OVR_EXPORT
  115. #endif
  116. #endif
  117. //-----------------------------------------------------------------------------------
  118. // ***** OVR_ALIGNAS
  119. //
  120. #if !defined(OVR_ALIGNAS)
  121. #if defined(__GNUC__) || defined(__clang__)
  122. #define OVR_ALIGNAS(n) __attribute__((aligned(n)))
  123. #elif defined(_MSC_VER) || defined(__INTEL_COMPILER)
  124. #define OVR_ALIGNAS(n) __declspec(align(n))
  125. #elif defined(__CC_ARM)
  126. #define OVR_ALIGNAS(n) __align(n)
  127. #else
  128. #error Need to define OVR_ALIGNAS
  129. #endif
  130. #endif
  131. //-----------------------------------------------------------------------------------
  132. // ***** OVR_CC_HAS_FEATURE
  133. //
  134. // This is a portable way to use compile-time feature identification available
  135. // with some compilers in a clean way. Direct usage of __has_feature in preprocessing
  136. // statements of non-supporting compilers results in a preprocessing error.
  137. //
  138. // Example usage:
  139. // #if OVR_CC_HAS_FEATURE(is_pod)
  140. // if(__is_pod(T)) // If the type is plain data then we can safely memcpy it.
  141. // memcpy(&destObject, &srcObject, sizeof(object));
  142. // #endif
  143. //
  144. #if !defined(OVR_CC_HAS_FEATURE)
  145. #if defined(__clang__) // http://clang.llvm.org/docs/LanguageExtensions.html#id2
  146. #define OVR_CC_HAS_FEATURE(x) __has_feature(x)
  147. #else
  148. #define OVR_CC_HAS_FEATURE(x) 0
  149. #endif
  150. #endif
  151. // ------------------------------------------------------------------------
  152. // ***** OVR_STATIC_ASSERT
  153. //
  154. // Portable support for C++11 static_assert().
  155. // Acts as if the following were declared:
  156. // void OVR_STATIC_ASSERT(bool const_expression, const char* msg);
  157. //
  158. // Example usage:
  159. // OVR_STATIC_ASSERT(sizeof(int32_t) == 4, "int32_t expected to be 4 bytes.");
  160. #if !defined(OVR_STATIC_ASSERT)
  161. #if !(defined(__cplusplus) && (__cplusplus >= 201103L)) /* Other */ && \
  162. !(defined(__GXX_EXPERIMENTAL_CXX0X__)) /* GCC */ && \
  163. !(defined(__clang__) && defined(__cplusplus) && OVR_CC_HAS_FEATURE(cxx_static_assert)) /* clang */ && \
  164. !(defined(_MSC_VER) && (_MSC_VER >= 1600) && defined(__cplusplus)) /* VS2010+ */
  165. #if !defined(OVR_SA_UNUSED)
  166. #if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG)
  167. #define OVR_SA_UNUSED __attribute__((unused))
  168. #else
  169. #define OVR_SA_UNUSED
  170. #endif
  171. #define OVR_SA_PASTE(a,b) a##b
  172. #define OVR_SA_HELP(a,b) OVR_SA_PASTE(a,b)
  173. #endif
  174. #if defined(__COUNTER__)
  175. #define OVR_STATIC_ASSERT(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __COUNTER__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED
  176. #else
  177. #define OVR_STATIC_ASSERT(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __LINE__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED
  178. #endif
  179. #else
  180. #define OVR_STATIC_ASSERT(expression, msg) static_assert(expression, msg)
  181. #endif
  182. #endif
  183. //-----------------------------------------------------------------------------------
  184. // ***** Padding
  185. //
  186. /// Defines explicitly unused space for a struct.
  187. /// When used correcly, usage of this macro should not change the size of the struct.
  188. /// Compile-time and runtime behavior with and without this defined should be identical.
  189. ///
  190. #if !defined(OVR_UNUSED_STRUCT_PAD)
  191. #define OVR_UNUSED_STRUCT_PAD(padName, size) char padName[size];
  192. #endif
  193. //-----------------------------------------------------------------------------------
  194. // ***** Word Size
  195. //
  196. /// Specifies the size of a pointer on the given platform.
  197. ///
  198. #if !defined(OVR_PTR_SIZE)
  199. #if defined(__WORDSIZE)
  200. #define OVR_PTR_SIZE ((__WORDSIZE) / 8)
  201. #elif defined(_WIN64) || defined(__LP64__) || defined(_LP64) || defined(_M_IA64) || defined(__ia64__) || defined(__arch64__) || defined(__64BIT__) || defined(__Ptr_Is_64)
  202. #define OVR_PTR_SIZE 8
  203. #elif defined(__CC_ARM) && (__sizeof_ptr == 8)
  204. #define OVR_PTR_SIZE 8
  205. #else
  206. #define OVR_PTR_SIZE 4
  207. #endif
  208. #endif
  209. //-----------------------------------------------------------------------------------
  210. // ***** OVR_ON32 / OVR_ON64
  211. //
  212. #if OVR_PTR_SIZE == 8
  213. #define OVR_ON32(x)
  214. #define OVR_ON64(x) x
  215. #else
  216. #define OVR_ON32(x) x
  217. #define OVR_ON64(x)
  218. #endif
  219. //-----------------------------------------------------------------------------------
  220. // ***** ovrBool
  221. typedef char ovrBool; ///< Boolean type
  222. #define ovrFalse 0 ///< ovrBool value of false.
  223. #define ovrTrue 1 ///< ovrBool value of true.
  224. //-----------------------------------------------------------------------------------
  225. // ***** Simple Math Structures
  226. /// A 2D vector with integer components.
  227. typedef struct OVR_ALIGNAS(4) ovrVector2i_
  228. {
  229. int x, y;
  230. } ovrVector2i;
  231. /// A 2D size with integer components.
  232. typedef struct OVR_ALIGNAS(4) ovrSizei_
  233. {
  234. int w, h;
  235. } ovrSizei;
  236. /// A 2D rectangle with a position and size.
  237. /// All components are integers.
  238. typedef struct OVR_ALIGNAS(4) ovrRecti_
  239. {
  240. ovrVector2i Pos;
  241. ovrSizei Size;
  242. } ovrRecti;
  243. /// A quaternion rotation.
  244. typedef struct OVR_ALIGNAS(4) ovrQuatf_
  245. {
  246. float x, y, z, w;
  247. } ovrQuatf;
  248. /// A 2D vector with float components.
  249. typedef struct OVR_ALIGNAS(4) ovrVector2f_
  250. {
  251. float x, y;
  252. } ovrVector2f;
  253. /// A 3D vector with float components.
  254. typedef struct OVR_ALIGNAS(4) ovrVector3f_
  255. {
  256. float x, y, z;
  257. } ovrVector3f;
  258. /// A 4x4 matrix with float elements.
  259. typedef struct OVR_ALIGNAS(4) ovrMatrix4f_
  260. {
  261. float M[4][4];
  262. } ovrMatrix4f;
  263. /// Position and orientation together.
  264. typedef struct OVR_ALIGNAS(4) ovrPosef_
  265. {
  266. ovrQuatf Orientation;
  267. ovrVector3f Position;
  268. } ovrPosef;
  269. /// A full pose (rigid body) configuration with first and second derivatives.
  270. ///
  271. /// Body refers to any object for which ovrPoseStatef is providing data.
  272. /// It can be the HMD, Touch controller, camera or something else. The context
  273. /// depends on the usage of the struct.
  274. typedef struct OVR_ALIGNAS(8) ovrPoseStatef_
  275. {
  276. ovrPosef ThePose; ///< Position and orientation.
  277. ovrVector3f AngularVelocity; ///< Angular velocity in radians per second.
  278. ovrVector3f LinearVelocity; ///< Velocity in meters per second.
  279. ovrVector3f AngularAcceleration; ///< Angular acceleration in radians per second per second.
  280. ovrVector3f LinearAcceleration; ///< Acceleration in meters per second per second.
  281. OVR_UNUSED_STRUCT_PAD(pad0, 4) ///< \internal struct pad.
  282. double TimeInSeconds; ///< Absolute time of this state sample.
  283. } ovrPoseStatef;
  284. /// Describes the up, down, left, and right angles of the field of view.
  285. ///
  286. /// Field Of View (FOV) tangent of the angle units.
  287. /// \note For a standard 90 degree vertical FOV, we would
  288. /// have: { UpTan = tan(90 degrees / 2), DownTan = tan(90 degrees / 2) }.
  289. typedef struct OVR_ALIGNAS(4) ovrFovPort_
  290. {
  291. float UpTan; ///< The tangent of the angle between the viewing vector and the top edge of the field of view.
  292. float DownTan; ///< The tangent of the angle between the viewing vector and the bottom edge of the field of view.
  293. float LeftTan; ///< The tangent of the angle between the viewing vector and the left edge of the field of view.
  294. float RightTan; ///< The tangent of the angle between the viewing vector and the right edge of the field of view.
  295. } ovrFovPort;
  296. //-----------------------------------------------------------------------------------
  297. // ***** HMD Types
  298. /// Enumerates all HMD types that we support.
  299. ///
  300. /// The currently released developer kits are ovrHmd_DK1 and ovrHmd_DK2. The other enumerations are for internal use only.
  301. typedef enum ovrHmdType_
  302. {
  303. ovrHmd_None = 0,
  304. ovrHmd_DK1 = 3,
  305. ovrHmd_DKHD = 4,
  306. ovrHmd_DK2 = 6,
  307. ovrHmd_CB = 8,
  308. ovrHmd_Other = 9,
  309. ovrHmd_E3_2015 = 10,
  310. ovrHmd_ES06 = 11,
  311. ovrHmd_ES09 = 12,
  312. ovrHmd_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  313. } ovrHmdType;
  314. /// HMD capability bits reported by device.
  315. ///
  316. /// Set <B>(read/write)</B> flags through ovr_SetEnabledCaps()
  317. typedef enum ovrHmdCaps_
  318. {
  319. // Read-only flags.
  320. ovrHmdCap_DebugDevice = 0x0010, ///< <B>(read only)</B> Specifies that the HMD is a virtual debug device.
  321. /// Indicates to the developer what caps they can and cannot modify. These are processed by the client.
  322. ovrHmdCap_Writable_Mask = 0x0000,
  323. ovrHmdCap_Service_Mask = 0x0000,
  324. ovrHmdCap_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  325. } ovrHmdCaps;
  326. /// Tracking capability bits reported by the device.
  327. /// Used with ovr_ConfigureTracking.
  328. typedef enum ovrTrackingCaps_
  329. {
  330. ovrTrackingCap_Orientation = 0x0010, ///< Supports orientation tracking (IMU).
  331. ovrTrackingCap_MagYawCorrection = 0x0020, ///< Supports yaw drift correction via a magnetometer or other means.
  332. ovrTrackingCap_Position = 0x0040, ///< Supports positional tracking.
  333. ovrTrackingCap_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  334. } ovrTrackingCaps;
  335. /// Specifies which eye is being used for rendering.
  336. /// This type explicitly does not include a third "NoStereo" monoscopic option, as such is
  337. /// not required for an HMD-centered API.
  338. typedef enum ovrEyeType_
  339. {
  340. ovrEye_Left = 0, ///< The left eye, from the viewer's perspective.
  341. ovrEye_Right = 1, ///< The right eye, from the viewer's perspective.
  342. ovrEye_Count = 2, ///< \internal Count of enumerated elements.
  343. ovrEye_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  344. } ovrEyeType;
  345. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrGraphicsLuid_
  346. {
  347. // Public definition reserves space for graphics API-specific implementation
  348. char Reserved[8];
  349. } ovrGraphicsLuid;
  350. /// This is a complete descriptor of the HMD.
  351. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrHmdDesc_
  352. {
  353. ovrHmdType Type; ///< The type of HMD.
  354. OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad0, 4)) ///< \internal struct paddding.
  355. char ProductName[64]; ///< UTF8-encoded product identification string (e.g. "Oculus Rift DK1").
  356. char Manufacturer[64]; ///< UTF8-encoded HMD manufacturer identification string.
  357. short VendorId; ///< HID (USB) vendor identifier of the device.
  358. short ProductId; ///< HID (USB) product identifier of the device.
  359. char SerialNumber[24]; ///< Sensor (and display) serial number.
  360. short FirmwareMajor; ///< Sensor firmware major version.
  361. short FirmwareMinor; ///< Sensor firmware minor version.
  362. float CameraFrustumHFovInRadians; ///< External tracking camera frustum horizontal field-of-view (if present).
  363. float CameraFrustumVFovInRadians; ///< External tracking camera frustum vertical field-of-view (if present).
  364. float CameraFrustumNearZInMeters; ///< External tracking camera frustum near Z (if present).
  365. float CameraFrustumFarZInMeters; ///< External tracking camera frustum far Z (if present).
  366. unsigned int AvailableHmdCaps; ///< Capability bits described by ovrHmdCaps which the HMD currently supports.
  367. unsigned int DefaultHmdCaps; ///< Capability bits described by ovrHmdCaps which are default for the current Hmd.
  368. unsigned int AvailableTrackingCaps; ///< Capability bits described by ovrTrackingCaps which the system currently supports.
  369. unsigned int DefaultTrackingCaps; ///< Capability bits described by ovrTrackingCaps which are default for the current system.
  370. ovrFovPort DefaultEyeFov[ovrEye_Count]; ///< Defines the recommended FOVs for the HMD.
  371. ovrFovPort MaxEyeFov[ovrEye_Count]; ///< Defines the maximum FOVs for the HMD.
  372. ovrSizei Resolution; ///< Resolution of the full HMD screen (both eyes) in pixels.
  373. float DisplayRefreshRate; ///< Nominal refresh rate of the display in cycles per second at the time of HMD creation.
  374. OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad1, 4)) ///< \internal struct paddding.
  375. } ovrHmdDesc;
  376. /// Used as an opaque pointer to an OVR session.
  377. typedef struct ovrHmdStruct* ovrSession;
  378. /// Deprecated synonym for ovrSession, to be removed in a future SDK.
  379. typedef struct ovrHmdStruct* ovrHmd;
  380. /// Bit flags describing the current status of sensor tracking.
  381. /// The values must be the same as in enum StatusBits
  382. ///
  383. /// \see ovrTrackingState
  384. ///
  385. typedef enum ovrStatusBits_
  386. {
  387. ovrStatus_OrientationTracked = 0x0001, ///< Orientation is currently tracked (connected and in use).
  388. ovrStatus_PositionTracked = 0x0002, ///< Position is currently tracked (false if out of range).
  389. ovrStatus_CameraPoseTracked = 0x0004, ///< Camera pose is currently tracked.
  390. ovrStatus_PositionConnected = 0x0020, ///< Position tracking hardware is connected.
  391. ovrStatus_HmdConnected = 0x0080, ///< HMD Display is available and connected.
  392. ovrStatus_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  393. } ovrStatusBits;
  394. /// Specifies a reading we can query from the sensor.
  395. ///
  396. /// \see ovrTrackingState
  397. ///
  398. typedef struct OVR_ALIGNAS(4) ovrSensorData_
  399. {
  400. ovrVector3f Accelerometer; ///< Acceleration reading in meters/second^2.
  401. ovrVector3f Gyro; ///< Rotation rate in radians/second.
  402. ovrVector3f Magnetometer; ///< Magnetic field in Gauss.
  403. float Temperature; ///< Temperature of the sensor in degrees Celsius.
  404. float TimeInSeconds; ///< Time when the reported IMU reading took place in seconds. \see ovr_GetTimeInSeconds
  405. } ovrSensorData;
  406. /// Tracking state at a given absolute time (describes predicted HMD pose, etc.).
  407. /// Returned by ovr_GetTrackingState.
  408. ///
  409. /// \see ovr_GetTrackingState
  410. ///
  411. typedef struct OVR_ALIGNAS(8) ovrTrackingState_
  412. {
  413. /// Predicted head pose (and derivatives) at the requested absolute time.
  414. /// The look-ahead interval is equal to (HeadPose.TimeInSeconds - RawSensorData.TimeInSeconds).
  415. ovrPoseStatef HeadPose;
  416. /// Current pose of the external camera (if present).
  417. /// This pose includes camera tilt (roll and pitch). For a leveled coordinate
  418. /// system use LeveledCameraPose.
  419. ovrPosef CameraPose;
  420. /// Camera frame aligned with gravity.
  421. /// This value includes position and yaw of the camera, but not roll and pitch.
  422. /// It can be used as a reference point to render real-world objects in the correct location.
  423. ovrPosef LeveledCameraPose;
  424. /// The most recent calculated pose for each hand when hand controller tracking is present.
  425. /// HandPoses[ovrHand_Left] refers to the left hand and HandPoses[ovrHand_Right] to the right hand.
  426. /// These values can be combined with ovrInputState for complete hand controller information.
  427. ovrPoseStatef HandPoses[2];
  428. /// The most recent sensor data received from the HMD.
  429. ovrSensorData RawSensorData;
  430. /// Tracking status described by ovrStatusBits.
  431. unsigned int StatusFlags;
  432. /// Hand status flags described by ovrStatusBits.
  433. /// Only ovrStatus_OrientationTracked and ovrStatus_PositionTracked are reported.
  434. unsigned int HandStatusFlags[2];
  435. /// Tags the vision processing results to a certain frame counter number.
  436. uint32_t LastCameraFrameCounter;
  437. OVR_UNUSED_STRUCT_PAD(pad0, 4) ///< \internal struct padding
  438. } ovrTrackingState;
  439. /// Rendering information for each eye. Computed by ovr_GetRenderDesc() based on the
  440. /// specified FOV. Note that the rendering viewport is not included
  441. /// here as it can be specified separately and modified per frame by
  442. /// passing different Viewport values in the layer structure.
  443. ///
  444. /// \see ovr_GetRenderDesc
  445. ///
  446. typedef struct OVR_ALIGNAS(4) ovrEyeRenderDesc_
  447. {
  448. ovrEyeType Eye; ///< The eye index to which this instance corresponds.
  449. ovrFovPort Fov; ///< The field of view.
  450. ovrRecti DistortedViewport; ///< Distortion viewport.
  451. ovrVector2f PixelsPerTanAngleAtCenter; ///< How many display pixels will fit in tan(angle) = 1.
  452. ovrVector3f HmdToEyeViewOffset; ///< Translation of each eye.
  453. } ovrEyeRenderDesc;
  454. /// Projection information for ovrLayerEyeFovDepth.
  455. ///
  456. /// Use the utility function ovrTimewarpProjectionDesc_FromProjection to
  457. /// generate this structure from the application's projection matrix.
  458. ///
  459. /// \see ovrLayerEyeFovDepth, ovrTimewarpProjectionDesc_FromProjection
  460. ///
  461. typedef struct OVR_ALIGNAS(4) ovrTimewarpProjectionDesc_
  462. {
  463. float Projection22; ///< Projection matrix element [2][2].
  464. float Projection23; ///< Projection matrix element [2][3].
  465. float Projection32; ///< Projection matrix element [3][2].
  466. } ovrTimewarpProjectionDesc;
  467. /// Contains the data necessary to properly calculate position info for various layer types.
  468. /// - HmdToEyeViewOffset is the same value pair provided in ovrEyeRenderDesc.
  469. /// - HmdSpaceToWorldScaleInMeters is used to scale player motion into in-application units.
  470. /// In other words, it is how big an in-application unit is in the player's physical meters.
  471. /// For example, if the application uses inches as its units then HmdSpaceToWorldScaleInMeters would be 0.0254.
  472. /// Note that if you are scaling the player in size, this must also scale. So if your application
  473. /// units are inches, but you're shrinking the player to half their normal size, then
  474. /// HmdSpaceToWorldScaleInMeters would be 0.0254*2.0.
  475. ///
  476. /// \see ovrEyeRenderDesc, ovr_SubmitFrame
  477. ///
  478. typedef struct OVR_ALIGNAS(4) ovrViewScaleDesc_
  479. {
  480. ovrVector3f HmdToEyeViewOffset[ovrEye_Count]; ///< Translation of each eye.
  481. float HmdSpaceToWorldScaleInMeters; ///< Ratio of viewer units to meter units.
  482. } ovrViewScaleDesc;
  483. //-----------------------------------------------------------------------------------
  484. // ***** Platform-independent Rendering Configuration
  485. /// These types are used to hide platform-specific details when passing
  486. /// render device, OS, and texture data to the API.
  487. ///
  488. /// The benefit of having these wrappers versus platform-specific API functions is
  489. /// that they allow application glue code to be portable. A typical example is an
  490. /// engine that has multiple back ends, such as GL and D3D. Portable code that calls
  491. /// these back ends can also use LibOVR. To do this, back ends can be modified
  492. /// to return portable types such as ovrTexture and ovrRenderAPIConfig.
  493. typedef enum ovrRenderAPIType_
  494. {
  495. ovrRenderAPI_None = 0, ///< No API
  496. ovrRenderAPI_OpenGL = 1, ///< OpenGL
  497. ovrRenderAPI_Android_GLES = 2, ///< OpenGL ES
  498. ovrRenderAPI_D3D11 = 5, ///< DirectX 11.
  499. ovrRenderAPI_Count = 4, ///< \internal Count of enumerated elements.
  500. ovrRenderAPI_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  501. } ovrRenderAPIType;
  502. /// API-independent part of a texture descriptor.
  503. ///
  504. /// ovrTextureHeader is a common struct present in all ovrTexture struct types.
  505. ///
  506. typedef struct OVR_ALIGNAS(4) ovrTextureHeader_
  507. {
  508. ovrRenderAPIType API; ///< The API type to which this texture belongs.
  509. ovrSizei TextureSize; ///< Size of this texture in pixels.
  510. } ovrTextureHeader;
  511. /// Contains platform-specific information about a texture.
  512. /// Aliases to one of ovrD3D11Texture or ovrGLTexture.
  513. ///
  514. /// \see ovrD3D11Texture, ovrGLTexture.
  515. ///
  516. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrTexture_
  517. {
  518. ovrTextureHeader Header; ///< API-independent header.
  519. OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad0, 4)) ///< \internal struct padding
  520. uintptr_t PlatformData[8]; ///< Specialized in ovrGLTextureData, ovrD3D11TextureData etc.
  521. } ovrTexture;
  522. /// Describes a set of textures that act as a rendered flip chain.
  523. ///
  524. /// An ovrSwapTextureSet per layer is passed to ovr_SubmitFrame via one of the ovrLayer types.
  525. /// The TextureCount refers to the flip chain count and not an eye count.
  526. /// See the layer structs and functions for information about how to use ovrSwapTextureSet.
  527. ///
  528. /// ovrSwapTextureSets must be created by either the ovr_CreateSwapTextureSetD3D11 or
  529. /// ovr_CreateSwapTextureSetGL factory function, and must be destroyed by ovr_DestroySwapTextureSet.
  530. ///
  531. /// \see ovr_CreateSwapTextureSetD3D11, ovr_CreateSwapTextureSetGL, ovr_DestroySwapTextureSet.
  532. ///
  533. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrSwapTextureSet_
  534. {
  535. ovrTexture* Textures; ///< Points to an array of ovrTextures.
  536. int TextureCount; ///< The number of textures referenced by the Textures array.
  537. /// CurrentIndex specifies which of the Textures will be used by the ovr_SubmitFrame call.
  538. /// This is manually incremented by the application, typically in a round-robin manner.
  539. ///
  540. /// Before selecting a Texture as a rendertarget, the application should increment CurrentIndex by
  541. /// 1 and wrap it back to 0 if CurrentIndex == TextureCount, so that it gets a fresh rendertarget,
  542. /// one that is not currently being used for display. It can then render to Textures[CurrentIndex].
  543. ///
  544. /// After rendering, the application calls ovr_SubmitFrame using that same CurrentIndex value
  545. /// to display the new rendertarget.
  546. ///
  547. /// The application can submit multiple frames with the same ovrSwapTextureSet and CurrentIndex
  548. /// value if the rendertarget does not need to be updated, for example when displaying an
  549. /// information display whose text has not changed since the previous frame.
  550. ///
  551. /// Multiple layers can use the same ovrSwapTextureSet at the same time - there is no need to
  552. /// create a unique ovrSwapTextureSet for each layer. However, all the layers using a particular
  553. /// ovrSwapTextureSet will share the same value of CurrentIndex, so they cannot use different
  554. /// textures within the ovrSwapTextureSet.
  555. ///
  556. /// Once a particular Textures[CurrentIndex] has been sent to ovr_SubmitFrame, that texture
  557. /// should not be rendered to until a subsequent ovr_SubmitFrame is made (either with a
  558. /// different CurrentIndex value, or with a different ovrSwapTextureSet, or disabling the layer).
  559. int CurrentIndex;
  560. } ovrSwapTextureSet;
  561. //-----------------------------------------------------------------------------------
  562. /// Describes button input types.
  563. /// Button inputs are combined; that is they will be reported as pressed if they are
  564. /// pressed on either one of the two devices.
  565. /// The ovrButton_Up/Down/Left/Right map to both XBox D-Pad and directional buttons.
  566. /// The ovrButton_Enter and ovrButton_Return map to Start and Back controller buttons, respectively.
  567. typedef enum ovrButton_
  568. {
  569. ovrButton_A = 0x00000001,
  570. ovrButton_B = 0x00000002,
  571. ovrButton_RThumb = 0x00000004,
  572. ovrButton_RShoulder = 0x00000008,
  573. ovrButton_X = 0x00000100,
  574. ovrButton_Y = 0x00000200,
  575. ovrButton_LThumb = 0x00000400,
  576. ovrButton_LShoulder = 0x00000800,
  577. // Navigation through DPad.
  578. ovrButton_Up = 0x00010000,
  579. ovrButton_Down = 0x00020000,
  580. ovrButton_Left = 0x00040000,
  581. ovrButton_Right = 0x00080000,
  582. ovrButton_Enter = 0x00100000, // Start on XBox controller.
  583. ovrButton_Back = 0x00200000, // Back on Xbox controller.
  584. ovrButton_Private = 0x00400000 | 0x00800000 | 0x01000000,
  585. ovrButton_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  586. } ovrButton;
  587. /// Describes touch input types.
  588. /// These values map to capacitive touch values reported ovrInputState::Touch.
  589. /// Some of these values are mapped to button bits for consistency.
  590. typedef enum ovrTouch_
  591. {
  592. ovrTouch_A = ovrButton_A,
  593. ovrTouch_B = ovrButton_B,
  594. ovrTouch_RThumb = ovrButton_RThumb,
  595. ovrTouch_RIndexTrigger = 0x00000010,
  596. ovrTouch_X = ovrButton_X,
  597. ovrTouch_Y = ovrButton_Y,
  598. ovrTouch_LThumb = ovrButton_LThumb,
  599. ovrTouch_LIndexTrigger = 0x00001000,
  600. // Finger pose state
  601. // Derived internally based on distance, proximity to sensors and filtering.
  602. ovrTouch_RIndexPointing = 0x00000020,
  603. ovrTouch_RThumbUp = 0x00000040,
  604. ovrTouch_LIndexPointing = 0x00002000,
  605. ovrTouch_LThumbUp = 0x00004000,
  606. ovrTouch_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  607. } ovrTouch;
  608. /// Specifies which controller is connected; multiple can be connected at once.
  609. typedef enum ovrControllerType_
  610. {
  611. ovrControllerType_None = 0x00,
  612. ovrControllerType_LTouch = 0x01,
  613. ovrControllerType_RTouch = 0x02,
  614. ovrControllerType_Touch = 0x03,
  615. ovrControllerType_XBox = 0x10,
  616. ovrControllerType_All = 0xff,
  617. ovrControllerType_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  618. } ovrControllerType;
  619. /// Provides names for the left and right hand array indexes.
  620. ///
  621. /// \see ovrInputState, ovrTrackingState
  622. ///
  623. typedef enum ovrHandType_
  624. {
  625. ovrHand_Left = 0,
  626. ovrHand_Right = 1,
  627. ovrHand_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  628. } ovrHandType;
  629. /// ovrInputState describes the complete controller input state, including Oculus Touch,
  630. /// and XBox gamepad. If multiple inputs are connected and used at the same time,
  631. /// their inputs are combined.
  632. typedef struct ovrInputState_
  633. {
  634. // System type when the controller state was last updated.
  635. double TimeInSeconds;
  636. // Described by ovrControllerType. Indicates which ControllerTypes are present.
  637. unsigned int ConnectedControllerTypes;
  638. // Values for buttons described by ovrButton.
  639. unsigned int Buttons;
  640. // Touch values for buttons and sensors as described by ovrTouch.
  641. unsigned int Touches;
  642. // Left and right finger trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f.
  643. float IndexTrigger[2];
  644. // Left and right hand trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f.
  645. float HandTrigger[2];
  646. // Horizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range -1.0f to 1.0f.
  647. ovrVector2f Thumbstick[2];
  648. } ovrInputState;
  649. //-----------------------------------------------------------------------------------
  650. // ***** Initialize structures
  651. /// Initialization flags.
  652. ///
  653. /// \see ovrInitParams, ovr_Initialize
  654. ///
  655. typedef enum ovrInitFlags_
  656. {
  657. /// When a debug library is requested, a slower debugging version of the library will
  658. /// run which can be used to help solve problems in the library and debug application code.
  659. ovrInit_Debug = 0x00000001,
  660. /// When a version is requested, the LibOVR runtime respects the RequestedMinorVersion
  661. /// field and verifies that the RequestedMinorVersion is supported.
  662. ovrInit_RequestVersion = 0x00000004,
  663. // These bits are writable by user code.
  664. ovrinit_WritableBits = 0x00ffffff,
  665. ovrInit_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  666. } ovrInitFlags;
  667. /// Logging levels
  668. ///
  669. /// \see ovrInitParams, ovrLogCallback
  670. ///
  671. typedef enum ovrLogLevel_
  672. {
  673. ovrLogLevel_Debug = 0, ///< Debug-level log event.
  674. ovrLogLevel_Info = 1, ///< Info-level log event.
  675. ovrLogLevel_Error = 2, ///< Error-level log event.
  676. ovrLogLevel_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  677. } ovrLogLevel;
  678. /// Signature of the logging callback function pointer type.
  679. ///
  680. /// \param[in] userData is an arbitrary value specified by the user of ovrInitParams.
  681. /// \param[in] level is one of the ovrLogLevel constants.
  682. /// \param[in] message is a UTF8-encoded null-terminated string.
  683. /// \see ovrInitParams, ovrLogLevel, ovr_Initialize
  684. ///
  685. typedef void (OVR_CDECL* ovrLogCallback)(uintptr_t userData, int level, const char* message);
  686. /// Parameters for ovr_Initialize.
  687. ///
  688. /// \see ovr_Initialize
  689. ///
  690. typedef struct OVR_ALIGNAS(8) ovrInitParams_
  691. {
  692. /// Flags from ovrInitFlags to override default behavior.
  693. /// Use 0 for the defaults.
  694. uint32_t Flags;
  695. /// Requests a specific minimum minor version of the LibOVR runtime.
  696. /// Flags must include ovrInit_RequestVersion or this will be ignored
  697. /// and OVR_MINOR_VERSION will be used.
  698. uint32_t RequestedMinorVersion;
  699. /// User-supplied log callback function, which may be called at any time
  700. /// asynchronously from multiple threads until ovr_Shutdown completes.
  701. /// Use NULL to specify no log callback.
  702. ovrLogCallback LogCallback;
  703. /// User-supplied data which is passed as-is to LogCallback. Typically this
  704. /// is used to store an application-specific pointer which is read in the
  705. /// callback function.
  706. uintptr_t UserData;
  707. /// Relative number of milliseconds to wait for a connection to the server
  708. /// before failing. Use 0 for the default timeout.
  709. uint32_t ConnectionTimeoutMS;
  710. OVR_ON64(OVR_UNUSED_STRUCT_PAD(pad0, 4)) ///< \internal
  711. } ovrInitParams;
  712. #ifdef __cplusplus
  713. extern "C" {
  714. #endif
  715. // -----------------------------------------------------------------------------------
  716. // ***** API Interfaces
  717. // Overview of the API
  718. //
  719. // Setup:
  720. // - ovr_Initialize().
  721. // - ovr_Create(&hmd, &graphicsId).
  722. // - Call ovr_ConfigureTracking() to configure and initialize tracking.
  723. // - Use hmd members and ovr_GetFovTextureSize() to determine graphics configuration
  724. // and ovr_GetRenderDesc() to get per-eye rendering parameters.
  725. // - Allocate render target texture sets with ovr_CreateSwapTextureSetD3D11() or
  726. // ovr_CreateSwapTextureSetGL().
  727. //
  728. // Application Loop:
  729. // - Call ovr_GetPredictedDisplayTime() to get the current frame timing information.
  730. // - Call ovr_GetTrackingState() and ovr_CalcEyePoses() to obtain the predicted
  731. // rendering pose for each eye based on timing.
  732. // - Increment ovrTextureSet::CurrentIndex for each layer you will be rendering to
  733. // in the next step.
  734. // - Render the scene content into ovrTextureSet::CurrentIndex for each eye and layer
  735. // you plan to update this frame.
  736. // - Call ovr_SubmitFrame() to render the distorted layers to the back buffer
  737. // and present them on the HMD. If ovr_SubmitFrame returns ovrSuccess_NotVisible,
  738. // there is no need to render the scene for the next loop iteration. Instead,
  739. // just call ovr_SubmitFrame again until it returns ovrSuccess. ovrTextureSet::CurrentIndex
  740. // for each layer should refer to the texure you want to display.
  741. //
  742. // Shutdown:
  743. // - ovr_Destroy().
  744. // - ovr_Shutdown().
  745. /// Initializes LibOVR
  746. ///
  747. /// Initialize LibOVR for application usage. This includes finding and loading the LibOVRRT
  748. /// shared library. No LibOVR API functions, other than ovr_GetLastErrorInfo, can be called
  749. /// unless ovr_Initialize succeeds. A successful call to ovr_Initialize must be eventually
  750. /// followed by a call to ovr_Shutdown. ovr_Initialize calls are idempotent.
  751. /// Calling ovr_Initialize twice does not require two matching calls to ovr_Shutdown.
  752. /// If already initialized, the return value is ovr_Success.
  753. ///
  754. /// LibOVRRT shared library search order:
  755. /// -# Current working directory (often the same as the application directory).
  756. /// -# Module directory (usually the same as the application directory,
  757. /// but not if the module is a separate shared library).
  758. /// -# Application directory
  759. /// -# Development directory (only if OVR_ENABLE_DEVELOPER_SEARCH is enabled,
  760. /// which is off by default).
  761. /// -# Standard OS shared library search location(s) (OS-specific).
  762. ///
  763. /// \param params Specifies custom initialization options. May be NULL to indicate default options.
  764. /// \return Returns an ovrResult indicating success or failure. In the case of failure, use
  765. /// ovr_GetLastErrorInfo to get more information. Example failed results include:
  766. /// - ovrError_Initialize: Generic initialization error.
  767. /// - ovrError_LibLoad: Couldn't load LibOVRRT.
  768. /// - ovrError_LibVersion: LibOVRRT version incompatibility.
  769. /// - ovrError_ServiceConnection: Couldn't connect to the OVR Service.
  770. /// - ovrError_ServiceVersion: OVR Service version incompatibility.
  771. /// - ovrError_IncompatibleOS: The operating system version is incompatible.
  772. /// - ovrError_DisplayInit: Unable to initialize the HMD display.
  773. /// - ovrError_ServerStart: Unable to start the server. Is it already running?
  774. /// - ovrError_Reinitialization: Attempted to re-initialize with a different version.
  775. ///
  776. /// <b>Example code</b>
  777. /// \code{.cpp}
  778. /// ovrResult result = ovr_Initialize(NULL);
  779. /// if(OVR_FAILURE(result)) {
  780. /// ovrErrorInfo errorInfo;
  781. /// ovr_GetLastErrorInfo(&errorInfo);
  782. /// DebugLog("ovr_Initialize failed: %s", errorInfo.ErrorString);
  783. /// return false;
  784. /// }
  785. /// [...]
  786. /// \endcode
  787. ///
  788. /// \see ovr_Shutdown
  789. ///
  790. OVR_PUBLIC_FUNCTION(ovrResult) ovr_Initialize(const ovrInitParams* params);
  791. /// Shuts down LibOVR
  792. ///
  793. /// A successful call to ovr_Initialize must be eventually matched by a call to ovr_Shutdown.
  794. /// After calling ovr_Shutdown, no LibOVR functions can be called except ovr_GetLastErrorInfo
  795. /// or another ovr_Initialize. ovr_Shutdown invalidates all pointers, references, and created objects
  796. /// previously returned by LibOVR functions. The LibOVRRT shared library can be unloaded by
  797. /// ovr_Shutdown.
  798. ///
  799. /// \see ovr_Initialize
  800. ///
  801. OVR_PUBLIC_FUNCTION(void) ovr_Shutdown();
  802. /// Provides information about the last error.
  803. /// \see ovr_GetLastErrorInfo
  804. typedef struct ovrErrorInfo_
  805. {
  806. ovrResult Result; ///< The result from the last API call that generated an error ovrResult.
  807. char ErrorString[512]; ///< A UTF8-encoded null-terminated English string describing the problem. The format of this string is subject to change in future versions.
  808. } ovrErrorInfo;
  809. /// Returns information about the most recent failed return value by the
  810. /// current thread for this library.
  811. ///
  812. /// This function itself can never generate an error.
  813. /// The last error is never cleared by LibOVR, but will be overwritten by new errors.
  814. /// Do not use this call to determine if there was an error in the last API
  815. /// call as successful API calls don't clear the last ovrErrorInfo.
  816. /// To avoid any inconsistency, ovr_GetLastErrorInfo should be called immediately
  817. /// after an API function that returned a failed ovrResult, with no other API
  818. /// functions called in the interim.
  819. ///
  820. /// \param[out] errorInfo The last ovrErrorInfo for the current thread.
  821. ///
  822. /// \see ovrErrorInfo
  823. ///
  824. OVR_PUBLIC_FUNCTION(void) ovr_GetLastErrorInfo(ovrErrorInfo* errorInfo);
  825. /// Returns the version string representing the LibOVRRT version.
  826. ///
  827. /// The returned string pointer is valid until the next call to ovr_Shutdown.
  828. ///
  829. /// Note that the returned version string doesn't necessarily match the current
  830. /// OVR_MAJOR_VERSION, etc., as the returned string refers to the LibOVRRT shared
  831. /// library version and not the locally compiled interface version.
  832. ///
  833. /// The format of this string is subject to change in future versions and its contents
  834. /// should not be interpreted.
  835. ///
  836. /// \return Returns a UTF8-encoded null-terminated version string.
  837. ///
  838. OVR_PUBLIC_FUNCTION(const char*) ovr_GetVersionString();
  839. /// Writes a message string to the LibOVR tracing mechanism (if enabled).
  840. ///
  841. /// This message will be passed back to the application via the ovrLogCallback if
  842. /// it was registered.
  843. ///
  844. /// \param[in] level One of the ovrLogLevel constants.
  845. /// \param[in] message A UTF8-encoded null-terminated string.
  846. /// \return returns the strlen of the message or a negative value if the message is too large.
  847. ///
  848. /// \see ovrLogLevel, ovrLogCallback
  849. ///
  850. OVR_PUBLIC_FUNCTION(int) ovr_TraceMessage(int level, const char* message);
  851. //-------------------------------------------------------------------------------------
  852. /// @name HMD Management
  853. ///
  854. /// Handles the enumeration, creation, destruction, and properties of an HMD (head-mounted display).
  855. ///@{
  856. /// Returns information about the current HMD.
  857. ///
  858. /// ovr_Initialize must have first been called in order for this to succeed, otherwise ovrHmdDesc::Type
  859. /// will be reported as ovrHmd_None.
  860. ///
  861. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create, else NULL in which
  862. /// case this function detects whether an HMD is present and returns its info if so.
  863. ///
  864. /// \return Returns an ovrHmdDesc. If the hmd is NULL and ovrHmdDesc::Type is ovrHmd_None then
  865. /// no HMD is present.
  866. ///
  867. OVR_PUBLIC_FUNCTION(ovrHmdDesc) ovr_GetHmdDesc(ovrSession session);
  868. /// Creates a handle to a VR session.
  869. ///
  870. /// Upon success the returned ovrSession must be eventually freed with ovr_Destroy when it is no longer needed.
  871. /// A second call to ovr_Create will result in an error return value if the previous Hmd has not been destroyed.
  872. ///
  873. /// \param[out] pSession Provides a pointer to an ovrSession which will be written to upon success.
  874. /// \param[out] luid Provides a system specific graphics adapter identifier that locates which
  875. /// graphics adapter has the HMD attached. This must match the adapter used by the application
  876. /// or no rendering output will be possible. This is important for stability on multi-adapter systems. An
  877. /// application that simply chooses the default adapter will not run reliably on multi-adapter systems.
  878. /// \return Returns an ovrResult indicating success or failure. Upon failure
  879. /// the returned pHmd will be NULL.
  880. ///
  881. /// <b>Example code</b>
  882. /// \code{.cpp}
  883. /// ovrSession session;
  884. /// ovrGraphicsLuid luid;
  885. /// ovrResult result = ovr_Create(&session, &luid);
  886. /// if(OVR_FAILURE(result))
  887. /// ...
  888. /// \endcode
  889. ///
  890. /// \see ovr_Destroy
  891. ///
  892. OVR_PUBLIC_FUNCTION(ovrResult) ovr_Create(ovrSession* pSession, ovrGraphicsLuid* pLuid);
  893. /// Destroys the HMD.
  894. ///
  895. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  896. /// \see ovr_Create
  897. ///
  898. OVR_PUBLIC_FUNCTION(void) ovr_Destroy(ovrSession session);
  899. /// Specifies status information for the current session.
  900. ///
  901. /// \see ovr_GetSessionStatus
  902. ///
  903. typedef struct ovrSessionStatus_
  904. {
  905. ovrBool HasVrFocus; ///< True if the process has VR focus and thus is visible in the HMD.
  906. ovrBool HmdPresent; ///< True if an HMD is present.
  907. }ovrSessionStatus;
  908. /// Returns status information for the application.
  909. ///
  910. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  911. /// \param[out] sessionStatus Provides an ovrSessionStatus that is filled in.
  912. ///
  913. /// \return Returns an ovrResult indicating success or failure. In the case of
  914. /// failure, use ovr_GetLastErrorInfo to get more information.
  915. ///
  916. OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetSessionStatus(ovrSession session, ovrSessionStatus* sessionStatus);
  917. /// Returns ovrHmdCaps bits that are currently enabled.
  918. ///
  919. /// Note that this value is different from ovrHmdDesc::AvailableHmdCaps, which describes what
  920. /// capabilities are available for that HMD.
  921. ///
  922. /// \return Returns a combination of zero or more ovrHmdCaps.
  923. /// \see ovrHmdCaps
  924. ///
  925. OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetEnabledCaps(ovrSession session);
  926. /// Modifies capability bits described by ovrHmdCaps that can be modified,
  927. /// such as ovrHmdCap_LowPersistance.
  928. ///
  929. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  930. /// \param[in] hmdCaps A combination of 0 or more ovrHmdCaps.
  931. ///
  932. /// \see ovrHmdCaps
  933. ///
  934. OVR_PUBLIC_FUNCTION(void) ovr_SetEnabledCaps(ovrSession session, unsigned int hmdCaps);
  935. //@}
  936. //-------------------------------------------------------------------------------------
  937. /// @name Tracking
  938. ///
  939. /// Tracking functions handle the position, orientation, and movement of the HMD in space.
  940. ///
  941. /// All tracking interface functions are thread-safe, allowing tracking state to be sampled
  942. /// from different threads.
  943. ///
  944. ///@{
  945. /// Returns the current tracking caps
  946. ///
  947. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  948. ///
  949. /// \return Returns caps from ovrTrackingCaps.
  950. ///
  951. /// \see ovrTrackingCaps
  952. ///
  953. OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetTrackingCaps(ovrSession session);
  954. /// Starts sensor sampling, enabling specified capabilities, described by ovrTrackingCaps.
  955. ///
  956. /// Use 0 for both requestedTrackingCaps and requiredTrackingCaps to disable tracking.
  957. /// ovr_ConfigureTracking can be called multiple times with the same or different values
  958. /// for a given ovrSession.
  959. ///
  960. /// ovr_Create automatically enables full tracking supported by the given device. This function
  961. /// is not needed unless the disabling of tracking features is required.
  962. ///
  963. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  964. ///
  965. /// \param[in] requestedTrackingCaps specifies support that is requested. The function will succeed
  966. /// even if these caps are not available (i.e. sensor or camera is unplugged). Support
  967. /// will automatically be enabled if the device is plugged in later. Software should
  968. /// check ovrTrackingState.StatusFlags for real-time status.
  969. ///
  970. /// \param[in] requiredTrackingCaps Specifies sensor capabilities required at the time of the call.
  971. /// If they are not available, the function will fail. Pass 0 if only specifying
  972. /// requestedTrackingCaps.
  973. ///
  974. /// \return Returns an ovrResult indicating success or failure. In the case of failure, use
  975. /// ovr_GetLastErrorInfo to get more information.
  976. ///
  977. /// \see ovrTrackingCaps, ovr_Create
  978. ///
  979. OVR_PUBLIC_FUNCTION(ovrResult) ovr_ConfigureTracking(ovrSession session, unsigned int requestedTrackingCaps,
  980. unsigned int requiredTrackingCaps);
  981. /// Re-centers the sensor position and orientation.
  982. ///
  983. /// This resets the (x,y,z) positional components and the yaw orientation component.
  984. /// The Roll and pitch orientation components are always determined by gravity and cannot
  985. /// be redefined. All future tracking will report values relative to this new reference position.
  986. ///
  987. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  988. ///
  989. OVR_PUBLIC_FUNCTION(void) ovr_RecenterPose(ovrSession session);
  990. /// Returns tracking state reading based on the specified absolute system time.
  991. ///
  992. /// Pass an absTime value of 0.0 to request the most recent sensor reading. In this case
  993. /// both PredictedPose and SamplePose will have the same value.
  994. ///
  995. /// This may also be used for more refined timing of front buffer rendering logic, and so on.
  996. /// This may be called by multiple threads.
  997. ///
  998. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  999. /// \param[in] absTime Specifies the absolute future time to predict the return
  1000. /// ovrTrackingState value. Use 0 to request the most recent tracking state.
  1001. /// \param[in] latencyMarker Specifies that this call is the point in time where
  1002. /// the "App-to-Mid-Photon" latency timer starts from. If a given ovrLayer
  1003. /// provides "SensorSampleTimestamp", that will override the value stored here.
  1004. /// \return Returns the ovrTrackingState that is predicted for the given absTime.
  1005. ///
  1006. /// \see ovrTrackingState, ovr_GetEyePoses, ovr_GetTimeInSeconds
  1007. ///
  1008. OVR_PUBLIC_FUNCTION(ovrTrackingState) ovr_GetTrackingState(ovrSession session, double absTime, ovrBool latencyMarker);
  1009. /// Returns the most recent input state for controllers, without positional tracking info.
  1010. /// Developers can tell whether the same state was returned by checking the PacketNumber.
  1011. ///
  1012. /// \param[out] inputState Input state that will be filled in.
  1013. /// \param[in] controllerTypeMask Specifies which controllers the input will be returned for.
  1014. /// Described by ovrControllerType.
  1015. /// \return Returns ovrSuccess if the new state was successfully obtained.
  1016. ///
  1017. /// \see ovrControllerType
  1018. ///
  1019. OVR_PUBLIC_FUNCTION(ovrResult) ovr_GetInputState(ovrSession session, unsigned int controllerTypeMask, ovrInputState* inputState);
  1020. /// Turns on vibration of the given controller.
  1021. ///
  1022. /// To disable vibration, call ovr_SetControllerVibration with an amplitude of 0.
  1023. /// Vibration automatically stops after a nominal amount of time, so if you want vibration
  1024. /// to be continuous over multiple seconds then you need to call this function periodically.
  1025. ///
  1026. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1027. /// \param[in] controllerTypeMask Specifies controllers to apply the vibration to.
  1028. /// \param[in] frequency Specifies a vibration frequency in the range of 0.0 to 1.0.
  1029. /// Currently the only valid values are 0.0, 0.5, and 1.0 and other values will
  1030. /// be clamped to one of these.
  1031. /// \param[in] amplitude Specifies a vibration amplitude in the range of 0.0 to 1.0.
  1032. ///
  1033. /// \return Returns ovrSuccess upon success.
  1034. ///
  1035. /// \see ovrControllerType
  1036. ///
  1037. OVR_PUBLIC_FUNCTION(ovrResult) ovr_SetControllerVibration(ovrSession session, unsigned int controllerTypeMask,
  1038. float frequency, float amplitude);
  1039. ///@}
  1040. //-------------------------------------------------------------------------------------
  1041. // @name Layers
  1042. //
  1043. ///@{
  1044. /// Specifies the maximum number of layers supported by ovr_SubmitFrame.
  1045. ///
  1046. /// /see ovr_SubmitFrame
  1047. ///
  1048. enum {
  1049. ovrMaxLayerCount = 32
  1050. };
  1051. /// Describes layer types that can be passed to ovr_SubmitFrame.
  1052. /// Each layer type has an associated struct, such as ovrLayerEyeFov.
  1053. ///
  1054. /// \see ovrLayerHeader
  1055. ///
  1056. typedef enum ovrLayerType_
  1057. {
  1058. ovrLayerType_Disabled = 0, ///< Layer is disabled.
  1059. ovrLayerType_EyeFov = 1, ///< Described by ovrLayerEyeFov.
  1060. ovrLayerType_EyeFovDepth = 2, ///< Described by ovrLayerEyeFovDepth.
  1061. ovrLayerType_Quad = 3, ///< Described by ovrLayerQuad. Was called ovrLayerType_QuadInWorld.
  1062. /// enum 4 used to be ovrLayerType_QuadHeadLocked. Instead, use ovrLayerType_Quad with ovrLayerFlag_HeadLocked.
  1063. ovrLayerType_EyeMatrix = 5, ///< Described by ovrLayerEyeMatrix.
  1064. ovrLayerType_Direct = 6, ///< Described by ovrLayerDirect. Passthrough for debugging and custom rendering.
  1065. ovrLayerType_EnumSize = 0x7fffffff ///< Force type int32_t.
  1066. } ovrLayerType;
  1067. /// Identifies flags used by ovrLayerHeader and which are passed to ovr_SubmitFrame.
  1068. ///
  1069. /// \see ovrLayerHeader
  1070. ///
  1071. typedef enum ovrLayerFlags_
  1072. {
  1073. /// ovrLayerFlag_HighQuality mode costs performance, but looks better.
  1074. ovrLayerFlag_HighQuality = 0x01,
  1075. /// ovrLayerFlag_TextureOriginAtBottomLeft: the opposite is TopLeft.
  1076. /// Generally this is false for D3D, true for OpenGL.
  1077. ovrLayerFlag_TextureOriginAtBottomLeft = 0x02,
  1078. /// Mark this surface as "headlocked", which means it is specified
  1079. /// relative to the HMD and moves with it, rather than being specified
  1080. /// relative to sensor/torso space and remaining still while the head moves.
  1081. /// ovrLayerType_QuadHeadLocked is now ovrLayerType_Quad plus this flag.
  1082. /// However the flag can be applied to any layer type except ovrLayerType_Direct
  1083. /// to achieve a similar effect.
  1084. ovrLayerFlag_HeadLocked = 0x04
  1085. } ovrLayerFlags;
  1086. /// Defines properties shared by all ovrLayer structs, such as ovrLayerEyeFov.
  1087. ///
  1088. /// ovrLayerHeader is used as a base member in these larger structs.
  1089. /// This struct cannot be used by itself except for the case that Type is ovrLayerType_Disabled.
  1090. ///
  1091. /// \see ovrLayerType, ovrLayerFlags
  1092. ///
  1093. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerHeader_
  1094. {
  1095. ovrLayerType Type; ///< Described by ovrLayerType.
  1096. unsigned Flags; ///< Described by ovrLayerFlags.
  1097. } ovrLayerHeader;
  1098. /// Describes a layer that specifies a monoscopic or stereoscopic view.
  1099. /// This is the kind of layer that's typically used as layer 0 to ovr_SubmitFrame,
  1100. /// as it is the kind of layer used to render a 3D stereoscopic view.
  1101. ///
  1102. /// Three options exist with respect to mono/stereo texture usage:
  1103. /// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, respectively.
  1104. /// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively.
  1105. /// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is NULL,
  1106. /// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0].
  1107. /// - ColorTexture[0] contains a single monoscopic rendering, and Viewport[0] and
  1108. /// Viewport[1] both refer to that rendering.
  1109. ///
  1110. /// \see ovrSwapTextureSet, ovr_SubmitFrame
  1111. ///
  1112. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeFov_
  1113. {
  1114. /// Header.Type must be ovrLayerType_EyeFov.
  1115. ovrLayerHeader Header;
  1116. /// ovrSwapTextureSets for the left and right eye respectively.
  1117. /// The second one of which can be NULL for cases described above.
  1118. ovrSwapTextureSet* ColorTexture[ovrEye_Count];
  1119. /// Specifies the ColorTexture sub-rect UV coordinates.
  1120. /// Both Viewport[0] and Viewport[1] must be valid.
  1121. ovrRecti Viewport[ovrEye_Count];
  1122. /// The viewport field of view.
  1123. ovrFovPort Fov[ovrEye_Count];
  1124. /// Specifies the position and orientation of each eye view, with the position specified in meters.
  1125. /// RenderPose will typically be the value returned from ovr_CalcEyePoses,
  1126. /// but can be different in special cases if a different head pose is used for rendering.
  1127. ovrPosef RenderPose[ovrEye_Count];
  1128. /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose)
  1129. /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds
  1130. /// around the instant the application calls ovr_GetTrackingState
  1131. /// The main purpose for this is to accurately track app tracking latency.
  1132. double SensorSampleTime;
  1133. } ovrLayerEyeFov;
  1134. /// Describes a layer that specifies a monoscopic or stereoscopic view,
  1135. /// with depth textures in addition to color textures. This is typically used to support
  1136. /// positional time warp. This struct is the same as ovrLayerEyeFov, but with the addition
  1137. /// of DepthTexture and ProjectionDesc.
  1138. ///
  1139. /// ProjectionDesc can be created using ovrTimewarpProjectionDesc_FromProjection.
  1140. ///
  1141. /// Three options exist with respect to mono/stereo texture usage:
  1142. /// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, respectively.
  1143. /// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively.
  1144. /// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is NULL,
  1145. /// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0].
  1146. /// - ColorTexture[0] contains a single monoscopic rendering, and Viewport[0] and
  1147. /// Viewport[1] both refer to that rendering.
  1148. ///
  1149. /// \see ovrSwapTextureSet, ovr_SubmitFrame
  1150. ///
  1151. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeFovDepth_
  1152. {
  1153. /// Header.Type must be ovrLayerType_EyeFovDepth.
  1154. ovrLayerHeader Header;
  1155. /// ovrSwapTextureSets for the left and right eye respectively.
  1156. /// The second one of which can be NULL for cases described above.
  1157. ovrSwapTextureSet* ColorTexture[ovrEye_Count];
  1158. /// Specifies the ColorTexture sub-rect UV coordinates.
  1159. /// Both Viewport[0] and Viewport[1] must be valid.
  1160. ovrRecti Viewport[ovrEye_Count];
  1161. /// The viewport field of view.
  1162. ovrFovPort Fov[ovrEye_Count];
  1163. /// Specifies the position and orientation of each eye view, with the position specified in meters.
  1164. /// RenderPose will typically be the value returned from ovr_CalcEyePoses,
  1165. /// but can be different in special cases if a different head pose is used for rendering.
  1166. ovrPosef RenderPose[ovrEye_Count];
  1167. /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose)
  1168. /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds
  1169. /// around the instant the application calls ovr_GetTrackingState
  1170. /// The main purpose for this is to accurately track app tracking latency.
  1171. double SensorSampleTime;
  1172. /// Depth texture for positional timewarp.
  1173. /// Must map 1:1 to the ColorTexture.
  1174. ovrSwapTextureSet* DepthTexture[ovrEye_Count];
  1175. /// Specifies how to convert DepthTexture information into meters.
  1176. /// \see ovrTimewarpProjectionDesc_FromProjection
  1177. ovrTimewarpProjectionDesc ProjectionDesc;
  1178. } ovrLayerEyeFovDepth;
  1179. /// Describes a layer that specifies a monoscopic or stereoscopic view.
  1180. /// This uses a direct 3x4 matrix to map from view space to the UV coordinates.
  1181. /// It is essentially the same thing as ovrLayerEyeFov but using a much
  1182. /// lower level. This is mainly to provide compatibility with specific apps.
  1183. /// Unless the application really requires this flexibility, it is usually better
  1184. /// to use ovrLayerEyeFov.
  1185. ///
  1186. /// Three options exist with respect to mono/stereo texture usage:
  1187. /// - ColorTexture[0] and ColorTexture[1] contain the left and right stereo renderings, respectively.
  1188. /// Viewport[0] and Viewport[1] refer to ColorTexture[0] and ColorTexture[1], respectively.
  1189. /// - ColorTexture[0] contains both the left and right renderings, ColorTexture[1] is NULL,
  1190. /// and Viewport[0] and Viewport[1] refer to sub-rects with ColorTexture[0].
  1191. /// - ColorTexture[0] contains a single monoscopic rendering, and Viewport[0] and
  1192. /// Viewport[1] both refer to that rendering.
  1193. ///
  1194. /// \see ovrSwapTextureSet, ovr_SubmitFrame
  1195. ///
  1196. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerEyeMatrix_
  1197. {
  1198. /// Header.Type must be ovrLayerType_EyeMatrix.
  1199. ovrLayerHeader Header;
  1200. /// ovrSwapTextureSets for the left and right eye respectively.
  1201. /// The second one of which can be NULL for cases described above.
  1202. ovrSwapTextureSet* ColorTexture[ovrEye_Count];
  1203. /// Specifies the ColorTexture sub-rect UV coordinates.
  1204. /// Both Viewport[0] and Viewport[1] must be valid.
  1205. ovrRecti Viewport[ovrEye_Count];
  1206. /// Specifies the position and orientation of each eye view, with the position specified in meters.
  1207. /// RenderPose will typically be the value returned from ovr_CalcEyePoses,
  1208. /// but can be different in special cases if a different head pose is used for rendering.
  1209. ovrPosef RenderPose[ovrEye_Count];
  1210. /// Specifies the mapping from a view-space vector
  1211. /// to a UV coordinate on the textures given above.
  1212. /// P = (x,y,z,1)*Matrix
  1213. /// TexU = P.x/P.z
  1214. /// TexV = P.y/P.z
  1215. ovrMatrix4f Matrix[ovrEye_Count];
  1216. /// Specifies the timestamp when the source ovrPosef (used in calculating RenderPose)
  1217. /// was sampled from the SDK. Typically retrieved by calling ovr_GetTimeInSeconds
  1218. /// around the instant the application calls ovr_GetTrackingState
  1219. /// The main purpose for this is to accurately track app tracking latency.
  1220. double SensorSampleTime;
  1221. } ovrLayerEyeMatrix;
  1222. /// Describes a layer of Quad type, which is a single quad in world or viewer space.
  1223. /// It is used for both ovrLayerType_Quad. This type of layer represents a single
  1224. /// object placed in the world and not a stereo view of the world itself.
  1225. ///
  1226. /// A typical use of ovrLayerType_Quad is to draw a television screen in a room
  1227. /// that for some reason is more convenient to draw as a layer than as part of the main
  1228. /// view in layer 0. For example, it could implement a 3D popup GUI that is drawn at a
  1229. /// higher resolution than layer 0 to improve fidelity of the GUI.
  1230. ///
  1231. /// Quad layers are visible from both sides; they are not back-face culled.
  1232. ///
  1233. /// \see ovrSwapTextureSet, ovr_SubmitFrame
  1234. ///
  1235. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerQuad_
  1236. {
  1237. /// Header.Type must be ovrLayerType_Quad.
  1238. ovrLayerHeader Header;
  1239. /// Contains a single image, never with any stereo view.
  1240. ovrSwapTextureSet* ColorTexture;
  1241. /// Specifies the ColorTexture sub-rect UV coordinates.
  1242. ovrRecti Viewport;
  1243. /// Position and orientation of the center of the quad. Position is specified in meters.
  1244. ovrPosef QuadPoseCenter;
  1245. /// Width and height (respectively) of the quad in meters.
  1246. ovrVector2f QuadSize;
  1247. } ovrLayerQuad;
  1248. /// Describes a layer which is copied to the HMD as-is. Neither distortion, time warp,
  1249. /// nor vignetting is applied to ColorTexture before it's copied to the HMD. The application
  1250. /// can, however implement these kinds of effects itself before submitting the layer.
  1251. /// This layer can be used for application-based distortion rendering and can also be
  1252. /// used for implementing a debug HUD that's viewed on the mirror texture.
  1253. ///
  1254. /// \see ovrSwapTextureSet, ovr_SubmitFrame
  1255. ///
  1256. typedef struct OVR_ALIGNAS(OVR_PTR_SIZE) ovrLayerDirect_
  1257. {
  1258. /// Header.Type must be ovrLayerType_EyeDirect.
  1259. ovrLayerHeader Header;
  1260. /// ovrSwapTextureSets for the left and right eye respectively.
  1261. /// The second one of which can be NULL for cases described above.
  1262. ovrSwapTextureSet* ColorTexture[ovrEye_Count];
  1263. /// Specifies the ColorTexture sub-rect UV coordinates.
  1264. /// Both Viewport[0] and Viewport[1] must be valid.
  1265. ovrRecti Viewport[ovrEye_Count];
  1266. } ovrLayerDirect;
  1267. /// Union that combines ovrLayer types in a way that allows them
  1268. /// to be used in a polymorphic way.
  1269. typedef union ovrLayer_Union_
  1270. {
  1271. ovrLayerHeader Header;
  1272. ovrLayerEyeFov EyeFov;
  1273. ovrLayerEyeFovDepth EyeFovDepth;
  1274. ovrLayerQuad Quad;
  1275. ovrLayerDirect Direct;
  1276. } ovrLayer_Union;
  1277. //@}
  1278. /// @name SDK Distortion Rendering
  1279. ///
  1280. /// All of rendering functions including the configure and frame functions
  1281. /// are not thread safe. It is OK to use ConfigureRendering on one thread and handle
  1282. /// frames on another thread, but explicit synchronization must be done since
  1283. /// functions that depend on configured state are not reentrant.
  1284. ///
  1285. /// These functions support rendering of distortion by the SDK.
  1286. ///
  1287. //@{
  1288. // TextureSet creation is rendering API-specific, so the ovr_CreateSwapTextureSetXX
  1289. // methods can be found in the rendering API-specific headers, such as OVR_CAPI_D3D.h and OVR_CAPI_GL.h
  1290. /// Destroys an ovrSwapTextureSet and frees all the resources associated with it.
  1291. ///
  1292. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1293. /// \param[in] textureSet Specifies the ovrSwapTextureSet to destroy. If it is NULL then this function has no effect.
  1294. ///
  1295. /// \see ovr_CreateSwapTextureSetD3D11, ovr_CreateSwapTextureSetGL
  1296. ///
  1297. OVR_PUBLIC_FUNCTION(void) ovr_DestroySwapTextureSet(ovrSession session, ovrSwapTextureSet* textureSet);
  1298. /// Destroys a mirror texture previously created by one of the mirror texture creation functions.
  1299. ///
  1300. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1301. /// \param[in] mirrorTexture Specifies the ovrTexture to destroy. If it is NULL then this function has no effect.
  1302. ///
  1303. /// \see ovr_CreateMirrorTextureD3D11, ovr_CreateMirrorTextureGL
  1304. ///
  1305. OVR_PUBLIC_FUNCTION(void) ovr_DestroyMirrorTexture(ovrSession session, ovrTexture* mirrorTexture);
  1306. /// Calculates the recommended viewport size for rendering a given eye within the HMD
  1307. /// with a given FOV cone.
  1308. ///
  1309. /// Higher FOV will generally require larger textures to maintain quality.
  1310. /// Apps packing multiple eye views together on the same texture should ensure there are
  1311. /// at least 8 pixels of padding between them to prevent texture filtering and chromatic
  1312. /// aberration causing images to leak between the two eye views.
  1313. ///
  1314. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1315. /// \param[in] eye Specifies which eye (left or right) to calculate for.
  1316. /// \param[in] fov Specifies the ovrFovPort to use.
  1317. /// \param[in] pixelsPerDisplayPixel Specifies the ratio of the number of render target pixels
  1318. /// to display pixels at the center of distortion. 1.0 is the default value. Lower
  1319. /// values can improve performance, higher values give improved quality.
  1320. /// \return Returns the texture width and height size.
  1321. ///
  1322. OVR_PUBLIC_FUNCTION(ovrSizei) ovr_GetFovTextureSize(ovrSession session, ovrEyeType eye, ovrFovPort fov,
  1323. float pixelsPerDisplayPixel);
  1324. /// Computes the distortion viewport, view adjust, and other rendering parameters for
  1325. /// the specified eye.
  1326. ///
  1327. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1328. /// \param[in] eyeType Specifies which eye (left or right) for which to perform calculations.
  1329. /// \param[in] fov Specifies the ovrFovPort to use.
  1330. /// \return Returns the computed ovrEyeRenderDesc for the given eyeType and field of view.
  1331. ///
  1332. /// \see ovrEyeRenderDesc
  1333. ///
  1334. OVR_PUBLIC_FUNCTION(ovrEyeRenderDesc) ovr_GetRenderDesc(ovrSession session,
  1335. ovrEyeType eyeType, ovrFovPort fov);
  1336. /// Submits layers for distortion and display.
  1337. ///
  1338. /// ovr_SubmitFrame triggers distortion and processing which might happen asynchronously.
  1339. /// The function will return when there is room in the submission queue and surfaces
  1340. /// are available. Distortion might or might not have completed.
  1341. ///
  1342. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1343. ///
  1344. /// \param[in] frameIndex Specifies the targeted application frame index, or 0 to refer to one frame
  1345. /// after the last time ovr_SubmitFrame was called.
  1346. ///
  1347. /// \param[in] viewScaleDesc Provides additional information needed only if layerPtrList contains
  1348. /// a ovrLayerType_Quad. If NULL, a default version is used based on the current configuration and a 1.0 world scale.
  1349. ///
  1350. /// \param[in] layerPtrList Specifies a list of ovrLayer pointers, which can include NULL entries to
  1351. /// indicate that any previously shown layer at that index is to not be displayed.
  1352. /// Each layer header must be a part of a layer structure such as ovrLayerEyeFov or ovrLayerQuad,
  1353. /// with Header.Type identifying its type. A NULL layerPtrList entry in the array indicates the
  1354. // absence of the given layer.
  1355. ///
  1356. /// \param[in] layerCount Indicates the number of valid elements in layerPtrList. The maximum
  1357. /// supported layerCount is not currently specified, but may be specified in a future version.
  1358. ///
  1359. /// - Layers are drawn in the order they are specified in the array, regardless of the layer type.
  1360. ///
  1361. /// - Layers are not remembered between successive calls to ovr_SubmitFrame. A layer must be
  1362. /// specified in every call to ovr_SubmitFrame or it won't be displayed.
  1363. ///
  1364. /// - If a layerPtrList entry that was specified in a previous call to ovr_SubmitFrame is
  1365. /// passed as NULL or is of type ovrLayerType_Disabled, that layer is no longer displayed.
  1366. ///
  1367. /// - A layerPtrList entry can be of any layer type and multiple entries of the same layer type
  1368. /// are allowed. No layerPtrList entry may be duplicated (i.e. the same pointer as an earlier entry).
  1369. ///
  1370. /// <b>Example code</b>
  1371. /// \code{.cpp}
  1372. /// ovrLayerEyeFov layer0;
  1373. /// ovrLayerQuad layer1;
  1374. /// ...
  1375. /// ovrLayerHeader* layers[2] = { &layer0.Header, &layer1.Header };
  1376. /// ovrResult result = ovr_SubmitFrame(hmd, frameIndex, nullptr, layers, 2);
  1377. /// \endcode
  1378. ///
  1379. /// \return Returns an ovrResult for which OVR_SUCCESS(result) is false upon error and true
  1380. /// upon one of the possible success values:
  1381. /// - ovrSuccess: rendering completed successfully.
  1382. /// - ovrSuccess_NotVisible: rendering completed successfully but was not displayed on the HMD,
  1383. /// usually because another application currently has ownership of the HMD. Applications receiving
  1384. /// this result should stop rendering new content, but continue to call ovr_SubmitFrame periodically
  1385. /// until it returns a value other than ovrSuccess_NotVisible.
  1386. /// - ovrError_DisplayLost: The session has become invalid (such as due to a device removal)
  1387. /// and the shared resources need to be released (ovr_DestroySwapTextureSet), the session needs to
  1388. /// destroyed (ovr_Destroy) and recreated (ovr_Create), and new resources need to be created
  1389. /// (ovr_CreateSwapTextureSetXXX). The application's existing private graphics resources do not
  1390. /// need to be recreated unless the new ovr_Create call returns a different GraphicsLuid.
  1391. ///
  1392. /// \see ovr_GetPredictedDisplayTime, ovrViewScaleDesc, ovrLayerHeader
  1393. ///
  1394. OVR_PUBLIC_FUNCTION(ovrResult) ovr_SubmitFrame(ovrSession session, long long frameIndex,
  1395. const ovrViewScaleDesc* viewScaleDesc,
  1396. ovrLayerHeader const * const * layerPtrList, unsigned int layerCount);
  1397. ///@}
  1398. //-------------------------------------------------------------------------------------
  1399. /// @name Frame Timing
  1400. ///
  1401. //@{
  1402. /// Gets the time of the specified frame midpoint.
  1403. ///
  1404. /// Predicts the time at which the given frame will be displayed. The predicted time
  1405. /// is the middle of the time period during which the corresponding eye images will
  1406. /// be displayed.
  1407. ///
  1408. /// The application should increment frameIndex for each successively targeted frame,
  1409. /// and pass that index to any relevent OVR functions that need to apply to the frame
  1410. /// identified by that index.
  1411. ///
  1412. /// This function is thread-safe and allows for multiple application threads to target
  1413. /// their processing to the same displayed frame.
  1414. ///
  1415. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1416. /// \param[in] frameIndex Identifies the frame the caller wishes to target.
  1417. /// A value of zero returns the next frame index.
  1418. /// \return Returns the absolute frame midpoint time for the given frameIndex.
  1419. /// \see ovr_GetTimeInSeconds
  1420. ///
  1421. OVR_PUBLIC_FUNCTION(double) ovr_GetPredictedDisplayTime(ovrSession session, long long frameIndex);
  1422. /// Returns global, absolute high-resolution time in seconds.
  1423. ///
  1424. /// The time frame of reference for this function is not specified and should not be
  1425. /// depended upon.
  1426. ///
  1427. /// \return Returns seconds as a floating point value.
  1428. /// \see ovrPoseStatef, ovrSensorData, ovrFrameTiming
  1429. ///
  1430. OVR_PUBLIC_FUNCTION(double) ovr_GetTimeInSeconds();
  1431. /// Performance HUD enables the HMD user to see information critical to
  1432. /// the real-time operation of the VR application such as latency timing,
  1433. /// and CPU & GPU performance metrics
  1434. ///
  1435. /// App can toggle performance HUD modes as such:
  1436. /// \code{.cpp}
  1437. /// ovrPerfHudMode PerfHudMode = ovrPerfHud_LatencyTiming;
  1438. /// ovr_SetInt(Hmd, OVR_PERF_HUD_MODE, (int)PerfHudMode);
  1439. /// \endcode
  1440. ///
  1441. typedef enum ovrPerfHudMode_
  1442. {
  1443. ovrPerfHud_Off = 0, ///< Turns off the performance HUD
  1444. ovrPerfHud_LatencyTiming = 1, ///< Shows latency related timing info
  1445. ovrPerfHud_RenderTiming = 2, ///< Shows CPU & GPU timing info
  1446. ovrPerfHud_PerfHeadroom = 3, ///< Shows available performance headroom in a "consumer-friendly" way
  1447. ovrPerfHud_VersionInfo = 4, ///< Shows SDK Version Info
  1448. ovrPerfHud_Count, ///< \internal Count of enumerated elements.
  1449. ovrPerfHud_EnumSize = 0x7fffffff ///< \internal Force type int32_t.
  1450. } ovrPerfHudMode;
  1451. /// Layer HUD enables the HMD user to see information about a layer
  1452. ///
  1453. /// App can toggle layer HUD modes as such:
  1454. /// \code{.cpp}
  1455. /// ovrLayerHudMode LayerHudMode = ovrLayerHud_Info;
  1456. /// ovr_SetInt(Hmd, OVR_LAYER_HUD_MODE, (int)LayerHudMode);
  1457. /// \endcode
  1458. ///
  1459. typedef enum ovrLayerHudMode_
  1460. {
  1461. ovrLayerHud_Off = 0, ///< Turns off the layer HUD
  1462. ovrLayerHud_Info = 1, ///< Shows info about a specific layer
  1463. ovrLayerHud_EnumSize = 0x7fffffff
  1464. } ovrLayerHudMode;
  1465. ///@}
  1466. /// Debug HUD is provided to help developers gauge and debug the fidelity of their app's
  1467. /// stereo rendering characteristics. Using the provided quad and crosshair guides,
  1468. /// the developer can verify various aspects such as VR tracking units (e.g. meters),
  1469. /// stereo camera-parallax properties (e.g. making sure objects at infinity are rendered
  1470. /// with the proper separation), measuring VR geometry sizes and distances and more.
  1471. ///
  1472. /// App can toggle the debug HUD modes as such:
  1473. /// \code{.cpp}
  1474. /// ovrDebugHudStereoMode DebugHudMode = ovrDebugHudStereo_QuadWithCrosshair;
  1475. /// ovr_SetInt(Hmd, OVR_DEBUG_HUD_STEREO_MODE, (int)DebugHudMode);
  1476. /// \endcode
  1477. ///
  1478. /// The app can modify the visual properties of the stereo guide (i.e. quad, crosshair)
  1479. /// using the ovr_SetFloatArray function. For a list of tweakable properties,
  1480. /// see the OVR_DEBUG_HUD_STEREO_GUIDE_* keys in the OVR_CAPI_Keys.h header file.
  1481. typedef enum ovrDebugHudStereoMode_
  1482. {
  1483. ovrDebugHudStereo_Off = 0, ///< Turns off the Stereo Debug HUD
  1484. ovrDebugHudStereo_Quad = 1, ///< Renders Quad in world for Stereo Debugging
  1485. ovrDebugHudStereo_QuadWithCrosshair = 2, ///< Renders Quad+crosshair in world for Stereo Debugging
  1486. ovrDebugHudStereo_CrosshairAtInfinity = 3, ///< Renders screen-space crosshair at infinity for Stereo Debugging
  1487. ovrDebugHudStereo_Count, ///< \internal Count of enumerated elements
  1488. ovrDebugHudStereo_EnumSize = 0x7fffffff ///< \internal Force type int32_t
  1489. } ovrDebugHudStereoMode;
  1490. /// Should be called when the headset is placed on a new user.
  1491. /// Previously named ovrHmd_ResetOnlyBackOfHeadTrackingForConnectConf.
  1492. ///
  1493. /// This may be removed in a future SDK version.
  1494. ///
  1495. OVR_PUBLIC_FUNCTION(void) ovr_ResetBackOfHeadTracking(ovrSession session);
  1496. /// Should be called when a tracking camera is moved.
  1497. ///
  1498. /// This may be removed in a future SDK version.
  1499. ///
  1500. OVR_PUBLIC_FUNCTION(void) ovr_ResetMulticameraTracking(ovrSession session);
  1501. // -----------------------------------------------------------------------------------
  1502. /// @name Property Access
  1503. ///
  1504. /// These functions read and write OVR properties. Supported properties
  1505. /// are defined in OVR_CAPI_Keys.h
  1506. ///
  1507. //@{
  1508. /// Reads a boolean property.
  1509. ///
  1510. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1511. /// \param[in] propertyName The name of the property, which needs to be valid for only the call.
  1512. /// \param[in] defaultVal specifes the value to return if the property couldn't be read.
  1513. /// \return Returns the property interpreted as a boolean value. Returns defaultVal if
  1514. /// the property doesn't exist.
  1515. OVR_PUBLIC_FUNCTION(ovrBool) ovr_GetBool(ovrSession session, const char* propertyName, ovrBool defaultVal);
  1516. /// Writes or creates a boolean property.
  1517. /// If the property wasn't previously a boolean property, it is changed to a boolean property.
  1518. ///
  1519. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1520. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1521. /// \param[in] value The value to write.
  1522. /// \return Returns true if successful, otherwise false. A false result should only occur if the property
  1523. /// name is empty or if the property is read-only.
  1524. OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetBool(ovrSession session, const char* propertyName, ovrBool value);
  1525. /// Reads an integer property.
  1526. ///
  1527. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1528. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1529. /// \param[in] defaultVal Specifes the value to return if the property couldn't be read.
  1530. /// \return Returns the property interpreted as an integer value. Returns defaultVal if
  1531. /// the property doesn't exist.
  1532. OVR_PUBLIC_FUNCTION(int) ovr_GetInt(ovrSession session, const char* propertyName, int defaultVal);
  1533. /// Writes or creates an integer property.
  1534. ///
  1535. /// If the property wasn't previously a boolean property, it is changed to an integer property.
  1536. ///
  1537. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1538. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1539. /// \param[in] value The value to write.
  1540. /// \return Returns true if successful, otherwise false. A false result should only occur if the property
  1541. /// name is empty or if the property is read-only.
  1542. OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetInt(ovrSession session, const char* propertyName, int value);
  1543. /// Reads a float property.
  1544. ///
  1545. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1546. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1547. /// \param[in] defaultVal specifes the value to return if the property couldn't be read.
  1548. /// \return Returns the property interpreted as an float value. Returns defaultVal if
  1549. /// the property doesn't exist.
  1550. OVR_PUBLIC_FUNCTION(float) ovr_GetFloat(ovrSession session, const char* propertyName, float defaultVal);
  1551. /// Writes or creates a float property.
  1552. /// If the property wasn't previously a float property, it's changed to a float property.
  1553. ///
  1554. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1555. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1556. /// \param[in] value The value to write.
  1557. /// \return Returns true if successful, otherwise false. A false result should only occur if the property
  1558. /// name is empty or if the property is read-only.
  1559. OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetFloat(ovrSession session, const char* propertyName, float value);
  1560. /// Reads a float array property.
  1561. ///
  1562. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1563. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1564. /// \param[in] values An array of float to write to.
  1565. /// \param[in] valuesCapacity Specifies the maximum number of elements to write to the values array.
  1566. /// \return Returns the number of elements read, or 0 if property doesn't exist or is empty.
  1567. OVR_PUBLIC_FUNCTION(unsigned int) ovr_GetFloatArray(ovrSession session, const char* propertyName,
  1568. float values[], unsigned int valuesCapacity);
  1569. /// Writes or creates a float array property.
  1570. ///
  1571. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1572. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1573. /// \param[in] values An array of float to write from.
  1574. /// \param[in] valuesSize Specifies the number of elements to write.
  1575. /// \return Returns true if successful, otherwise false. A false result should only occur if the property
  1576. /// name is empty or if the property is read-only.
  1577. OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetFloatArray(ovrSession session, const char* propertyName,
  1578. const float values[], unsigned int valuesSize);
  1579. /// Reads a string property.
  1580. /// Strings are UTF8-encoded and null-terminated.
  1581. ///
  1582. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1583. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1584. /// \param[in] defaultVal Specifes the value to return if the property couldn't be read.
  1585. /// \return Returns the string property if it exists. Otherwise returns defaultVal, which can be specified as NULL.
  1586. /// The return memory is guaranteed to be valid until next call to ovr_GetString or
  1587. /// until the HMD is destroyed, whichever occurs first.
  1588. OVR_PUBLIC_FUNCTION(const char*) ovr_GetString(ovrSession session, const char* propertyName,
  1589. const char* defaultVal);
  1590. /// Writes or creates a string property.
  1591. /// Strings are UTF8-encoded and null-terminated.
  1592. ///
  1593. /// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
  1594. /// \param[in] propertyName The name of the property, which needs to be valid only for the call.
  1595. /// \param[in] value The string property, which only needs to be valid for the duration of the call.
  1596. /// \return Returns true if successful, otherwise false. A false result should only occur if the property
  1597. /// name is empty or if the property is read-only.
  1598. OVR_PUBLIC_FUNCTION(ovrBool) ovr_SetString(ovrSession session, const char* propertyName,
  1599. const char* value);
  1600. ///@}
  1601. #ifdef __cplusplus
  1602. } // extern "C"
  1603. #endif
  1604. #if defined(_MSC_VER)
  1605. #pragma warning(pop)
  1606. #endif
  1607. /// @cond DoxygenIgnore
  1608. //-----------------------------------------------------------------------------
  1609. // ***** Compiler packing validation
  1610. //
  1611. // These checks ensure that the compiler settings being used will be compatible
  1612. // with with pre-built dynamic library provided with the runtime.
  1613. OVR_STATIC_ASSERT(sizeof(ovrBool) == 1, "ovrBool size mismatch");
  1614. OVR_STATIC_ASSERT(sizeof(ovrVector2i) == 4 * 2, "ovrVector2i size mismatch");
  1615. OVR_STATIC_ASSERT(sizeof(ovrSizei) == 4 * 2, "ovrSizei size mismatch");
  1616. OVR_STATIC_ASSERT(sizeof(ovrRecti) == sizeof(ovrVector2i) + sizeof(ovrSizei), "ovrRecti size mismatch");
  1617. OVR_STATIC_ASSERT(sizeof(ovrQuatf) == 4 * 4, "ovrQuatf size mismatch");
  1618. OVR_STATIC_ASSERT(sizeof(ovrVector2f) == 4 * 2, "ovrVector2f size mismatch");
  1619. OVR_STATIC_ASSERT(sizeof(ovrVector3f) == 4 * 3, "ovrVector3f size mismatch");
  1620. OVR_STATIC_ASSERT(sizeof(ovrMatrix4f) == 4 * 16, "ovrMatrix4f size mismatch");
  1621. OVR_STATIC_ASSERT(sizeof(ovrPosef) == (7 * 4), "ovrPosef size mismatch");
  1622. OVR_STATIC_ASSERT(sizeof(ovrPoseStatef) == (22 * 4), "ovrPoseStatef size mismatch");
  1623. OVR_STATIC_ASSERT(sizeof(ovrFovPort) == (4 * 4), "ovrFovPort size mismatch");
  1624. OVR_STATIC_ASSERT(sizeof(ovrHmdCaps) == 4, "ovrHmdCaps size mismatch");
  1625. OVR_STATIC_ASSERT(sizeof(ovrTrackingCaps) == 4, "ovrTrackingCaps size mismatch");
  1626. OVR_STATIC_ASSERT(sizeof(ovrEyeType) == 4, "ovrEyeType size mismatch");
  1627. OVR_STATIC_ASSERT(sizeof(ovrHmdType) == 4, "ovrHmdType size mismatch");
  1628. OVR_STATIC_ASSERT(sizeof(ovrSensorData) == (11 * 4), "ovrSensorData size mismatch");
  1629. OVR_STATIC_ASSERT(sizeof(ovrTrackingState) ==
  1630. sizeof(ovrPoseStatef) * 3 + 4 + 2 * sizeof(ovrPosef) + sizeof(ovrSensorData) + 4 * 4,
  1631. "ovrTrackingState size mismatch");
  1632. OVR_STATIC_ASSERT(sizeof(ovrRenderAPIType) == 4, "ovrRenderAPIType size mismatch");
  1633. OVR_STATIC_ASSERT(sizeof(ovrTextureHeader) == sizeof(ovrRenderAPIType) + sizeof(ovrSizei),
  1634. "ovrTextureHeader size mismatch");
  1635. OVR_STATIC_ASSERT(sizeof(ovrTexture) == sizeof(ovrTextureHeader) OVR_ON64(+4) + sizeof(uintptr_t) * 8,
  1636. "ovrTexture size mismatch");
  1637. OVR_STATIC_ASSERT(sizeof(ovrStatusBits) == 4, "ovrStatusBits size mismatch");
  1638. OVR_STATIC_ASSERT(sizeof(ovrSessionStatus) == 2, "ovrSessionStatus size mismatch");
  1639. OVR_STATIC_ASSERT(sizeof(ovrEyeRenderDesc) == sizeof(ovrEyeType) + sizeof(ovrFovPort) + sizeof(ovrRecti) +
  1640. sizeof(ovrVector2f) + sizeof(ovrVector3f),
  1641. "ovrEyeRenderDesc size mismatch");
  1642. OVR_STATIC_ASSERT(sizeof(ovrTimewarpProjectionDesc) == 4 * 3, "ovrTimewarpProjectionDesc size mismatch");
  1643. OVR_STATIC_ASSERT(sizeof(ovrInitFlags) == 4, "ovrInitFlags size mismatch");
  1644. OVR_STATIC_ASSERT(sizeof(ovrLogLevel) == 4, "ovrLogLevel size mismatch");
  1645. OVR_STATIC_ASSERT(sizeof(ovrInitParams) == 4 + 4 + sizeof(ovrLogCallback) + sizeof(uintptr_t) + 4 + 4,
  1646. "ovrInitParams size mismatch");
  1647. OVR_STATIC_ASSERT(sizeof(ovrHmdDesc) ==
  1648. + sizeof(ovrHmdType) // Type
  1649. OVR_ON64(+ 4) // pad0
  1650. + 64 // ProductName
  1651. + 64 // Manufacturer
  1652. + 2 // VendorId
  1653. + 2 // ProductId
  1654. + 24 // SerialNumber
  1655. + 2 // FirmwareMajor
  1656. + 2 // FirmwareMinor
  1657. + 4 * 4 // CameraFrustumHFovInRadians - CameraFrustumFarZInMeters
  1658. + 4 * 4 // AvailableHmdCaps - DefaultTrackingCaps
  1659. + sizeof(ovrFovPort) * 2 // DefaultEyeFov
  1660. + sizeof(ovrFovPort) * 2 // MaxEyeFov
  1661. + sizeof(ovrSizei) // Resolution
  1662. + 4 // DisplayRefreshRate
  1663. OVR_ON64(+ 4) // pad1
  1664. , "ovrHmdDesc size mismatch");
  1665. // -----------------------------------------------------------------------------------
  1666. // ***** Backward compatibility #includes
  1667. //
  1668. // This is at the bottom of this file because the following is dependent on the
  1669. // declarations above.
  1670. #if !defined(OVR_CAPI_NO_UTILS)
  1671. #include "Extras/OVR_CAPI_Util.h"
  1672. #endif
  1673. /// @endcond
  1674. #endif // OVR_CAPI_h