OpenXR: Expose view information to GDExtension API

View count and XrViewConfigurationType are relevant for various core
OpenXR functions and extensions. This commit makes them accessible
via the GDExtension API.
This commit is contained in:
Erik Ritschl
2025-11-04 15:18:29 +01:00
parent 40448082ab
commit 3bd8f3ccb6
5 changed files with 30 additions and 2 deletions
@@ -149,6 +149,18 @@
Returns the ID of the system, which is an [url=https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrSystemId.html]XrSystemId[/url] cast to an integer.
</description>
</method>
<method name="get_view_configuration" qualifiers="const">
<return type="int" />
<description>
Returns the view configuration type, which is an [url=https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrViewConfigurationType.html]XrViewConfigurationType[/url] cast to an integer.
</description>
</method>
<method name="get_view_count" qualifiers="const">
<return type="int" />
<description>
Returns the number of views. It is usually two, one for each eye, but may differ with different view configurations.
</description>
</method>
<method name="insert_debug_label">
<return type="void" />
<param index="0" name="label_name" type="String" />
+1 -1
View File
@@ -1561,7 +1561,7 @@ void OpenXRAPI::set_form_factor(XrFormFactor p_form_factor) {
form_factor = p_form_factor;
}
uint32_t OpenXRAPI::get_view_count() {
uint32_t OpenXRAPI::get_view_count() const {
return view_configuration_views.size();
}
+1 -1
View File
@@ -502,7 +502,7 @@ public:
void set_form_factor(XrFormFactor p_form_factor);
XrFormFactor get_form_factor() const { return form_factor; }
uint32_t get_view_count();
uint32_t get_view_count() const;
void set_view_configuration(XrViewConfigurationType p_view_configuration);
XrViewConfigurationType get_view_configuration() const { return view_configuration; }
+13
View File
@@ -50,6 +50,9 @@ void OpenXRAPIExtension::_bind_methods() {
ClassDB::bind_method(D_METHOD("end_debug_label_region"), &OpenXRAPIExtension::end_debug_label_region);
ClassDB::bind_method(D_METHOD("insert_debug_label", "label_name"), &OpenXRAPIExtension::insert_debug_label);
ClassDB::bind_method(D_METHOD("get_view_count"), &OpenXRAPIExtension::get_view_count);
ClassDB::bind_method(D_METHOD("get_view_configuration"), &OpenXRAPIExtension::get_view_configuration);
ClassDB::bind_method(D_METHOD("is_initialized"), &OpenXRAPIExtension::is_initialized);
ClassDB::bind_method(D_METHOD("is_running"), &OpenXRAPIExtension::is_running);
@@ -183,6 +186,16 @@ void OpenXRAPIExtension::insert_debug_label(const String &p_label_name) {
OpenXRAPI::get_singleton()->insert_debug_label(p_label_name);
}
uint32_t OpenXRAPIExtension::get_view_count() const {
ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), 0);
return (uint32_t)OpenXRAPI::get_singleton()->get_view_count();
}
uint64_t OpenXRAPIExtension::get_view_configuration() const {
ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), 0);
return (uint64_t)OpenXRAPI::get_singleton()->get_view_configuration();
}
bool OpenXRAPIExtension::is_initialized() {
ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), false);
return OpenXRAPI::get_singleton()->is_initialized();
+3
View File
@@ -77,6 +77,9 @@ public:
void end_debug_label_region();
void insert_debug_label(const String &p_label_name);
uint32_t get_view_count() const;
uint64_t get_view_configuration() const;
bool is_initialized();
bool is_running();