openxr 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/AUTHORS +1 -0
- data/CHANGES.md +7 -0
- data/CREDITS.md +2 -0
- data/README.md +64 -0
- data/UNLICENSE +24 -0
- data/VERSION +1 -0
- data/lib/openxr.rb +33 -0
- data/lib/openxr/abi.rb +492 -0
- data/lib/openxr/action.rb +12 -0
- data/lib/openxr/action_set.rb +12 -0
- data/lib/openxr/api.rb +90 -0
- data/lib/openxr/extension.rb +73 -0
- data/lib/openxr/handle.rb +15 -0
- data/lib/openxr/instance.rb +70 -0
- data/lib/openxr/layer.rb +11 -0
- data/lib/openxr/result.rb +24 -0
- data/lib/openxr/session.rb +12 -0
- data/lib/openxr/space.rb +12 -0
- data/lib/openxr/swapchain.rb +12 -0
- data/lib/openxr/system.rb +82 -0
- data/lib/openxr/version.rb +21 -0
- metadata +141 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 36abdb32c2a8c74e38219474fe86c86dc85c56d227cac9dd2e8fa5f1ddc9c846
|
4
|
+
data.tar.gz: 93069b7dd05951a389c29a07c74aa8f40ff8426c2af4e499e8643243ed01ddc0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a8a08e3cd2d31e206514d3e986cd00342504d2a9e1ab4ffcfd8cddc8cf1bb336d15719c19f40ad2cb77524be05e6676789ea8921335998d23fbd7248fd57fb6e
|
7
|
+
data.tar.gz: 0a916f590edb0d5aff013c19b54ea79c4f85cc01e682d0fbc0661708c84139e34366a4bbcf29cbf0c0ee6420faf0994de8629ec2e773933cc7fd902b677575f4
|
data/AUTHORS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* Arto Bendiken <arto@bendiken.net>
|
data/CHANGES.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Changelog
|
2
|
+
=========
|
3
|
+
|
4
|
+
All notable changes to this project will be documented in this file.
|
5
|
+
|
6
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
7
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
data/CREDITS.md
ADDED
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
OpenXR for Ruby
|
2
|
+
===============
|
3
|
+
|
4
|
+
[](https://unlicense.org)
|
5
|
+
[](https://rubygems.org/gems/openxr)
|
6
|
+
[](https://rubygems.org/gems/openxr)
|
7
|
+
|
8
|
+
**OpenXR.rb** implements Ruby bindings for [OpenXR](https://www.khronos.org/openxr/)
|
9
|
+
[1.0](https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html),
|
10
|
+
the open standard and cross-platform API for virtual reality (VR) and
|
11
|
+
augmented reality (AR) hardware.
|
12
|
+
|
13
|
+
Installation
|
14
|
+
------------
|
15
|
+
|
16
|
+
$ gem install openxr
|
17
|
+
|
18
|
+
Prerequisites
|
19
|
+
-------------
|
20
|
+
|
21
|
+
- [Ruby](https://www.ruby-lang.org/en/) 2.7+
|
22
|
+
with [FFI](https://github.com/ffi/ffi/wiki)
|
23
|
+
|
24
|
+
- [OpenXR SDK](https://github.com/KhronosGroup/OpenXR-SDK) 1.0.8+
|
25
|
+
|
26
|
+
Examples
|
27
|
+
--------
|
28
|
+
|
29
|
+
### Loading the library
|
30
|
+
|
31
|
+
require 'openxr'
|
32
|
+
|
33
|
+
### Listing extensions
|
34
|
+
|
35
|
+
OpenXR::Extension.each do |extension|
|
36
|
+
puts [extension.name, extension.version].join("\t")
|
37
|
+
end
|
38
|
+
|
39
|
+
### Creating an instance
|
40
|
+
|
41
|
+
OpenXR::Instance.create($0) do |instance|
|
42
|
+
...
|
43
|
+
end
|
44
|
+
|
45
|
+
Development
|
46
|
+
-----------
|
47
|
+
|
48
|
+
We recommend Debian 11 (aka [Bullseye](https://www.debian.org/releases/bullseye/))
|
49
|
+
as a development environment. If you're on a Mac, you can run Debian in a
|
50
|
+
virtual machine using [VMware Fusion](https://www.vmware.com/products/fusion.html)
|
51
|
+
or [VirtualBox](https://www.virtualbox.org).
|
52
|
+
|
53
|
+
Install the Debian packages for the OpenXR SDK's loader as follows:
|
54
|
+
|
55
|
+
$ apt install libopenxr-loader1
|
56
|
+
|
57
|
+
That's the only required package, but find related packages of interest using:
|
58
|
+
|
59
|
+
$ apt search openxr
|
60
|
+
|
61
|
+
In addition, you _will_ need an OpenXR runtime for your hardware. In the
|
62
|
+
absence of suitable vendor-supplied runtimes, have a look at the open-source
|
63
|
+
[Monado](https://monado.freedesktop.org) project which supports many common
|
64
|
+
devices.
|
data/UNLICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <https://unlicense.org/>
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
data/lib/openxr.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
module OpenXR; end
|
4
|
+
|
5
|
+
require_relative 'openxr/abi'
|
6
|
+
require_relative 'openxr/api'
|
7
|
+
|
8
|
+
require_relative 'openxr/action'
|
9
|
+
require_relative 'openxr/action_set'
|
10
|
+
require_relative 'openxr/extension'
|
11
|
+
require_relative 'openxr/handle'
|
12
|
+
require_relative 'openxr/instance'
|
13
|
+
require_relative 'openxr/layer'
|
14
|
+
require_relative 'openxr/result'
|
15
|
+
require_relative 'openxr/session'
|
16
|
+
require_relative 'openxr/space'
|
17
|
+
require_relative 'openxr/swapchain'
|
18
|
+
require_relative 'openxr/system'
|
19
|
+
require_relative 'openxr/version'
|
20
|
+
|
21
|
+
module OpenXR
|
22
|
+
##
|
23
|
+
# @return [Boolean]
|
24
|
+
def self.has_layers?
|
25
|
+
nil # TODO
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# @return [Boolean]
|
30
|
+
def self.has_extensions?
|
31
|
+
!!(Extension.count.nonzero?)
|
32
|
+
end
|
33
|
+
end # OpenXR
|
data/lib/openxr/abi.rb
ADDED
@@ -0,0 +1,492 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require 'ffi'
|
4
|
+
|
5
|
+
##
|
6
|
+
# The OpenXR application binary interface (ABI).
|
7
|
+
module OpenXR::ABI
|
8
|
+
##
|
9
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#api-version-numbers-and-semantics
|
10
|
+
def self.XR_MAKE_VERSION(major, minor, patch)
|
11
|
+
(((major.to_i & 0xffff) << 48) + ((minor.to_i & 0xffff) << 32) + (patch.to_i & 0xffffffff))
|
12
|
+
end
|
13
|
+
|
14
|
+
XR_CURRENT_API_VERSION = XR_MAKE_VERSION(1, 0, 8)
|
15
|
+
|
16
|
+
XrVersion = :uint64
|
17
|
+
XrFlags64 = :uint64
|
18
|
+
XrSystemId = :uint64
|
19
|
+
XrBool32 = :uint32
|
20
|
+
XrPath = :uint64
|
21
|
+
XrTime = :int64
|
22
|
+
XrDuration = :int64
|
23
|
+
|
24
|
+
class XrInstance < FFI::Struct
|
25
|
+
layout :handle, :pointer
|
26
|
+
end
|
27
|
+
|
28
|
+
class XrSession < FFI::Struct
|
29
|
+
layout :handle, :pointer
|
30
|
+
end
|
31
|
+
|
32
|
+
class XrSpace < FFI::Struct
|
33
|
+
layout :handle, :pointer
|
34
|
+
end
|
35
|
+
|
36
|
+
class XrAction < FFI::Struct
|
37
|
+
layout :handle, :pointer
|
38
|
+
end
|
39
|
+
|
40
|
+
class XrSwapchain < FFI::Struct
|
41
|
+
layout :handle, :pointer
|
42
|
+
end
|
43
|
+
|
44
|
+
class XrActionSet < FFI::Struct
|
45
|
+
layout :handle, :pointer
|
46
|
+
end
|
47
|
+
|
48
|
+
XR_TRUE = 1
|
49
|
+
XR_FALSE = 0
|
50
|
+
XR_MAX_EXTENSION_NAME_SIZE = 128
|
51
|
+
XR_MAX_API_LAYER_NAME_SIZE = 256
|
52
|
+
XR_MAX_API_LAYER_DESCRIPTION_SIZE = 256
|
53
|
+
XR_MAX_SYSTEM_NAME_SIZE = 256
|
54
|
+
XR_MAX_APPLICATION_NAME_SIZE = 128
|
55
|
+
XR_MAX_ENGINE_NAME_SIZE = 128
|
56
|
+
XR_MAX_RUNTIME_NAME_SIZE = 128
|
57
|
+
XR_MAX_PATH_LENGTH = 256
|
58
|
+
XR_MAX_STRUCTURE_NAME_SIZE = 64
|
59
|
+
XR_MAX_RESULT_STRING_SIZE = 64
|
60
|
+
XR_MIN_COMPOSITION_LAYERS_SUPPORTED = 16
|
61
|
+
XR_MAX_ACTION_SET_NAME_SIZE = 64
|
62
|
+
XR_MAX_LOCALIZED_ACTION_SET_NAME_SIZE = 128
|
63
|
+
XR_MAX_ACTION_NAME_SIZE = 64
|
64
|
+
XR_MAX_LOCALIZED_ACTION_NAME_SIZE = 128
|
65
|
+
|
66
|
+
XrResult = :int # enum
|
67
|
+
XR_SUCCESS = 0
|
68
|
+
XR_ERROR_VALIDATION_FAILURE = -1
|
69
|
+
XR_ERROR_RUNTIME_FAILURE = -2
|
70
|
+
XR_ERROR_HANDLE_INVALID = -12
|
71
|
+
|
72
|
+
XrStructureType = :int # enum
|
73
|
+
XR_TYPE_UNKNOWN = 0
|
74
|
+
XR_TYPE_API_LAYER_PROPERTIES = 1
|
75
|
+
XR_TYPE_EXTENSION_PROPERTIES = 2
|
76
|
+
XR_TYPE_INSTANCE_CREATE_INFO = 3
|
77
|
+
XR_TYPE_SYSTEM_GET_INFO = 4
|
78
|
+
XR_TYPE_SYSTEM_PROPERTIES = 5
|
79
|
+
XR_TYPE_VIEW_LOCATE_INFO = 6
|
80
|
+
XR_TYPE_VIEW = 7
|
81
|
+
XR_TYPE_SESSION_CREATE_INFO = 8
|
82
|
+
|
83
|
+
XrFormFactor = :int # enum
|
84
|
+
XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY = 1
|
85
|
+
XR_FORM_FACTOR_HANDHELD_DISPLAY = 2
|
86
|
+
XR_FORM_FACTOR_MAX_ENUM = 0x7FFFFFFF
|
87
|
+
|
88
|
+
XrInstanceCreateFlags = XrFlags64
|
89
|
+
XrSessionCreateFlags = XrFlags64
|
90
|
+
|
91
|
+
class XrBaseStructure < FFI::Struct
|
92
|
+
layout :type, XrStructureType,
|
93
|
+
:next, :pointer
|
94
|
+
end
|
95
|
+
|
96
|
+
class XrApiLayerProperties < FFI::Struct
|
97
|
+
layout :base, XrBaseStructure,
|
98
|
+
:layerName, [:char, XR_MAX_API_LAYER_NAME_SIZE],
|
99
|
+
:specVersion, XrVersion,
|
100
|
+
:layerVersion, :uint32,
|
101
|
+
:description, [:char, XR_MAX_API_LAYER_DESCRIPTION_SIZE]
|
102
|
+
end
|
103
|
+
|
104
|
+
class XrExtensionProperties < FFI::Struct
|
105
|
+
layout :base, XrBaseStructure,
|
106
|
+
:extensionName, [:char, XR_MAX_EXTENSION_NAME_SIZE],
|
107
|
+
:extensionVersion, :uint32
|
108
|
+
end
|
109
|
+
|
110
|
+
class XrApplicationInfo < FFI::Struct
|
111
|
+
layout :applicationName, [:char, XR_MAX_APPLICATION_NAME_SIZE],
|
112
|
+
:applicationVersion, :uint32,
|
113
|
+
:engineName, [:char, XR_MAX_ENGINE_NAME_SIZE],
|
114
|
+
:engineVersion, :uint32,
|
115
|
+
:apiVersion, XrVersion
|
116
|
+
end
|
117
|
+
|
118
|
+
class XrInstanceCreateInfo < FFI::Struct
|
119
|
+
layout :base, XrBaseStructure,
|
120
|
+
:createFlags, XrInstanceCreateFlags,
|
121
|
+
:applicationInfo, XrApplicationInfo,
|
122
|
+
:enabledApiLayerCount, :uint32,
|
123
|
+
:enabledApiLayerNames, :string,
|
124
|
+
:enabledExtensionCount, :uint32,
|
125
|
+
:enabledExtensionNames, :string
|
126
|
+
end
|
127
|
+
|
128
|
+
class XrInstanceProperties < FFI::Struct
|
129
|
+
layout :base, XrBaseStructure,
|
130
|
+
:runtimeVersion, XrVersion,
|
131
|
+
:runtimeName, [:char, XR_MAX_RUNTIME_NAME_SIZE]
|
132
|
+
end
|
133
|
+
|
134
|
+
class XrEventDataBuffer < FFI::Struct
|
135
|
+
layout :base, XrBaseStructure,
|
136
|
+
:varying, :uint8
|
137
|
+
end
|
138
|
+
|
139
|
+
class XrSystemGetInfo < FFI::Struct
|
140
|
+
layout :base, XrBaseStructure,
|
141
|
+
:formFactor, XrFormFactor
|
142
|
+
end
|
143
|
+
|
144
|
+
class XrSystemGraphicsProperties < FFI::Struct
|
145
|
+
layout :maxSwapchainImageHeight, :uint32,
|
146
|
+
:maxSwapchainImageWidth, :uint32,
|
147
|
+
:maxLayerCount, :uint32
|
148
|
+
end
|
149
|
+
|
150
|
+
class XrSystemTrackingProperties < FFI::Struct
|
151
|
+
layout :orientationTracking, XrBool32,
|
152
|
+
:positionTracking, XrBool32
|
153
|
+
end
|
154
|
+
|
155
|
+
class XrSystemProperties < FFI::Struct
|
156
|
+
layout :base, XrBaseStructure,
|
157
|
+
:systemId, XrSystemId,
|
158
|
+
:vendorId, :uint32,
|
159
|
+
:systemName, [:char, XR_MAX_SYSTEM_NAME_SIZE],
|
160
|
+
:graphicsProperties, XrSystemGraphicsProperties,
|
161
|
+
:trackingProperties, XrSystemTrackingProperties
|
162
|
+
end
|
163
|
+
|
164
|
+
class XrSessionCreateInfo < FFI::Struct
|
165
|
+
layout :base, XrBaseStructure,
|
166
|
+
:createFlags, XrSessionCreateFlags,
|
167
|
+
:systemId, XrSystemId
|
168
|
+
end
|
169
|
+
|
170
|
+
class XrVector3f < FFI::Struct
|
171
|
+
# TODO
|
172
|
+
end
|
173
|
+
|
174
|
+
class XrSpaceVelocity < FFI::Struct
|
175
|
+
# TODO
|
176
|
+
end
|
177
|
+
|
178
|
+
class XrQuaternionf < FFI::Struct
|
179
|
+
# TODO
|
180
|
+
end
|
181
|
+
|
182
|
+
class XrPosef < FFI::Struct
|
183
|
+
# TODO
|
184
|
+
end
|
185
|
+
|
186
|
+
class XrReferenceSpaceCreateInfo < FFI::Struct
|
187
|
+
# TODO
|
188
|
+
end
|
189
|
+
|
190
|
+
class XrExtent2Df < FFI::Struct
|
191
|
+
# TODO
|
192
|
+
end
|
193
|
+
|
194
|
+
class XrActionSpaceCreateInfo < FFI::Struct
|
195
|
+
# TODO
|
196
|
+
end
|
197
|
+
|
198
|
+
class XrSpaceLocation < FFI::Struct
|
199
|
+
# TODO
|
200
|
+
end
|
201
|
+
|
202
|
+
class XrViewConfigurationProperties < FFI::Struct
|
203
|
+
# TODO
|
204
|
+
end
|
205
|
+
|
206
|
+
class XrViewConfigurationView < FFI::Struct
|
207
|
+
# TODO
|
208
|
+
end
|
209
|
+
|
210
|
+
class XrSwapchainCreateInfo < FFI::Struct
|
211
|
+
# TODO
|
212
|
+
end
|
213
|
+
|
214
|
+
class XrSwapchainImageBaseHeader < FFI::Struct
|
215
|
+
# TODO
|
216
|
+
end
|
217
|
+
|
218
|
+
class XrSwapchainImageAcquireInfo < FFI::Struct
|
219
|
+
# TODO
|
220
|
+
end
|
221
|
+
|
222
|
+
class XrSwapchainImageWaitInfo < FFI::Struct
|
223
|
+
# TODO
|
224
|
+
end
|
225
|
+
|
226
|
+
class XrSwapchainImageReleaseInfo < FFI::Struct
|
227
|
+
# TODO
|
228
|
+
end
|
229
|
+
|
230
|
+
class XrSessionBeginInfo < FFI::Struct
|
231
|
+
# TODO
|
232
|
+
end
|
233
|
+
|
234
|
+
class XrFrameWaitInfo < FFI::Struct
|
235
|
+
# TODO
|
236
|
+
end
|
237
|
+
|
238
|
+
class XrFrameState < FFI::Struct
|
239
|
+
# TODO
|
240
|
+
end
|
241
|
+
|
242
|
+
class XrFrameBeginInfo < FFI::Struct
|
243
|
+
# TODO
|
244
|
+
end
|
245
|
+
|
246
|
+
class XrCompositionLayerBaseHeader < FFI::Struct
|
247
|
+
# TODO
|
248
|
+
end
|
249
|
+
|
250
|
+
class XrFrameEndInfo < FFI::Struct
|
251
|
+
# TODO
|
252
|
+
end
|
253
|
+
|
254
|
+
class XrViewLocateInfo < FFI::Struct
|
255
|
+
# TODO
|
256
|
+
end
|
257
|
+
|
258
|
+
class XrViewState < FFI::Struct
|
259
|
+
# TODO
|
260
|
+
end
|
261
|
+
|
262
|
+
class XrFovf < FFI::Struct
|
263
|
+
# TODO
|
264
|
+
end
|
265
|
+
|
266
|
+
class XrView < FFI::Struct
|
267
|
+
# TODO
|
268
|
+
end
|
269
|
+
|
270
|
+
class XrActionSetCreateInfo < FFI::Struct
|
271
|
+
# TODO
|
272
|
+
end
|
273
|
+
|
274
|
+
class XrActionCreateInfo < FFI::Struct
|
275
|
+
# TODO
|
276
|
+
end
|
277
|
+
|
278
|
+
class XrActionSuggestedBinding < FFI::Struct
|
279
|
+
# TODO
|
280
|
+
end
|
281
|
+
|
282
|
+
class XrInteractionProfileSuggestedBinding < FFI::Struct
|
283
|
+
# TODO
|
284
|
+
end
|
285
|
+
|
286
|
+
class XrSessionActionSetsAttachInfo < FFI::Struct
|
287
|
+
# TODO
|
288
|
+
end
|
289
|
+
|
290
|
+
class XrInteractionProfileState < FFI::Struct
|
291
|
+
# TODO
|
292
|
+
end
|
293
|
+
|
294
|
+
class XrActionStateGetInfo < FFI::Struct
|
295
|
+
# TODO
|
296
|
+
end
|
297
|
+
|
298
|
+
class XrActionStateBoolean < FFI::Struct
|
299
|
+
# TODO
|
300
|
+
end
|
301
|
+
|
302
|
+
class XrActionStateFloat < FFI::Struct
|
303
|
+
# TODO
|
304
|
+
end
|
305
|
+
|
306
|
+
class XrVector2f < FFI::Struct
|
307
|
+
# TODO
|
308
|
+
end
|
309
|
+
|
310
|
+
class XrActionStateVector2f < FFI::Struct
|
311
|
+
# TODO
|
312
|
+
end
|
313
|
+
|
314
|
+
class XrActionStatePose < FFI::Struct
|
315
|
+
# TODO
|
316
|
+
end
|
317
|
+
|
318
|
+
class XrActiveActionSet < FFI::Struct
|
319
|
+
# TODO
|
320
|
+
end
|
321
|
+
|
322
|
+
class XrActionsSyncInfo < FFI::Struct
|
323
|
+
# TODO
|
324
|
+
end
|
325
|
+
|
326
|
+
class XrBoundSourcesForActionEnumerateInfo < FFI::Struct
|
327
|
+
# TODO
|
328
|
+
end
|
329
|
+
|
330
|
+
class XrInputSourceLocalizedNameGetInfo < FFI::Struct
|
331
|
+
# TODO
|
332
|
+
end
|
333
|
+
|
334
|
+
class XrHapticActionInfo < FFI::Struct
|
335
|
+
# TODO
|
336
|
+
end
|
337
|
+
|
338
|
+
class XrHapticBaseHeader < FFI::Struct
|
339
|
+
# TODO
|
340
|
+
end
|
341
|
+
|
342
|
+
XrBaseInStructure = XrBaseStructure
|
343
|
+
XrBaseOutStructure = XrBaseStructure
|
344
|
+
|
345
|
+
class XrOffset2Di < FFI::Struct
|
346
|
+
# TODO
|
347
|
+
end
|
348
|
+
|
349
|
+
class XrExtent2Di < FFI::Struct
|
350
|
+
# TODO
|
351
|
+
end
|
352
|
+
|
353
|
+
class XrRect2Di < FFI::Struct
|
354
|
+
# TODO
|
355
|
+
end
|
356
|
+
|
357
|
+
class XrSwapchainSubImage < FFI::Struct
|
358
|
+
# TODO
|
359
|
+
end
|
360
|
+
|
361
|
+
class XrCompositionLayerProjectionView < FFI::Struct
|
362
|
+
# TODO
|
363
|
+
end
|
364
|
+
|
365
|
+
class XrCompositionLayerProjection < FFI::Struct
|
366
|
+
# TODO
|
367
|
+
end
|
368
|
+
|
369
|
+
class XrCompositionLayerQuad < FFI::Struct
|
370
|
+
# TODO
|
371
|
+
end
|
372
|
+
|
373
|
+
class XrEventDataBaseHeader < FFI::Struct
|
374
|
+
# TODO
|
375
|
+
end
|
376
|
+
|
377
|
+
class XrEventDataEventsLost < FFI::Struct
|
378
|
+
# TODO
|
379
|
+
end
|
380
|
+
|
381
|
+
class XrEventDataInstanceLossPending < FFI::Struct
|
382
|
+
# TODO
|
383
|
+
end
|
384
|
+
|
385
|
+
class XrEventDataSessionStateChanged < FFI::Struct
|
386
|
+
# TODO
|
387
|
+
end
|
388
|
+
|
389
|
+
class XrEventDataReferenceSpaceChangePending < FFI::Struct
|
390
|
+
# TODO
|
391
|
+
end
|
392
|
+
|
393
|
+
class XrEventDataInteractionProfileChanged < FFI::Struct
|
394
|
+
# TODO
|
395
|
+
end
|
396
|
+
|
397
|
+
class XrHapticVibration < FFI::Struct
|
398
|
+
# TODO
|
399
|
+
end
|
400
|
+
|
401
|
+
class XrOffset2Df < FFI::Struct
|
402
|
+
# TODO
|
403
|
+
end
|
404
|
+
|
405
|
+
class XrRect2Df < FFI::Struct
|
406
|
+
# TODO
|
407
|
+
end
|
408
|
+
|
409
|
+
class XrVector4f < FFI::Struct
|
410
|
+
# TODO
|
411
|
+
end
|
412
|
+
|
413
|
+
class XrColor4f < FFI::Struct
|
414
|
+
# TODO
|
415
|
+
end
|
416
|
+
|
417
|
+
class XrCompositionLayerCubeKHR < FFI::Struct
|
418
|
+
# TODO
|
419
|
+
end
|
420
|
+
|
421
|
+
class XrCompositionLayerDepthInfoKHR < FFI::Struct
|
422
|
+
# TODO
|
423
|
+
end
|
424
|
+
|
425
|
+
class XrCompositionLayerCylinderKHR < FFI::Struct
|
426
|
+
# TODO
|
427
|
+
end
|
428
|
+
|
429
|
+
class XrCompositionLayerEquirectKHR < FFI::Struct
|
430
|
+
# TODO
|
431
|
+
end
|
432
|
+
|
433
|
+
class XrVisibilityMaskKHR < FFI::Struct
|
434
|
+
# TODO
|
435
|
+
end
|
436
|
+
|
437
|
+
class XrEventDataVisibilityMaskChangedKHR < FFI::Struct
|
438
|
+
# TODO
|
439
|
+
end
|
440
|
+
|
441
|
+
class XrEventDataPerfSettingsEXT < FFI::Struct
|
442
|
+
# TODO
|
443
|
+
end
|
444
|
+
|
445
|
+
class XrDebugUtilsObjectNameInfoEXT < FFI::Struct
|
446
|
+
# TODO
|
447
|
+
end
|
448
|
+
|
449
|
+
class XrDebugUtilsLabelEXT < FFI::Struct
|
450
|
+
# TODO
|
451
|
+
end
|
452
|
+
|
453
|
+
class XrDebugUtilsMessengerCallbackDataEXT < FFI::Struct
|
454
|
+
# TODO
|
455
|
+
end
|
456
|
+
|
457
|
+
class XrDebugUtilsMessengerCreateInfoEXT < FFI::Struct
|
458
|
+
# TODO
|
459
|
+
end
|
460
|
+
|
461
|
+
class XrSystemEyeGazeInteractionPropertiesEXT < FFI::Struct
|
462
|
+
# TODO
|
463
|
+
end
|
464
|
+
|
465
|
+
class XrEyeGazeSampleTimeEXT < FFI::Struct
|
466
|
+
# TODO
|
467
|
+
end
|
468
|
+
|
469
|
+
class XrSessionCreateInfoOverlayEXTX < FFI::Struct
|
470
|
+
# TODO
|
471
|
+
end
|
472
|
+
|
473
|
+
class XrEventDataMainSessionVisibilityChangedEXTX < FFI::Struct
|
474
|
+
# TODO
|
475
|
+
end
|
476
|
+
|
477
|
+
class XrSpatialAnchorCreateInfoMSFT < FFI::Struct
|
478
|
+
# TODO
|
479
|
+
end
|
480
|
+
|
481
|
+
class XrSpatialAnchorSpaceCreateInfoMSFT < FFI::Struct
|
482
|
+
# TODO
|
483
|
+
end
|
484
|
+
|
485
|
+
class XrViewConfigurationDepthRangeEXT < FFI::Struct
|
486
|
+
# TODO
|
487
|
+
end
|
488
|
+
|
489
|
+
class XrViewConfigurationViewFovEPIC < FFI::Struct
|
490
|
+
# TODO
|
491
|
+
end
|
492
|
+
end # OpenXR::ABI
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
require_relative 'handle'
|
5
|
+
|
6
|
+
##
|
7
|
+
# An OpenXR action handle.
|
8
|
+
#
|
9
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#input
|
10
|
+
class OpenXR::Action < OpenXR::Handle
|
11
|
+
# TODO
|
12
|
+
end # OpenXR::Action
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
require_relative 'handle'
|
5
|
+
|
6
|
+
##
|
7
|
+
# An OpenXR action set handle.
|
8
|
+
#
|
9
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#input
|
10
|
+
class OpenXR::ActionSet < OpenXR::Handle
|
11
|
+
# TODO
|
12
|
+
end # OpenXR::ActionSet
|
data/lib/openxr/api.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'abi'
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
|
7
|
+
##
|
8
|
+
# The OpenXR application programming interface (API).
|
9
|
+
module OpenXR::API
|
10
|
+
extend OpenXR::ABI
|
11
|
+
include OpenXR::ABI
|
12
|
+
|
13
|
+
extend FFI::Library
|
14
|
+
|
15
|
+
ffi_lib ["libopenxr_loader.so.1", "openxr_loader"]
|
16
|
+
|
17
|
+
attach_function :xrAcquireSwapchainImage, [:pointer, :pointer, :pointer], :int
|
18
|
+
attach_function :xrApplyHapticFeedback, [:pointer, :pointer, :pointer], :int
|
19
|
+
attach_function :xrAttachSessionActionSets, [:pointer, :pointer], :int
|
20
|
+
attach_function :xrBeginFrame, [:pointer, :pointer], :int
|
21
|
+
attach_function :xrBeginSession, [:pointer, :pointer], :int
|
22
|
+
attach_function :xrCreateAction, [:pointer, :pointer, :pointer], :int
|
23
|
+
attach_function :xrCreateActionSet, [:pointer, :pointer, :pointer], :int
|
24
|
+
attach_function :xrCreateActionSpace, [:pointer, :pointer, :pointer], :int
|
25
|
+
#attach_function :xrCreateDebugUtilsMessengerEXT, [:pointer, :pointer, :pointer], :int
|
26
|
+
attach_function :xrCreateInstance, [:pointer, :pointer], :int
|
27
|
+
attach_function :xrCreateReferenceSpace, [:pointer, :pointer, :pointer], :int
|
28
|
+
attach_function :xrCreateSession, [:pointer, :pointer, :pointer], :int
|
29
|
+
#attach_function :xrCreateSpatialAnchorMSFT, [:pointer, :pointer, :pointer], :int
|
30
|
+
#attach_function :xrCreateSpatialAnchorSpaceMSFT, [:pointer, :pointer, :pointer], :int
|
31
|
+
attach_function :xrCreateSwapchain, [:pointer, :pointer, :pointer], :int
|
32
|
+
attach_function :xrDestroyAction, [:pointer], :int
|
33
|
+
attach_function :xrDestroyActionSet, [:pointer], :int
|
34
|
+
#attach_function :xrDestroyDebugUtilsMessengerEXT, [:pointer], :int
|
35
|
+
attach_function :xrDestroyInstance, [:pointer], :int
|
36
|
+
attach_function :xrDestroySession, [:pointer], :int
|
37
|
+
attach_function :xrDestroySpace, [:pointer], :int
|
38
|
+
#attach_function :xrDestroySpatialAnchorMSFT, [:pointer], :int
|
39
|
+
attach_function :xrDestroySwapchain, [:pointer], :int
|
40
|
+
attach_function :xrEndFrame, [:pointer, :pointer], :int
|
41
|
+
attach_function :xrEndSession, [:pointer], :int
|
42
|
+
attach_function :xrEnumerateApiLayerProperties, [:uint32, :pointer, :pointer], :int
|
43
|
+
attach_function :xrEnumerateBoundSourcesForAction, [:pointer, :pointer, :uint32, :pointer, :pointer], :int
|
44
|
+
attach_function :xrEnumerateEnvironmentBlendModes, [:pointer, :ulong_long, :int, :uint32, :pointer, :int], :int
|
45
|
+
attach_function :xrEnumerateInstanceExtensionProperties, [:string, :uint32, :pointer, :pointer], :int
|
46
|
+
attach_function :xrEnumerateReferenceSpaces, [:pointer, :uint32, :pointer, :int], :int
|
47
|
+
attach_function :xrEnumerateSwapchainFormats, [:pointer, :uint32, :pointer, :pointer], :int
|
48
|
+
attach_function :xrEnumerateSwapchainImages, [:pointer, :uint32, :pointer, :pointer], :int
|
49
|
+
attach_function :xrEnumerateViewConfigurationViews, [:pointer, :ulong_long, :int, :uint32, :pointer, :pointer], :int
|
50
|
+
attach_function :xrEnumerateViewConfigurations, [:pointer, :ulong_long, :uint32, :pointer, :int], :int
|
51
|
+
attach_function :xrGetActionStateBoolean, [:pointer, :pointer, :pointer], :int
|
52
|
+
attach_function :xrGetActionStateFloat, [:pointer, :pointer, :pointer], :int
|
53
|
+
attach_function :xrGetActionStatePose, [:pointer, :pointer, :pointer], :int
|
54
|
+
attach_function :xrGetActionStateVector2f, [:pointer, :pointer, :pointer], :int
|
55
|
+
attach_function :xrGetCurrentInteractionProfile, [:pointer, :ulong_long, :pointer], :int
|
56
|
+
attach_function :xrGetInputSourceLocalizedName, [:pointer, :pointer, :uint32, :pointer, :string], :int
|
57
|
+
attach_function :xrGetInstanceProcAddr, [:pointer, :string, :pointer], :int
|
58
|
+
attach_function :xrGetInstanceProperties, [:pointer, :pointer], :int
|
59
|
+
attach_function :xrGetReferenceSpaceBoundsRect, [:pointer, :int, :pointer], :int
|
60
|
+
attach_function :xrGetSystem, [:pointer, :pointer, :pointer], :int
|
61
|
+
attach_function :xrGetSystemProperties, [:pointer, :ulong_long, :pointer], :int
|
62
|
+
attach_function :xrGetViewConfigurationProperties, [:pointer, :ulong_long, :int, :pointer], :int
|
63
|
+
#attach_function :xrGetVisibilityMaskKHR, [:pointer, :int, :uint32, :int, :pointer], :int
|
64
|
+
attach_function :xrLocateSpace, [:pointer, :pointer, :long_long, :pointer], :int
|
65
|
+
attach_function :xrLocateViews, [:pointer, :pointer, :pointer, :uint32, :pointer, :pointer], :int
|
66
|
+
attach_function :xrPathToString, [:pointer, :ulong_long, :uint32, :pointer, :string], :int
|
67
|
+
#attach_function :xrPerfSettingsSetPerformanceLevelEXT, [:pointer, :int, :int], :int
|
68
|
+
attach_function :xrPollEvent, [:pointer, :pointer], :int
|
69
|
+
attach_function :xrReleaseSwapchainImage, [:pointer, :pointer], :int
|
70
|
+
attach_function :xrRequestExitSession, [:pointer], :int
|
71
|
+
attach_function :xrResultToString, [:pointer, :int, :pointer], :int
|
72
|
+
#attach_function :xrSessionBeginDebugUtilsLabelRegionEXT, [:pointer, :pointer], :int
|
73
|
+
#attach_function :xrSessionEndDebugUtilsLabelRegionEXT, [:pointer], :int
|
74
|
+
#attach_function :xrSessionInsertDebugUtilsLabelEXT, [:pointer, :pointer], :int
|
75
|
+
#attach_function :xrSetDebugUtilsObjectNameEXT, [:pointer, :pointer], :int
|
76
|
+
#attach_function :xrSetInputDeviceActiveEXT, [:pointer, :ulong_long, :ulong_long, :uint], :int
|
77
|
+
#attach_function :xrSetInputDeviceLocationEXT, [:pointer, :ulong_long, :ulong_long, :pointer, :pointer], :int
|
78
|
+
#attach_function :xrSetInputDeviceStateBoolEXT, [:pointer, :ulong_long, :ulong_long, :uint], :int
|
79
|
+
#attach_function :xrSetInputDeviceStateFloatEXT, [:pointer, :ulong_long, :ulong_long, :float], :int
|
80
|
+
#attach_function :xrSetInputDeviceStateVector2fEXT, [:pointer, :ulong_long, :ulong_long, :pointer], :int
|
81
|
+
attach_function :xrStopHapticFeedback, [:pointer, :pointer], :int
|
82
|
+
attach_function :xrStringToPath, [:pointer, :string, :pointer], :int
|
83
|
+
attach_function :xrStructureTypeToString, [:pointer, :int, :pointer], :int
|
84
|
+
#attach_function :xrSubmitDebugUtilsMessageEXT, [:pointer, :ulong_long, :ulong_long, :pointer], :int
|
85
|
+
attach_function :xrSuggestInteractionProfileBindings, [:pointer, :pointer], :int
|
86
|
+
attach_function :xrSyncActions, [:pointer, :pointer], :int
|
87
|
+
#attach_function :xrThermalGetTemperatureTrendEXT, [:pointer, :int, :int, :pointer, :pointer], :int
|
88
|
+
attach_function :xrWaitFrame, [:pointer, :pointer, :pointer], :int
|
89
|
+
attach_function :xrWaitSwapchainImage, [:pointer, :pointer], :int
|
90
|
+
end # OpenXR::API
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
require_relative 'result'
|
5
|
+
|
6
|
+
require 'ffi'
|
7
|
+
|
8
|
+
##
|
9
|
+
# An OpenXR instance extension.
|
10
|
+
#
|
11
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#extensions
|
12
|
+
class OpenXR::Extension < Struct.new(:name, :version)
|
13
|
+
extend OpenXR::API
|
14
|
+
include OpenXR::API
|
15
|
+
|
16
|
+
##
|
17
|
+
# @return [Integer]
|
18
|
+
def self.count
|
19
|
+
response = FFI::MemoryPointer.new(:uint32)
|
20
|
+
begin
|
21
|
+
# https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrenumerateinstanceextensionproperties3
|
22
|
+
case result = xrEnumerateInstanceExtensionProperties(nil, 0, response, nil)
|
23
|
+
when XR_SUCCESS then response.read(:uint32)
|
24
|
+
else raise OpenXR::Result.new(result, :xrEnumerateInstanceExtensionProperties)
|
25
|
+
end
|
26
|
+
ensure
|
27
|
+
response&.free
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# @yield [extension]
|
33
|
+
# @return [Enumerator]
|
34
|
+
def self.each(&block)
|
35
|
+
return self.to_enum(:each) unless block_given?
|
36
|
+
self.list.each(&block)
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# @return [Array<Extension>]
|
41
|
+
def self.list
|
42
|
+
self.query.values
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# @return [Hash<Symbol, Extension>]
|
47
|
+
def self.query
|
48
|
+
request_count = self.count
|
49
|
+
response_count = FFI::MemoryPointer.new(:uint32)
|
50
|
+
response_array = FFI::MemoryPointer.new(XrExtensionProperties, request_count)
|
51
|
+
begin
|
52
|
+
request_count.times do |i|
|
53
|
+
XrExtensionProperties.new(response_array[i])[:base][:type] = XR_TYPE_EXTENSION_PROPERTIES
|
54
|
+
end
|
55
|
+
|
56
|
+
# https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrenumerateinstanceextensionproperties3
|
57
|
+
case result = xrEnumerateInstanceExtensionProperties(nil, request_count, response_count, response_array)
|
58
|
+
when XR_SUCCESS
|
59
|
+
response_count.read(:uint32).times.inject({}) do |available, i|
|
60
|
+
response = XrExtensionProperties.new(response_array[i])
|
61
|
+
extension_name = response[:extensionName].to_s.to_sym
|
62
|
+
extension_version = response[:extensionVersion]
|
63
|
+
available[extension_name] = self.new(extension_name, extension_version)
|
64
|
+
available
|
65
|
+
end
|
66
|
+
else raise OpenXR::Result.new(result, :xrEnumerateInstanceExtensionProperties)
|
67
|
+
end
|
68
|
+
ensure
|
69
|
+
response_array&.free
|
70
|
+
response_count&.free
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end # OpenXR::Extension
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
|
5
|
+
##
|
6
|
+
# An OpenXR handle.
|
7
|
+
#
|
8
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#handles
|
9
|
+
class OpenXR::Handle
|
10
|
+
##
|
11
|
+
# @return [void]
|
12
|
+
def destroy!
|
13
|
+
# subclasses MUST implement this
|
14
|
+
end
|
15
|
+
end # OpenXR::Handle
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
require_relative 'handle'
|
5
|
+
require_relative 'result'
|
6
|
+
|
7
|
+
##
|
8
|
+
# An OpenXR instance handle.
|
9
|
+
#
|
10
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#instance
|
11
|
+
class OpenXR::Instance < OpenXR::Handle
|
12
|
+
include OpenXR::API
|
13
|
+
|
14
|
+
##
|
15
|
+
# @param [String, #to_s] app_name
|
16
|
+
# @param [Integer, #to_i] app_version
|
17
|
+
# @param [Integer, #to_i] api_version
|
18
|
+
# @yield [instance]
|
19
|
+
# @return [Object]
|
20
|
+
def self.create(app_name, app_version: nil, api_version: nil, &block)
|
21
|
+
instance = self.new(app_name, app_version: app_version, api_version: api_version)
|
22
|
+
begin
|
23
|
+
block.call(instance) if block_given?
|
24
|
+
ensure
|
25
|
+
instance&.destroy!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# @param [String, #to_s] app_name
|
31
|
+
# @param [Integer, #to_i] app_version
|
32
|
+
# @param [Integer, #to_i] api_version
|
33
|
+
def initialize(app_name, app_version: nil, api_version: nil)
|
34
|
+
@struct = XrInstance.new
|
35
|
+
|
36
|
+
request = XrInstanceCreateInfo.new
|
37
|
+
request[:base][:type] = XR_TYPE_INSTANCE_CREATE_INFO
|
38
|
+
request[:base][:next] = nil
|
39
|
+
request[:createFlags] = 0
|
40
|
+
request[:applicationInfo][:applicationName] = app_name.to_s
|
41
|
+
request[:applicationInfo][:applicationVersion] = (app_version || 0).to_i
|
42
|
+
request[:applicationInfo][:engineName] = "OpenXR.rb"
|
43
|
+
request[:applicationInfo][:engineVersion] = 0
|
44
|
+
request[:applicationInfo][:apiVersion] = (api_version || XR_CURRENT_API_VERSION).to_i
|
45
|
+
|
46
|
+
# https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrcreateinstance3
|
47
|
+
case result = xrCreateInstance(request, @struct)
|
48
|
+
when XR_SUCCESS
|
49
|
+
else raise OpenXR::Result.new(result, :xrCreateInstance) # TODO
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# @return [FFI::Pointer]
|
55
|
+
def handle
|
56
|
+
@struct[:handle]
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# @return [void]
|
61
|
+
def destroy!
|
62
|
+
return if @struct.nil?
|
63
|
+
# https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrdestroyinstance3
|
64
|
+
case result = xrDestroyInstance(@struct[:handle])
|
65
|
+
when XR_SUCCESS then @struct = nil
|
66
|
+
when XR_ERROR_HANDLE_INVALID then raise OpenXR::Result::HandleInvalid.new(:xrDestroyInstance)
|
67
|
+
else raise OpenXR::Result.new(result, :xrDestroyInstance) # unreachable
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end # OpenXR::Instance
|
data/lib/openxr/layer.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
|
5
|
+
##
|
6
|
+
# An OpenXR API layer.
|
7
|
+
#
|
8
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#api-layers
|
9
|
+
class OpenXR::Layer
|
10
|
+
# TODO
|
11
|
+
end # OpenXR::Layer
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
|
5
|
+
##
|
6
|
+
# An OpenXR result code.
|
7
|
+
#
|
8
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#return-codes
|
9
|
+
class OpenXR::Result < StandardError
|
10
|
+
include OpenXR::API
|
11
|
+
|
12
|
+
attr_reader :result
|
13
|
+
|
14
|
+
def initialize(result, function)
|
15
|
+
@result = result
|
16
|
+
super("#{function} returned #{result}")
|
17
|
+
end
|
18
|
+
|
19
|
+
class HandleInvalid < OpenXR::Result
|
20
|
+
def initialize(function)
|
21
|
+
super(XR_ERROR_HANDLE_INVALID, function)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end # OpenXR::Result
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
require_relative 'handle'
|
5
|
+
|
6
|
+
##
|
7
|
+
# An OpenXR session handle.
|
8
|
+
#
|
9
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#session
|
10
|
+
class OpenXR::Session < OpenXR::Handle
|
11
|
+
# TODO
|
12
|
+
end # OpenXR::Session
|
data/lib/openxr/space.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
require_relative 'handle'
|
5
|
+
|
6
|
+
##
|
7
|
+
# An OpenXR space handle.
|
8
|
+
#
|
9
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#spaces
|
10
|
+
class OpenXR::Space < OpenXR::Handle
|
11
|
+
# TODO
|
12
|
+
end # OpenXR::Space
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
require_relative 'handle'
|
5
|
+
|
6
|
+
##
|
7
|
+
# An OpenXR swapchain handle.
|
8
|
+
#
|
9
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#rendering
|
10
|
+
class OpenXR::Swapchain < OpenXR::Handle
|
11
|
+
# TODO
|
12
|
+
end # OpenXR::Swapchain
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
require_relative 'api'
|
4
|
+
require_relative 'result'
|
5
|
+
|
6
|
+
##
|
7
|
+
# An OpenXR system.
|
8
|
+
#
|
9
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#system
|
10
|
+
class OpenXR::System
|
11
|
+
extend OpenXR::API
|
12
|
+
include OpenXR::API
|
13
|
+
|
14
|
+
##
|
15
|
+
# @param [Instance] instance
|
16
|
+
# @param [XrFormFactor, #to_i] form_factor
|
17
|
+
# @return [System]
|
18
|
+
# @see https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#form_factor_description
|
19
|
+
def self.for_form_factor(instance, form_factor)
|
20
|
+
request = XrSystemGetInfo.new
|
21
|
+
request[:base][:type] = XR_TYPE_SYSTEM_GET_INFO
|
22
|
+
request[:formFactor] = form_factor.to_i
|
23
|
+
system_id = FFI::MemoryPointer.new(XrSystemId)
|
24
|
+
|
25
|
+
begin
|
26
|
+
# https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrgetsystem3
|
27
|
+
case result = xrGetSystem(instance.handle, request, system_id)
|
28
|
+
when XR_SUCCESS then self.new(instance, system_id.read(XrSystemId))
|
29
|
+
#when XR_ERROR_FORM_FACTOR_UNAVAILABLE then # TODO
|
30
|
+
else raise OpenXR::Result.new(result, :xrGetSystem)
|
31
|
+
end
|
32
|
+
ensure
|
33
|
+
system_id&.free
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# @return [Instance]
|
38
|
+
attr_reader :instance
|
39
|
+
|
40
|
+
# @return [API::XrSystemId]
|
41
|
+
attr_reader :id
|
42
|
+
|
43
|
+
# @return [String]
|
44
|
+
attr_reader :name
|
45
|
+
|
46
|
+
# @return [Integer]
|
47
|
+
attr_reader :vendor_id
|
48
|
+
|
49
|
+
# @return [Hash<Symbol, Integer>]
|
50
|
+
attr_reader :graphics_properties
|
51
|
+
|
52
|
+
# @return [Hash<Symbol, Bool>]
|
53
|
+
attr_reader :tracking_properties
|
54
|
+
|
55
|
+
##
|
56
|
+
# @param [Instance] instance
|
57
|
+
# @param [API::XrSystemId, #to_i] id
|
58
|
+
def initialize(instance, id)
|
59
|
+
@instance = instance
|
60
|
+
@id = id.to_i
|
61
|
+
|
62
|
+
response = XrSystemProperties.new
|
63
|
+
response[:base][:type] = XR_TYPE_SYSTEM_PROPERTIES
|
64
|
+
|
65
|
+
# https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrgetsystemproperties3
|
66
|
+
case result = xrGetSystemProperties(@instance.handle, @id, response)
|
67
|
+
when XR_SUCCESS
|
68
|
+
@name = response[:systemName].to_s
|
69
|
+
@vendor_id = response[:vendorId]
|
70
|
+
@graphics_properties = {
|
71
|
+
:max_swapchain_image_height => response[:graphicsProperties][:maxSwapchainImageHeight],
|
72
|
+
:max_swapchain_image_width => response[:graphicsProperties][:maxSwapchainImageWidth],
|
73
|
+
:max_layer_count => response[:graphicsProperties][:maxLayerCount],
|
74
|
+
}
|
75
|
+
@tracking_properties = {
|
76
|
+
:orientation_tracking => response[:trackingProperties][:orientationTracking] == XR_TRUE,
|
77
|
+
:position_tracking => response[:trackingProperties][:positionTracking] == XR_TRUE,
|
78
|
+
}
|
79
|
+
else raise OpenXR::Result.new(result, :xrGetSystemProperties)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end # OpenXR::System
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
module OpenXR
|
4
|
+
module VERSION
|
5
|
+
FILE = File.expand_path('../../VERSION', __dir__).freeze
|
6
|
+
STRING = File.read(FILE).chomp.freeze
|
7
|
+
MAJOR, MINOR, TINY, EXTRA = STRING.split('.').map(&:to_i).freeze
|
8
|
+
|
9
|
+
##
|
10
|
+
# @return [String]
|
11
|
+
def self.to_s() STRING end
|
12
|
+
|
13
|
+
##
|
14
|
+
# @return [String]
|
15
|
+
def self.to_str() STRING end
|
16
|
+
|
17
|
+
##
|
18
|
+
# @return [Array(Integer, Integer, Integer)]
|
19
|
+
def self.to_a() [MAJOR, MINOR, TINY].freeze end
|
20
|
+
end # VERSION
|
21
|
+
end # OpenXR
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openxr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arto Bendiken
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ffidb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ffi
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.12'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.12'
|
83
|
+
description: |
|
84
|
+
OpenXR.rb implements Ruby bindings for OpenXR 1.0, the open standard and
|
85
|
+
cross-platform API for virtual reality (VR) and augmented reality (AR)
|
86
|
+
hardware.
|
87
|
+
email: arto@bendiken.net
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- AUTHORS
|
93
|
+
- CHANGES.md
|
94
|
+
- CREDITS.md
|
95
|
+
- README.md
|
96
|
+
- UNLICENSE
|
97
|
+
- VERSION
|
98
|
+
- lib/openxr.rb
|
99
|
+
- lib/openxr/abi.rb
|
100
|
+
- lib/openxr/action.rb
|
101
|
+
- lib/openxr/action_set.rb
|
102
|
+
- lib/openxr/api.rb
|
103
|
+
- lib/openxr/extension.rb
|
104
|
+
- lib/openxr/handle.rb
|
105
|
+
- lib/openxr/instance.rb
|
106
|
+
- lib/openxr/layer.rb
|
107
|
+
- lib/openxr/result.rb
|
108
|
+
- lib/openxr/session.rb
|
109
|
+
- lib/openxr/space.rb
|
110
|
+
- lib/openxr/swapchain.rb
|
111
|
+
- lib/openxr/system.rb
|
112
|
+
- lib/openxr/version.rb
|
113
|
+
homepage: https://github.com/dryruby/openxr.rb
|
114
|
+
licenses:
|
115
|
+
- Unlicense
|
116
|
+
metadata:
|
117
|
+
bug_tracker_uri: https://github.com/dryruby/openxr.rb/issues
|
118
|
+
changelog_uri: https://github.com/dryruby/openxr.rb/blob/master/CHANGES.md
|
119
|
+
documentation_uri: https://www.rubydoc.info/github/dryruby/openxr.rb/master
|
120
|
+
homepage_uri: https://github.com/dryruby/openxr.rb
|
121
|
+
source_code_uri: https://github.com/dryruby/openxr.rb
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 2.7.0
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: 3.1.2
|
136
|
+
requirements: []
|
137
|
+
rubygems_version: 3.1.2
|
138
|
+
signing_key:
|
139
|
+
specification_version: 4
|
140
|
+
summary: OpenXR bindings for Ruby.
|
141
|
+
test_files: []
|