Class: OpenXR::System

Inherits:
Object
  • Object
show all
Extended by:
API
Includes:
API
Defined in:
lib/openxr/system.rb

Overview

An OpenXR system.

Constant Summary

Constants included from ABI

ABI::XR_CURRENT_API_VERSION, ABI::XR_ERROR_HANDLE_INVALID, ABI::XR_ERROR_RUNTIME_FAILURE, ABI::XR_ERROR_VALIDATION_FAILURE, ABI::XR_FALSE, ABI::XR_FORM_FACTOR_HANDHELD_DISPLAY, ABI::XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY, ABI::XR_FORM_FACTOR_MAX_ENUM, ABI::XR_MAX_ACTION_NAME_SIZE, ABI::XR_MAX_ACTION_SET_NAME_SIZE, ABI::XR_MAX_API_LAYER_DESCRIPTION_SIZE, ABI::XR_MAX_API_LAYER_NAME_SIZE, ABI::XR_MAX_APPLICATION_NAME_SIZE, ABI::XR_MAX_ENGINE_NAME_SIZE, ABI::XR_MAX_EXTENSION_NAME_SIZE, ABI::XR_MAX_LOCALIZED_ACTION_NAME_SIZE, ABI::XR_MAX_LOCALIZED_ACTION_SET_NAME_SIZE, ABI::XR_MAX_PATH_LENGTH, ABI::XR_MAX_RESULT_STRING_SIZE, ABI::XR_MAX_RUNTIME_NAME_SIZE, ABI::XR_MAX_STRUCTURE_NAME_SIZE, ABI::XR_MAX_SYSTEM_NAME_SIZE, ABI::XR_MIN_COMPOSITION_LAYERS_SUPPORTED, ABI::XR_SUCCESS, ABI::XR_TRUE, ABI::XR_TYPE_API_LAYER_PROPERTIES, ABI::XR_TYPE_EXTENSION_PROPERTIES, ABI::XR_TYPE_INSTANCE_CREATE_INFO, ABI::XR_TYPE_SESSION_CREATE_INFO, ABI::XR_TYPE_SYSTEM_GET_INFO, ABI::XR_TYPE_SYSTEM_PROPERTIES, ABI::XR_TYPE_UNKNOWN, ABI::XR_TYPE_VIEW, ABI::XR_TYPE_VIEW_LOCATE_INFO, ABI::XrBaseInStructure, ABI::XrBaseOutStructure, ABI::XrBool32, ABI::XrDuration, ABI::XrFlags64, ABI::XrFormFactor, ABI::XrInstanceCreateFlags, ABI::XrPath, ABI::XrResult, ABI::XrSessionCreateFlags, ABI::XrStructureType, ABI::XrSystemId, ABI::XrTime, ABI::XrVersion

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ABI

XR_MAKE_VERSION

Constructor Details

#initialize(instance, id) ⇒ System

Returns a new instance of System.

Parameters:



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/openxr/system.rb', line 58

def initialize(instance, id)
  @instance = instance
  @id = id.to_i

  response = XrSystemProperties.new
  response[:base][:type] = XR_TYPE_SYSTEM_PROPERTIES

  # https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrgetsystemproperties3
  case result = xrGetSystemProperties(@instance.handle, @id, response)
    when XR_SUCCESS
      @name = response[:systemName].to_s
      @vendor_id = response[:vendorId]
      @graphics_properties = {
        :max_swapchain_image_height => response[:graphicsProperties][:maxSwapchainImageHeight],
        :max_swapchain_image_width => response[:graphicsProperties][:maxSwapchainImageWidth],
        :max_layer_count => response[:graphicsProperties][:maxLayerCount],
      }
      @tracking_properties = {
        :orientation_tracking => response[:trackingProperties][:orientationTracking] == XR_TRUE,
        :position_tracking    => response[:trackingProperties][:positionTracking] == XR_TRUE,
      }
    else raise OpenXR::Result.new(result, :xrGetSystemProperties)
  end
end

Instance Attribute Details

#graphics_propertiesHash<Symbol, Integer> (readonly)

Returns:

  • (Hash<Symbol, Integer>)


50
51
52
# File 'lib/openxr/system.rb', line 50

def graphics_properties
  @graphics_properties
end

#idAPI::XrSystemId (readonly)

Returns:



41
42
43
# File 'lib/openxr/system.rb', line 41

def id
  @id
end

#instanceInstance (readonly)

Returns:



38
39
40
# File 'lib/openxr/system.rb', line 38

def instance
  @instance
end

#nameString (readonly)

Returns:

  • (String)


44
45
46
# File 'lib/openxr/system.rb', line 44

def name
  @name
end

#tracking_propertiesHash<Symbol, Bool> (readonly)

Returns:

  • (Hash<Symbol, Bool>)


53
54
55
# File 'lib/openxr/system.rb', line 53

def tracking_properties
  @tracking_properties
end

#vendor_idInteger (readonly)

Returns:

  • (Integer)


47
48
49
# File 'lib/openxr/system.rb', line 47

def vendor_id
  @vendor_id
end

Class Method Details

.for_form_factor(instance, form_factor) ⇒ System



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/openxr/system.rb', line 19

def self.for_form_factor(instance, form_factor)
  request = XrSystemGetInfo.new
  request[:base][:type] = XR_TYPE_SYSTEM_GET_INFO
  request[:formFactor] = form_factor.to_i
  system_id = FFI::MemoryPointer.new(XrSystemId)

  begin
    # https://www.khronos.org/registry/OpenXR/specs/1.0/man/html/openxr.html#_xrgetsystem3
    case result = xrGetSystem(instance.handle, request, system_id)
      when XR_SUCCESS then self.new(instance, system_id.read(XrSystemId))
      #when XR_ERROR_FORM_FACTOR_UNAVAILABLE then # TODO
      else raise OpenXR::Result.new(result, :xrGetSystem)
    end
  ensure
    system_id&.free
  end
end