Class XrHelper

java.lang.Object
gaiasky.vr.openxr.XrHelper

public final class XrHelper extends Object
Helper functions to use by the VR subsystem.
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    createProjectionMatrixBuffer(org.lwjgl.system.MemoryStack stack, org.lwjgl.openxr.XrFovf fov, float nearZ, float farZ, boolean zZeroToOne)
    Allocates a FloatBuffer 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>
    T
    fill(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 an XrActionSuggestedBinding.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 an XrApiLayerProperties.Buffer onto the given stack with the given number of layers and sets the type of each element in the buffer to XR_TYPE_API_LAYER_PROPERTIES.
    static org.lwjgl.openxr.XrExtensionProperties.Buffer
    prepareExtensionProperties(org.lwjgl.system.MemoryStack stack, int numExtensions)
    Allocates an XrExtensionProperties.Buffer onto the given stack with the given number of extensions and sets the type of each element in the buffer to XR_TYPE_EXTENSION_PROPERTIES.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 an XrApiLayerProperties.Buffer onto the given stack with the given number of layers and sets the type of each element in the buffer to XR_TYPE_API_LAYER_PROPERTIES.

      Note: you can't use the buffer after the stack is gone!

      Parameters:
      stack - the stack to allocate the buffer on
      numLayers - 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 an XrExtensionProperties.Buffer onto the given stack with the given number of extensions and sets the type of each element in the buffer to XR_TYPE_EXTENSION_PROPERTIES.

      Note: you can't use the buffer after the stack is gone!

      Parameters:
      stack - the stack onto which to allocate the buffer
      numExtensions - 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 an XrActionSuggestedBinding.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 on
      numBindings - 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 a FloatBuffer 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 allocated
      fov - The desired Field of View for the projection matrix. You should normally use the value of XrCompositionLayerProjectionView.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 the XrSessionCreateInfo 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 struct
      window - 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

      public static IntModel loadRenderModel(XrDriver driver, XrControllerDevice controllerDevice)