Class XrHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.lwjgl.system.Struct
createOpenGLBinding
(org.lwjgl.system.MemoryStack stack, long window) Allocates aXrGraphicsBindingOpenGL**
struct for the current platform onto the given stack.static FloatBuffer
createProjectionMatrixBuffer
(org.lwjgl.system.MemoryStack stack, org.lwjgl.openxr.XrFovf fov, float nearZ, float farZ, boolean zZeroToOne) Allocates aFloatBuffer
onto the given stack and fills it such that it can be used as parameter to the set method of Matrix4f.static <T extends org.lwjgl.system.StructBuffer>
Tfill
(T buffer, int offset, int value) static IntModel
loadRenderModel
(XrDriver driver, XrControllerDevice controllerDevice) static org.lwjgl.openxr.XrActionSuggestedBinding.Buffer
prepareActionSuggestedBindings
(org.lwjgl.system.MemoryStack stack, int numBindings) Allocates anXrActionSuggestedBinding.Buffer
onto the given stack with the given number of bindings.static org.lwjgl.openxr.XrApiLayerProperties.Buffer
prepareApiLayerProperties
(org.lwjgl.system.MemoryStack stack, int numLayers) Allocates anXrApiLayerProperties.Buffer
onto the given stack with the given number of layers and sets the type of each element in the buffer toXR_TYPE_API_LAYER_PROPERTIES
.static org.lwjgl.openxr.XrExtensionProperties.Buffer
prepareExtensionProperties
(org.lwjgl.system.MemoryStack stack, int numExtensions) Allocates anXrExtensionProperties.Buffer
onto the given stack with the given number of extensions and sets the type of each element in the buffer toXR_TYPE_EXTENSION_PROPERTIES
.
-
Method Details
-
fill
public static <T extends org.lwjgl.system.StructBuffer> T fill(T buffer, int offset, int value) -
prepareApiLayerProperties
public static org.lwjgl.openxr.XrApiLayerProperties.Buffer prepareApiLayerProperties(org.lwjgl.system.MemoryStack stack, int numLayers) Allocates anXrApiLayerProperties.Buffer
onto the given stack with the given number of layers and sets the type of each element in the buffer toXR_TYPE_API_LAYER_PROPERTIES
.Note: you can't use the buffer after the stack is gone!
- Parameters:
stack
- the stack to allocate the buffer onnumLayers
- the number of elements the buffer should get- Returns:
- the created buffer
-
prepareExtensionProperties
public static org.lwjgl.openxr.XrExtensionProperties.Buffer prepareExtensionProperties(org.lwjgl.system.MemoryStack stack, int numExtensions) Allocates anXrExtensionProperties.Buffer
onto the given stack with the given number of extensions and sets the type of each element in the buffer toXR_TYPE_EXTENSION_PROPERTIES
.Note: you can't use the buffer after the stack is gone!
- Parameters:
stack
- the stack onto which to allocate the buffernumExtensions
- the number of elements the buffer should get- Returns:
- the created buffer
-
prepareActionSuggestedBindings
public static org.lwjgl.openxr.XrActionSuggestedBinding.Buffer prepareActionSuggestedBindings(org.lwjgl.system.MemoryStack stack, int numBindings) Allocates anXrActionSuggestedBinding.Buffer
onto the given stack with the given number of bindings.Note: you can't use the buffer after the stack is gone!
- Parameters:
stack
- the stack to allocate the buffer onnumBindings
- the number of elements the buffer should get- Returns:
- the created buffer
-
createProjectionMatrixBuffer
public static FloatBuffer createProjectionMatrixBuffer(org.lwjgl.system.MemoryStack stack, org.lwjgl.openxr.XrFovf fov, float nearZ, float farZ, boolean zZeroToOne) Allocates aFloatBuffer
onto the given stack and fills it such that it can be used as parameter to the set method of Matrix4f. The buffer will be filled such that it represents a projection matrix with the given fov, nearZ (a.k.a. near plane), farZ (a.k.a. far plane).- Parameters:
stack
- The stack onto which the buffer should be allocatedfov
- The desired Field of View for the projection matrix. You should normally use the value ofXrCompositionLayerProjectionView.fov()
.nearZ
- The nearest Z value that the user should see (also known as the near plane)farZ
- The furthest Z value that the user should see (also known as far plane)zZeroToOne
- True if the z-axis of the coordinate system goes from 0 to 1 (Vulkan). False if the z-axis of the coordinate system goes from -1 to 1 (OpenGL).- Returns:
- A
FloatBuffer
that contains the matrix data of the desired projection matrix. Use the set method of a Matrix4f instance to copy the buffer values to that matrix.
-
createOpenGLBinding
public static org.lwjgl.system.Struct createOpenGLBinding(org.lwjgl.system.MemoryStack stack, long window) Allocates a
XrGraphicsBindingOpenGL**
struct for the current platform onto the given stack. It should be included in the next-chain of theXrSessionCreateInfo
that will be used to create an OpenXR session with OpenGL rendering. (Every platform requires a different OpenGL graphics binding struct, so this method spares users the trouble of working with all these cases themselves.)Note:
XR10.xrCreateSession(org.lwjgl.openxr.XrInstance, org.lwjgl.openxr.XrSessionCreateInfo, org.lwjgl.PointerBuffer)
must be called before the given stack is dropped!Note: Linux support is not finished, so only Windows works at the moment. This should be fixed in the future. Until then, Vulkan is the only cross-platform rendering API for the OpenXR Java bindings.
- Parameters:
stack
- The stack onto which to allocate the graphics binding structwindow
- The GLFW window handle used to create the OpenGL context- Returns:
- A
XrGraphicsBindingOpenGL**
struct that can be used to create a session - Throws:
IllegalStateException
- If the current platform is not supported
-
loadRenderModel
-