class OpenXR::Session

An OpenXR session handle.

@see www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#session

Attributes

instance[R]

@return [Instance]

system[R]

@return [System]

Public Class Methods

new(system, graphics_binding = nil) click to toggle source

@param [System] @param [XrGraphicsBinding] graphics_binding @raise [Result::Error] if `xrCreateSession` failed

# File lib/openxr/session.rb, line 25
def initialize(system, graphics_binding = nil)
  @instance = system.instance
  @system   = system
  @struct   = XrSession.new

  # https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrsessioncreateinfo3
  request = XrSessionCreateInfo.new
  request[:base][:next] = graphics_binding
  request[:createFlags] = 0
  request[:systemId] = system.id

  # https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrcreatesession3
  case result = xrCreateSession(instance.handle, request, @struct)
    when XR_SUCCESS
    else raise OpenXR::Result.for(result).new(:xrCreateSession)
  end
end

Public Instance Methods

destroy!() click to toggle source

@return [void] @raise [Result::Error] if `xrDestroySession` failed

# File lib/openxr/session.rb, line 52
def destroy!
  return if @struct.nil?
  # https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrdestroysession3
  case result = xrDestroySession(@struct[:handle])
    when XR_SUCCESS then @struct = nil
    else raise OpenXR::Result.for(result).new(:xrDestroySession) # unreachable
  end
end
handle() click to toggle source

@return [FFI::Pointer]

# File lib/openxr/session.rb, line 45
def handle
  @struct[:handle]
end