-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoovr_noimpl.go
1575 lines (1399 loc) · 64.8 KB
/
goovr_noimpl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// +build !windows
package goovr
/*
#cgo CXXFLAGS: -std=c++11
*/
import "C"
import (
"errors"
)
var errNoImpl = errors.New("OVR not implemented on this platform")
/// A 2D vector with integer components.
type Vector2i struct {
X, Y int
}
/// A 2D size with integer components.
type Sizei struct {
W, H int
}
/// A 2D rectangle with a position and size.
/// All components are integers.
type Recti struct {
Pos Vector2i
Size Sizei
}
/// A quaternion rotation.
type Quatf struct {
X, Y, Z, W float32
}
/// A 2D vector with float components.
type Vector2f struct {
X, Y float32
}
/// A 3D vector with float components.
type Vector3f struct {
X, Y, Z float32
}
/// A 4x4 matrix with float elements.
type Matrix4f struct {
M [4][4]float32
}
/// Position and orientation together.
type Posef struct {
Orientation Quatf
Position Vector3f
}
/// A full pose (rigid body) configuration with first and second derivatives.
///
/// Body refers to any object for which ovrPoseStatef is providing data.
/// It can be the HMD, Touch controller, sensor or something else. The context
/// depends on the usage of the struct.
type PoseStatef struct {
ThePose Posef //< Position and orientation.
AngularVelocity Vector3f //< Angular velocity in radians per second.
LinearVelocity Vector3f //< Velocity in meters per second.
AngularAcceleration Vector3f //< Angular acceleration in radians per second per second.
LinearAcceleration Vector3f //< Acceleration in meters per second per second.
TimeInSeconds float64 //< Absolute time of this state sample.
}
/// Describes the up, down, left, and right angles of the field of view.
///
/// Field Of View (FOV) tangent of the angle units.
/// \note For a standard 90 degree vertical FOV, we would
/// have: { UpTan = tan(90 degrees / 2), DownTan = tan(90 degrees / 2) }.
type FovPort struct {
UpTan float32 //< The tangent of the angle between the viewing vector and the top edge of the field of view.
DownTan float32 //< The tangent of the angle between the viewing vector and the bottom edge of the field of view.
LeftTan float32 //< The tangent of the angle between the viewing vector and the left edge of the field of view.
RightTan float32 //< The tangent of the angle between the viewing vector and the right edge of the field of view.
}
/// Enumerates all HMD types that we support.
///
/// The currently released developer kits are ovrHmd_DK1 and ovrHmd_DK2. The other enumerations are for internal use only.
type HmdType int32
const (
Hmd_None HmdType = 0
Hmd_DK1
Hmd_DKHD
Hmd_DK2
Hmd_CB
Hmd_Other
Hmd_E3_2015
Hmd_ES06
Hmd_ES09
Hmd_ES11
Hmd_CV1
)
/// HMD capability bits reported by device.
///
type HmdCaps int32
const (
HmdCap_DebugDevice HmdCaps = 0 ///< <B>(read only)</B> Specifies that the HMD is a virtual debug device.
)
/// Tracking capability bits reported by the device.
/// Used with ovr_GetTrackingCaps.
type TrackingCaps int32
const (
TrackingCap_Orientation TrackingCaps = 0 ///< Supports orientation tracking (IMU).
TrackingCap_MagYawCorrection ///< Supports yaw drift correction via a magnetometer or other means.
TrackingCap_Position ///< Supports positional tracking.
)
/// Specifies which eye is being used for rendering.
/// This type explicitly does not include a third "NoStereo" monoscopic option, as such is
/// not required for an HMD-centered API.
type EyeType int32
const (
Eye_Left EyeType = 0 ///< The left eye, from the viewer's perspective.
Eye_Right ///< The right eye, from the viewer's perspective.
Eye_Count ///< \internal Count of enumerated elements.
)
/// Specifies the coordinate system ovrTrackingState returns tracking poses in.
/// Used with ovr_SetTrackingOriginType()
type TrackingOrigin int32
const (
/// \brief Tracking system origin reported at eye (HMD) height
/// \details Prefer using this origin when your application requires
/// matching user's current physical head pose to a virtual head pose
/// without any regards to a the height of the floor. Cockpit-based,
/// or 3rd-person experiences are ideal candidates.
/// When used, all poses in ovrTrackingState are reported as an offset
/// transform from the profile calibrated or recentered HMD pose.
/// It is recommended that apps using this origin type call ovr_RecenterTrackingOrigin
/// prior to starting the VR experience, but notify the user before doing so
/// to make sure the user is in a comfortable pose, facing a comfortable
/// direction.
TrackingOrigin_EyeLevel TrackingOrigin = 0
/// \brief Tracking system origin reported at floor height
/// \details Prefer using this origin when your application requires the
/// physical floor height to match the virtual floor height, such as
/// standing experiences.
/// When used, all poses in ovrTrackingState are reported as an offset
/// transform from the profile calibrated floor pose. Calling ovr_RecenterTrackingOrigin
/// will recenter the X & Z axes as well as yaw, but the Y-axis (i.e. height) will continue
/// to be reported using the floor height as the origin for all poses.
TrackingOrigin_FloorLevel
TrackingOrigin_Count ///< \internal Count of enumerated elements.
)
/// Identifies a graphics device in a platform-specific way.
/// For Windows this is a LUID type.
type GraphicsLuid struct {
Reserved [8]byte
}
/// This is a complete descriptor of the HMD.
type HmdDesc struct {
Type HmdType
ProductName string
Manufacturer string
VendorId int16
ProductId int16
SerialNumber [24]byte
FirmwareMajor int16
FirmwareMinor int16
AvailableHmdCaps HmdCaps
DefaultHmdCaps HmdCaps
AvailableTrackingCaps TrackingCaps
DefaultTrackingCaps TrackingCaps
DefaultEyeFov [Eye_Count]FovPort
MaxEyeFov [Eye_Count]FovPort
Resolution Sizei
DisplayRefreshRate float32
}
/// Used as an opaque pointer to an OVR session.
type Session struct {
}
/// Bit flags describing the current status of sensor tracking.
/// The values must be the same as in enum StatusBits
///
/// \see ovrTrackingState
type StatusBits int32
const (
Status_OrientationTracked StatusBits = 0 ///< Orientation is currently tracked (connected and in use).
Status_PositionTracked ///< Position is currently tracked (false if out of range).
)
/// Specifies the description of a single sensor.
///
/// \see ovrGetTrackerDesc
type TrackerDesc struct {
FrustumHFovInRadians float32
FrustumVFovInRadians float32
FrustumNearZInMeters float32
FrustumFarZInMeters float32
}
/// Specifies sensor flags.
///
/// /see ovrTrackerPose
type TrackerFlags int32
const (
Tracker_Connected TrackerFlags = 0 ///< The sensor is present, else the sensor is absent or offline.
Tracker_PoseTracked ///< The sensor has a valid pose, else the pose is unavailable. This will only be set if ovrTracker_Connected is set.
)
/// Specifies the pose for a single sensor.
type TrackerPose struct {
TrackerFlags uint32 ///< ovrTrackerFlags.
Pose Posef ///< The sensor's pose. This pose includes sensor tilt (roll and pitch). For a leveled coordinate system use LeveledPose.
LeveledPose Posef ///< The sensor's leveled pose, aligned with gravity. This value includes position and yaw of the sensor, but not roll and pitch. It can be used as a reference point to render real-world objects in the correct location.
}
/// Tracking state at a given absolute time (describes predicted HMD pose, etc.).
/// Returned by ovr_GetTrackingState.
///
/// \see ovr_GetTrackingState
type TrackingState struct {
/// Predicted head pose (and derivatives) at the requested absolute time.
HeadPose PoseStatef
/// HeadPose tracking status described by ovrStatusBits.
StatusFlags StatusBits
/// The most recent calculated pose for each hand when hand controller tracking is present.
/// HandPoses[ovrHand_Left] refers to the left hand and HandPoses[ovrHand_Right] to the right hand.
/// These values can be combined with ovrInputState for complete hand controller information.
HandPoses [2]PoseStatef
/// HandPoses status flags described by ovrStatusBits.
/// Only ovrStatus_OrientationTracked and ovrStatus_PositionTracked are reported.
HandStatusFlags [2]StatusBits
/// The pose of the origin captured during calibration.
/// Like all other poses here, this is expressed in the space set by ovr_RecenterTrackingOrigin,
/// and so will change every time that is called. This pose can be used to calculate
/// where the calibrated origin lands in the new recentered space.
/// If an application never calls ovr_RecenterTrackingOrigin, expect this value to be the identity
/// pose and as such will point respective origin based on ovrTrackingOrigin requested when
/// calling ovr_GetTrackingState.
CalibratedOrigin Posef
}
/// Rendering information for each eye. Computed by ovr_GetRenderDesc() based on the
/// specified FOV. Note that the rendering viewport is not included
/// here as it can be specified separately and modified per frame by
/// passing different Viewport values in the layer structure.
///
/// \see ovr_GetRenderDesc
type EyeRenderDesc struct {
Eye EyeType ///< The eye index to which this instance corresponds.
Fov FovPort ///< The field of view.
DistortedViewport Recti ///< Distortion viewport.
PixelsPerTanAngleAtCenter Vector2f ///< How many display pixels will fit in tan(angle) = 1.
HmdToEyeOffset Vector3f ///< Translation of each eye, in meters.
}
/// Projection information for ovrLayerEyeFovDepth.
///
/// Use the utility function ovrTimewarpProjectionDesc_FromProjection to
/// generate this structure from the application's projection matrix.
///
/// \see ovrLayerEyeFovDepth, ovrTimewarpProjectionDesc_FromProjection
type TimewarpProjectionDesc struct {
Projection22 float32 ///< Projection matrix element [2][2].
Projection23 float32 ///< Projection matrix element [2][3].
Projection32 float32 ///< Projection matrix element [3][2].
}
/// Contains the data necessary to properly calculate position info for various layer types.
/// - HmdToEyeOffset is the same value pair provided in ovrEyeRenderDesc.
/// - HmdSpaceToWorldScaleInMeters is used to scale player motion into in-application units.
/// In other words, it is how big an in-application unit is in the player's physical meters.
/// For example, if the application uses inches as its units then HmdSpaceToWorldScaleInMeters would be 0.0254.
/// Note that if you are scaling the player in size, this must also scale. So if your application
/// units are inches, but you're shrinking the player to half their normal size, then
/// HmdSpaceToWorldScaleInMeters would be 0.0254*2.0.
///
/// \see ovrEyeRenderDesc, ovr_SubmitFrame
type ViewScaleDesc struct {
HmdToEyeOffset [Eye_Count]Vector3f ///< Translation of each eye.
HmdSpaceToWorldScaleInMeters float32 ///< Ratio of viewer units to meter units.
}
/// The type of texture resource.
///
/// \see ovrTextureSwapChainDesc
type TextureType int32
const (
Texture_2D TextureType = 0 ///< 2D textures.
Texture_2D_External ///< External 2D texture. Not used on PC
Texture_Cube ///< Cube maps. Not currently supported on PC.
Texture_Count
)
/// The bindings required for texture swap chain.
///
/// All texture swap chains are automatically bindable as shader
/// input resources since the Oculus runtime needs this to read them.
///
/// \see ovrTextureSwapChainDesc
type TextureBindFlags int32
const (
TextureBind_None TextureBindFlags = 0
TextureBind_DX_RenderTarget ///< The application can write into the chain with pixel shader
TextureBind_DX_UnorderedAccess ///< The application can write to the chain with compute shader
TextureBind_DX_DepthStencil ///< The chain buffers can be bound as depth and/or stencil buffers
)
/// The format of a texture.
///
/// \see ovrTextureSwapChainDesc
type TextureFormat int32
const (
FORMAT_UNKNOWN TextureFormat = 0
FORMAT_B5G6R5_UNORM ///< Not currently supported on PC. Would require a DirectX 11.1 device.
FORMAT_B5G5R5A1_UNORM ///< Not currently supported on PC. Would require a DirectX 11.1 device.
FORMAT_B4G4R4A4_UNORM ///< Not currently supported on PC. Would require a DirectX 11.1 device.
FORMAT_R8G8B8A8_UNORM
FORMAT_R8G8B8A8_UNORM_SRGB
FORMAT_B8G8R8A8_UNORM
FORMAT_B8G8R8A8_UNORM_SRGB ///< Not supported for OpenGL applications
FORMAT_B8G8R8X8_UNORM ///< Not supported for OpenGL applications
FORMAT_B8G8R8X8_UNORM_SRGB ///< Not supported for OpenGL applications
FORMAT_R16G16B16A16_FLOAT
FORMAT_D16_UNORM
FORMAT_D24_UNORM_S8_UINT
FORMAT_D32_FLOAT
FORMAT_D32_FLOAT_S8X24_UINT
)
/// Misc flags overriding particular
/// behaviors of a texture swap chain
///
/// \see ovrTextureSwapChainDesc
type TextureMiscFlags int32
const (
TextureMisc_None TextureMiscFlags = 0
/// DX only: The underlying texture is created with a TYPELESS equivalent of the
/// format specified in the texture desc. The SDK will still access the
/// texture using the format specified in the texture desc, but the app can
/// create views with different formats if this is specified.
TextureMisc_DX_Typeless
/// DX only: Allow generation of the mip chain on the GPU via the GenerateMips
/// call. This flag requires that RenderTarget binding also be specified.
TextureMisc_AllowGenerateMips
)
/// Description used to create a texture swap chain.
///
/// \see ovr_CreateTextureSwapChainDX
/// \see ovr_CreateTextureSwapChainGL
type TextureSwapChainDesc struct {
Typ TextureType
Format TextureFormat
ArraySize int ///< Only supported with ovrTexture_2D. Not supported on PC at this time.
Width int
Height int
MipLevels int
SampleCount int ///< Current only supported on depth textures
StaticImage bool ///< Not buffered in a chain. For images that don't change
MiscFlags TextureMiscFlags ///< ovrTextureMiscFlags
BindFlags TextureBindFlags ///< ovrTextureBindFlags. Not used for GL.
}
/// Description used to create a mirror texture.
///
/// \see ovr_CreateMirrorTextureDX
/// \see ovr_CreateMirrorTextureGL
type MirrorTextureDesc struct {
Format TextureFormat
Width int
Height int
MiscFlags TextureMiscFlags ///< ovrTextureMiscFlags
}
type TextureSwapChain struct {
}
type MirrorTexture struct {
}
/// Describes button input types.
/// Button inputs are combined; that is they will be reported as pressed if they are
/// pressed on either one of the two devices.
/// The ovrButton_Up/Down/Left/Right map to both XBox D-Pad and directional buttons.
/// The ovrButton_Enter and ovrButton_Return map to Start and Back controller buttons, respectively.
type Button int
const (
Button_A Button = 0
Button_B
Button_RThumb
Button_RShoulder
// Bit mask of all buttons on the right Touch controller
Button_RMask
Button_X
Button_Y
Button_LThumb
Button_LShoulder
// Bit mask of all buttons on the left Touch controller
Button_LMask
// Navigation through DPad.
Button_Up
Button_Down
Button_Left
Button_Right
Button_Enter // Start on XBox controller.
Button_Back // Back on Xbox controller.
Button_VolUp // only supported by Remote.
Button_VolDown // only supported by Remote.
Button_Home
Button_Private
)
/// Describes touch input types.
/// These values map to capacitive touch values reported ovrInputState::Touch.
/// Some of these values are mapped to button bits for consistency.
type Touch int
const (
Touch_A Touch = 0
Touch_B
Touch_RThumb
Touch_RIndexTrigger
// Bit mask of all buttons on the right Touch controller
Touch_RButtonMask
Touch_X
Touch_Y
Touch_LThumb
Touch_LIndexTrigger
// Bit mask of all the button touches on the left controller
Touch_LButtonMask
// Finger pose state
// Derived internally based on distance, proximity to sensors and filtering.
Touch_RIndexPointing
Touch_RThumbUp
// Bit mask of all right controller poses
Touch_RPoseMask
Touch_LIndexPointing
Touch_LThumbUp
// Bit mask of all left controller poses
Touch_LPoseMask
)
/// Specifies which controller is connected; multiple can be connected at once.
type ControllerType int
const (
ControllerType_None ControllerType = 0
ControllerType_LTouch
ControllerType_RTouch
ControllerType_Touch
ControllerType_Remote
ControllerType_XBox
ControllerType_Active ///< Operate on or query whichever controller is active.
)
/// Provides names for the left and right hand array indexes.
///
/// \see ovrInputState, ovrTrackingState
type HandType int
const (
Hand_Left HandType = 0
Hand_Right
Hand_Count
)
/// ovrInputState describes the complete controller input state, including Oculus Touch,
/// and XBox gamepad. If multiple inputs are connected and used at the same time,
/// their inputs are combined.
type InputState struct {
// System type when the controller state was last updated.
TimeInSeconds float64
// Values for buttons described by ovrButton.
Buttons Button
// Touch values for buttons and sensors as described by ovrTouch.
Touches Touch
// Left and right finger trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f.
IndexTrigger [2]float32
// Left and right hand trigger values (ovrHand_Left and ovrHand_Right), in the range 0.0 to 1.0f.
HandTrigger [2]float32
// Horizontal and vertical thumbstick axis values (ovrHand_Left and ovrHand_Right), in the range -1.0f to 1.0f.
Thumbstick [2]Vector2f
// The type of the controller this state is for.
ControllerType ControllerType
}
/// Initialization flags.
///
/// \see ovrInitParams, ovr_Initialize
type InitFlags int32
const (
/// When a debug library is requested, a slower debugging version of the library will
/// run which can be used to help solve problems in the library and debug application code.
Init_Debug InitFlags = 0
/// When a version is requested, the LibOVR runtime respects the RequestedMinorVersion
/// field and verifies that the RequestedMinorVersion is supported.
Init_RequestVersion
// These bits are writable by user code.
Init_WritableBits
)
/// Logging levels
///
/// \see ovrInitParams, ovrLogCallback
type LogLevel int32
const (
LogLevel_Debug LogLevel = 0 ///< Debug-level log event.
LogLevel_Info ///< Info-level log event.
LogLevel_Error ///< Error-level log event.
)
/// Signature of the logging callback function pointer type.
///
/// \param[in] userData is an arbitrary value specified by the user of ovrInitParams.
/// \param[in] level is one of the ovrLogLevel constants.
/// \param[in] message is a UTF8-encoded null-terminated string.
/// \see ovrInitParams, ovrLogLevel, ovr_Initialize
type LogCallback func(userData uintptr, level int, message string)
/// Parameters for ovr_Initialize.
///
/// \see ovr_Initialize
type InitParams struct {
/// Flags from ovrInitFlags to override default behavior.
/// Use 0 for the defaults.
Flags InitFlags
/// Requests a specific minimum minor version of the LibOVR runtime.
/// Flags must include ovrInit_RequestVersion or this will be ignored
/// and OVR_MINOR_VERSION will be used.
RequestedMinorVersion uint32
/// User-supplied log callback function, which may be called at any time
/// asynchronously from multiple threads until ovr_Shutdown completes.
/// Use NULL to specify no log callback.
LogCallback LogCallback
/// User-supplied data which is passed as-is to LogCallback. Typically this
/// is used to store an application-specific pointer which is read in the
/// callback function.
UserData uintptr
/// Relative number of milliseconds to wait for a connection to the server
/// before failing. Use 0 for the default timeout.
ConnectionTimeoutMS uint32
}
// -----------------------------------------------------------------------------------
// ***** API Interfaces
// Overview of the API
//
// Setup:
// - ovr_Initialize().
// - ovr_Create(&hmd, &graphicsId).
// - Use hmd members and ovr_GetFovTextureSize() to determine graphics configuration
// and ovr_GetRenderDesc() to get per-eye rendering parameters.
// - Allocate texture swap chains with ovr_CreateTextureSwapChainDX() or
// ovr_CreateTextureSwapChainGL(). Create any associated render target views or
// frame buffer objects.
//
// Application Loop:
// - Call ovr_GetPredictedDisplayTime() to get the current frame timing information.
// - Call ovr_GetTrackingState() and ovr_CalcEyePoses() to obtain the predicted
// rendering pose for each eye based on timing.
// - Render the scene content into the current buffer of the texture swapchains
// for each eye and layer you plan to update this frame. If you render into a
// texture swap chain, you must call ovr_CommitTextureSwapChain() on it to commit
// the changes before you reference the chain this frame (otherwise, your latest
// changes won't be picked up).
// - Call ovr_SubmitFrame() to render the distorted layers to and present them on the HMD.
// If ovr_SubmitFrame returns ovrSuccess_NotVisible, there is no need to render the scene
// for the next loop iteration. Instead, just call ovr_SubmitFrame again until it returns
// ovrSuccess.
//
// Shutdown:
// - ovr_Destroy().
// - ovr_Shutdown().
/// Initializes LibOVR
///
/// Initialize LibOVR for application usage. This includes finding and loading the LibOVRRT
/// shared library. No LibOVR API functions, other than ovr_GetLastErrorInfo, can be called
/// unless ovr_Initialize succeeds. A successful call to ovr_Initialize must be eventually
/// followed by a call to ovr_Shutdown. ovr_Initialize calls are idempotent.
/// Calling ovr_Initialize twice does not require two matching calls to ovr_Shutdown.
/// If already initialized, the return value is ovr_Success.
///
/// LibOVRRT shared library search order:
/// -# Current working directory (often the same as the application directory).
/// -# Module directory (usually the same as the application directory,
/// but not if the module is a separate shared library).
/// -# Application directory
/// -# Development directory (only if OVR_ENABLE_DEVELOPER_SEARCH is enabled,
/// which is off by default).
/// -# Standard OS shared library search location(s) (OS-specific).
///
/// \param params Specifies custom initialization options. May be NULL to indicate default options.
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
/// ovr_GetLastErrorInfo to get more information. Example failed results include:
/// - ovrError_Initialize: Generic initialization error.
/// - ovrError_LibLoad: Couldn't load LibOVRRT.
/// - ovrError_LibVersion: LibOVRRT version incompatibility.
/// - ovrError_ServiceConnection: Couldn't connect to the OVR Service.
/// - ovrError_ServiceVersion: OVR Service version incompatibility.
/// - ovrError_IncompatibleOS: The operating system version is incompatible.
/// - ovrError_DisplayInit: Unable to initialize the HMD display.
/// - ovrError_ServerStart: Unable to start the server. Is it already running?
/// - ovrError_Reinitialization: Attempted to re-initialize with a different version.
///
/// <b>Example code</b>
/// \code{.cpp}
/// ovrResult result = ovr_Initialize(NULL);
/// if(OVR_FAILURE(result)) {
/// ovrErrorInfo errorInfo;
/// ovr_GetLastErrorInfo(&errorInfo);
/// DebugLog("ovr_Initialize failed: %s", errorInfo.ErrorString);
/// return false;
/// }
/// [...]
/// \endcode
///
/// \see ovr_Shutdown
func Initialize(params *InitParams) error {
return errNoImpl
}
/// Shuts down LibOVR
///
/// A successful call to ovr_Initialize must be eventually matched by a call to ovr_Shutdown.
/// After calling ovr_Shutdown, no LibOVR functions can be called except ovr_GetLastErrorInfo
/// or another ovr_Initialize. ovr_Shutdown invalidates all pointers, references, and created objects
/// previously returned by LibOVR functions. The LibOVRRT shared library can be unloaded by
/// ovr_Shutdown.
///
/// \see ovr_Initialize
func Shutdown() {
}
/// Returns information about the most recent failed return value by the
/// current thread for this library.
///
/// This function itself can never generate an error.
/// The last error is never cleared by LibOVR, but will be overwritten by new errors.
/// Do not use this call to determine if there was an error in the last API
/// call as successful API calls don't clear the last ovrErrorInfo.
/// To avoid any inconsistency, ovr_GetLastErrorInfo should be called immediately
/// after an API function that returned a failed ovrResult, with no other API
/// functions called in the interim.
///
/// \param[out] errorInfo The last ovrErrorInfo for the current thread.
///
/// \see ovrErrorInfo
func GetLastErrorInfo() ErrorInfo {
return ErrorInfo{}
}
/// Returns the version string representing the LibOVRRT version.
///
/// The returned string pointer is valid until the next call to ovr_Shutdown.
///
/// Note that the returned version string doesn't necessarily match the current
/// OVR_MAJOR_VERSION, etc., as the returned string refers to the LibOVRRT shared
/// library version and not the locally compiled interface version.
///
/// The format of this string is subject to change in future versions and its contents
/// should not be interpreted.
///
/// \return Returns a UTF8-encoded null-terminated version string.
func GetVersionString() string {
return ""
}
/// Writes a message string to the LibOVR tracing mechanism (if enabled).
///
/// This message will be passed back to the application via the ovrLogCallback if
/// it was registered.
///
/// \param[in] level One of the ovrLogLevel constants.
/// \param[in] message A UTF8-encoded null-terminated string.
/// \return returns the strlen of the message or a negative value if the message is too large.
///
/// \see ovrLogLevel, ovrLogCallback
func TraceMessage(level int, message string) (int, error) {
return 0, errNoImpl
}
/// Returns information about the current HMD.
///
/// ovr_Initialize must have first been called in order for this to succeed, otherwise ovrHmdDesc::Type
/// will be reported as ovrHmd_None.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create, else NULL in which
/// case this function detects whether an HMD is present and returns its info if so.
///
/// \return Returns an ovrHmdDesc. If the hmd is NULL and ovrHmdDesc::Type is ovrHmd_None then
/// no HMD is present.
func (s *Session) GetHmdDesc() *HmdDesc {
return nil
}
/// Returns the number of sensors.
///
/// The number of sensors may change at any time, so this function should be called before use
/// as opposed to once on startup.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
///
/// \return Returns unsigned int count.
func (s *Session) GetTrackerCount() uint {
return 0
}
/// Returns a given sensor description.
///
/// It's possible that sensor desc [0] may indicate a unconnnected or non-pose tracked sensor, but
/// sensor desc [1] may be connected.
///
/// ovr_Initialize must have first been called in order for this to succeed, otherwise the returned
/// trackerDescArray will be zero-initialized. The data returned by this function can change at runtime.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
///
/// \param[in] trackerDescIndex Specifies a sensor index. The valid indexes are in the range of 0 to
/// the sensor count returned by ovr_GetTrackerCount.
///
/// \return Returns ovrTrackerDesc. An empty ovrTrackerDesc will be returned if trackerDescIndex is out of range.
///
/// \see ovrTrackerDesc, ovr_GetTrackerCount
func (s *Session) GetTrackerDesc(trackerDescIndex uint) TrackerDesc {
return TrackerDesc{}
}
/// Creates a handle to a VR session.
///
/// Upon success the returned ovrSession must be eventually freed with ovr_Destroy when it is no longer needed.
/// A second call to ovr_Create will result in an error return value if the previous Hmd has not been destroyed.
///
/// \param[out] pSession Provides a pointer to an ovrSession which will be written to upon success.
/// \param[out] luid Provides a system specific graphics adapter identifier that locates which
/// graphics adapter has the HMD attached. This must match the adapter used by the application
/// or no rendering output will be possible. This is important for stability on multi-adapter systems. An
/// application that simply chooses the default adapter will not run reliably on multi-adapter systems.
/// \return Returns an ovrResult indicating success or failure. Upon failure
/// the returned pHmd will be NULL.
///
/// <b>Example code</b>
/// \code{.cpp}
/// ovrSession session;
/// ovrGraphicsLuid luid;
/// ovrResult result = ovr_Create(&session, &luid);
/// if(OVR_FAILURE(result))
/// ...
/// \endcode
///
/// \see ovr_Destroy
func Create(pLuid *GraphicsLuid) (*Session, error) {
return nil, errNoImpl
}
/// Destroys the HMD.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
/// \see ovr_Create
func (s *Session) Destroy() {
}
/// Specifies status information for the current session.
///
/// \see ovr_GetSessionStatus
type SessionStatus struct {
IsVisible bool ///< True if the process has VR focus and thus is visible in the HMD.
HmdPresent bool ///< True if an HMD is present.
HmdMounted bool ///< True if the HMD is on the user's head.
DisplayLost bool ///< True if the session is in a display-lost state. See ovr_SubmitFrame.
ShouldQuit bool ///< True if the application should initiate shutdown.
ShouldRecenter bool ///< True if UX has requested re-centering. Must call ovr_ClearShouldRecenterFlag or ovr_RecenterTrackingOrigin.
}
/// Returns status information for the application.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
/// \param[out] sessionStatus Provides an ovrSessionStatus that is filled in.
///
/// \return Returns an ovrResult indicating success or failure. In the case of
/// failure, use ovr_GetLastErrorInfo to get more information.
// Return values include but aren't limited to:
/// - ovrSuccess: Completed successfully.
/// - ovrError_ServiceConnection: The service connection was lost and the application
// must destroy the session.
func (s *Session) GetSessionStatus() (SessionStatus, error) {
return SessionStatus{}, errNoImpl
}
/// Sets the tracking origin type
///
/// When the tracking origin is changed, all of the calls that either provide
/// or accept ovrPosef will use the new tracking origin provided.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
/// \param[in] origin Specifies an ovrTrackingOrigin to be used for all ovrPosef
///
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
/// ovr_GetLastErrorInfo to get more information.
///
/// \see ovrTrackingOrigin, ovr_GetTrackingOriginType
func (s *Session) SetTrackingOriginType(origin TrackingOrigin) {
}
/// Gets the tracking origin state
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
///
/// \return Returns the ovrTrackingOrigin that was either set by default, or previous set by the application.
///
/// \see ovrTrackingOrigin, ovr_SetTrackingOriginType
func (s *Session) GetTrackingOriginType() TrackingOrigin {
return 0
}
/// Re-centers the sensor position and orientation.
///
/// This resets the (x,y,z) positional components and the yaw orientation component.
/// The Roll and pitch orientation components are always determined by gravity and cannot
/// be redefined. All future tracking will report values relative to this new reference position.
/// If you are using ovrTrackerPoses then you will need to call ovr_GetTrackerPose after
/// this, because the sensor position(s) will change as a result of this.
///
/// The headset cannot be facing vertically upward or downward but rather must be roughly
/// level otherwise this function will fail with ovrError_InvalidHeadsetOrientation.
///
/// For more info, see the notes on each ovrTrackingOrigin enumeration to understand how
/// recenter will vary slightly in its behavior based on the current ovrTrackingOrigin setting.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
///
/// \return Returns an ovrResult indicating success or failure. In the case of failure, use
/// ovr_GetLastErrorInfo to get more information. Return values include but aren't limited to:
/// - ovrSuccess: Completed successfully.
/// - ovrError_InvalidHeadsetOrientation: The headset was facing an invalid direction when
/// attempting recentering, such as facing vertically.
///
/// \see ovrTrackingOrigin, ovr_GetTrackerPose
func (s *Session) RecenterTrackingOrigin() error {
return errNoImpl
}
/// Clears the ShouldRecenter status bit in ovrSessionStatus.
///
/// Clears the ShouldRecenter status bit in ovrSessionStatus, allowing further recenter
/// requests to be detected. Since this is automatically done by ovr_RecenterTrackingOrigin,
/// this is only needs to be called when application is doing its own re-centering.
func (s *Session) ClearShouldRecenterFlag() {
}
/// Returns tracking state reading based on the specified absolute system time.
///
/// Pass an absTime value of 0.0 to request the most recent sensor reading. In this case
/// both PredictedPose and SamplePose will have the same value.
///
/// This may also be used for more refined timing of front buffer rendering logic, and so on.
/// This may be called by multiple threads.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
/// \param[in] absTime Specifies the absolute future time to predict the return
/// ovrTrackingState value. Use 0 to request the most recent tracking state.
/// \param[in] latencyMarker Specifies that this call is the point in time where
/// the "App-to-Mid-Photon" latency timer starts from. If a given ovrLayer
/// provides "SensorSampleTimestamp", that will override the value stored here.
/// \return Returns the ovrTrackingState that is predicted for the given absTime.
///
/// \see ovrTrackingState, ovr_GetEyePoses, ovr_GetTimeInSeconds
func (s *Session) GetTrackingState(absTime float64, latencyMarker bool) TrackingState {
return TrackingState{}
}
/// Returns the ovrTrackerPose for the given sensor.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
/// \param[in] trackerPoseIndex Index of the sensor being requested.
///
/// \return Returns the requested ovrTrackerPose. An empty ovrTrackerPose will be returned if trackerPoseIndex is out of range.
///
/// \see ovr_GetTrackerCount
///
func (s *Session) GetTrackerPose(trackerPoseIndex uint) TrackerPose {
return TrackerPose{}
}
/// Returns the most recent input state for controllers, without positional tracking info.
///
/// \param[out] inputState Input state that will be filled in.
/// \param[in] ovrControllerType Specifies which controller the input will be returned for.
/// \return Returns ovrSuccess if the new state was successfully obtained.
///
/// \see ovrControllerType
func (s *Session) GetInputState(controllerType ControllerType) (InputState, error) {
return InputState{}, errNoImpl
}
/// Returns controller types connected to the system OR'ed together.
///
/// \return A bitmask of ovrControllerTypes connected to the system.
///
/// \see ovrControllerType
func (s *Session) GetConnectedControllerTypes() uint {
return 0
}
/// Turns on vibration of the given controller.
///
/// To disable vibration, call ovr_SetControllerVibration with an amplitude of 0.
/// Vibration automatically stops after a nominal amount of time, so if you want vibration
/// to be continuous over multiple seconds then you need to call this function periodically.
///
/// \param[in] session Specifies an ovrSession previously returned by ovr_Create.
/// \param[in] controllerType Specifies the controller to apply the vibration to.
/// \param[in] frequency Specifies a vibration frequency in the range of 0.0 to 1.0.
/// Currently the only valid values are 0.0, 0.5, and 1.0 and other values will
/// be clamped to one of these.
/// \param[in] amplitude Specifies a vibration amplitude in the range of 0.0 to 1.0.
///
/// \return Returns ovrSuccess upon success.
///
/// \see ovrControllerType
func (s *Session) SetControllerVibration(controllerType ControllerType, frequency, amplitude float32) error {
return errNoImpl
}
/// Specifies the maximum number of layers supported by ovr_SubmitFrame.
///
/// /see ovr_SubmitFrame
const MaxLayerCount = 0
/// Describes layer types that can be passed to ovr_SubmitFrame.
/// Each layer type has an associated struct, such as ovrLayerEyeFov.
///
/// \see ovrLayerHeader
type LayerType int32
const (
LayerType_Disabled LayerType = 0 ///< Layer is disabled.
LayerType_EyeFov ///< Described by ovrLayerEyeFov.
LayerType_Quad ///< Described by ovrLayerQuad. Previously called ovrLayerType_QuadInWorld.
/// enum 4 used to be ovrLayerType_QuadHeadLocked. Instead, use ovrLayerType_Quad with ovrLayerFlag_HeadLocked.
LayerType_EyeMatrix ///< Described by ovrLayerEyeMatrix.
)
/// Identifies flags used by ovrLayerHeader and which are passed to ovr_SubmitFrame.
///
/// \see ovrLayerHeader
type LayerFlags int32