1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

OpenXR: Add support for retrieving play area

This commit is contained in:
Bastiaan Olij
2023-11-21 16:34:29 +11:00
parent d76c1d0e51
commit 69a41b3d39
4 changed files with 63 additions and 2 deletions

View File

@@ -87,7 +87,7 @@ String OpenXRAPI::get_default_action_map_resource_name() {
return name;
}
String OpenXRAPI::get_error_string(XrResult result) {
String OpenXRAPI::get_error_string(XrResult result) const {
if (XR_SUCCEEDED(result)) {
return String("Succeeded");
}
@@ -1261,6 +1261,7 @@ bool OpenXRAPI::resolve_instance_openxr_symbols() {
OPENXR_API_INIT_XR_FUNC_V(xrGetActionStateFloat);
OPENXR_API_INIT_XR_FUNC_V(xrGetActionStateVector2f);
OPENXR_API_INIT_XR_FUNC_V(xrGetCurrentInteractionProfile);
OPENXR_API_INIT_XR_FUNC_V(xrGetReferenceSpaceBoundsRect);
OPENXR_API_INIT_XR_FUNC_V(xrGetSystem);
OPENXR_API_INIT_XR_FUNC_V(xrGetSystemProperties);
OPENXR_API_INIT_XR_FUNC_V(xrLocateViews);
@@ -2072,6 +2073,25 @@ void OpenXRAPI::set_foveation_dynamic(bool p_foveation_dynamic) {
}
}
Size2 OpenXRAPI::get_play_space_bounds() const {
Size2 ret;
ERR_FAIL_COND_V(session == XR_NULL_HANDLE, Size2());
XrExtent2Df extents;
XrResult result = xrGetReferenceSpaceBoundsRect(session, reference_space, &extents);
if (XR_FAILED(result)) {
print_line("OpenXR: failed to get play space bounds! [", get_error_string(result), "]");
return ret;
}
ret.width = extents.width;
ret.height = extents.height;
return ret;
}
OpenXRAPI::OpenXRAPI() {
// OpenXRAPI is only constructed if OpenXR is enabled.
singleton = this;