C Specification
Function pointers for all OpenXR functions can be obtained with the function xrGetInstanceProcAddr.
XrResult xrGetInstanceProcAddr(
XrInstance instance,
const char* name,
PFN_xrVoidFunction* function);
Parameters
Description
xrGetInstanceProcAddr itself is obtained in a platform- and loader- specific manner. Typically, the loader library will export this function as a function symbol, so applications can link against the loader library, or load it dynamically and look up the symbol using platform-specific APIs. Loaders must export function symbols for all core OpenXR functions. Because of this, applications that use only the core OpenXR functions have no need to use xrGetInstanceProcAddr.
Because an application can call xrGetInstanceProcAddr before
creating an instance, xrGetInstanceProcAddr returns a valid
function pointer when the instance
parameter is XR_NULL_HANDLE
and the name
parameter is one of the following strings:
xrGetInstanceProcAddr returns XR_ERROR_HANDLE_INVALID
if instance
is
NULL
and name
is not one of the above strings.
xrGetInstanceProcAddr returns XR_ERROR_FUNCTION_UNSUPPORTED
if instance
is a valid
instance and the string specified in name
is not
the name of an OpenXR core or enabled extension function.
If name
is the name of an extension function, then the result returned by
xrGetInstanceProcAddr will depend upon how the instance
was
created.
If instance
was created with the related extension’s name appearing
in the XrInstanceCreateInfo::enabledExtensionNames
array,
then xrGetInstanceProcAddr returns a valid function pointer.
If the related extension’s name did not appear in the
XrInstanceCreateInfo::enabledExtensionNames
array during
the creation of instance
, then xrGetInstanceProcAddr returns
XR_ERROR_FUNCTION_UNSUPPORTED
.
Because of this, function pointers returned by xrGetInstanceProcAddr
using one XrInstance may not be valid when used with objects related to
a different XrInstance.
The returned function pointer is of type PFN_xrVoidFunction, and must be cast to the type of the function being queried.
The table below defines the various use cases for xrGetInstanceProcAddr and return value (“fp” is “function pointer”) for each case.
instance parameter |
name parameter |
return value |
---|---|---|
* |
|
undefined |
invalid instance |
* |
undefined |
|
fp |
|
|
fp |
|
|
fp |
|
|
* (any |
|
instance |
core OpenXR function |
fp1 |
instance |
enabled extension function for |
fp1 |
instance |
* (any |
|
- 1
-
The returned function pointer must only be called with a dispatchable object (the first parameter) that is
instance
or a child ofinstance
.
See Also
Document Notes
For more information, see the OpenXR Specification at URL
This page is extracted from the OpenXR Specification. Fixes and changes should be made to the Specification, not directly.
Copyright
Copyright (c) 2014-2019 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.