Skip to content

Commit 38363fa

Browse files
authored
Add docs for rec resolution and hybrid apps (#274)
1 parent 19a0237 commit 38363fa

12 files changed

+137
-1
lines changed

doc_classes/OpenXRHybridApp.xml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="OpenXRHybridApp" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
3+
<brief_description>
4+
Used to query/update an app's hybrid app state.
5+
</brief_description>
6+
<description>
7+
Used to query/update an app's hybrid app state.
8+
A hybrid app is an application capable of swapping between an immersive 3D mode and a 2D panel mode.
9+
</description>
10+
<tutorials>
11+
</tutorials>
12+
<methods>
13+
<method name="get_launch_data" qualifiers="const">
14+
<return type="String" />
15+
<description>
16+
Gets the [code]data[/code] string that was passed to [method switch_mode].
17+
</description>
18+
</method>
19+
<method name="get_mode" qualifiers="const">
20+
<return type="int" enum="OpenXRHybridApp.HybridMode" />
21+
<description>
22+
Gets the current hybrid app mode.
23+
</description>
24+
</method>
25+
<method name="is_hybrid_app" qualifiers="const">
26+
<return type="bool" />
27+
<description>
28+
Returns [code]true[/code] if application is a hybrid app.
29+
</description>
30+
</method>
31+
<method name="switch_mode">
32+
<return type="bool" />
33+
<param index="0" name="mode" type="int" enum="OpenXRHybridApp.HybridMode" />
34+
<param index="1" name="data" type="String" default="&quot;&quot;" />
35+
<description>
36+
Switches the application to the specified hybrid app mode.
37+
The [param data] string will be accessible via [method get_launch_data] upon switching hybrid app modes.
38+
</description>
39+
</method>
40+
</methods>
41+
<constants>
42+
<constant name="HYBRID_MODE_NONE" value="-1" enum="HybridMode">
43+
Disable hybrid app functionality.
44+
</constant>
45+
<constant name="HYBRID_MODE_IMMERSIVE" value="0" enum="HybridMode">
46+
3D immersive hybrid app mode.
47+
</constant>
48+
<constant name="HYBRID_MODE_PANEL" value="1" enum="HybridMode">
49+
2D panel hybird app mode.
50+
</constant>
51+
</constants>
52+
</class>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="OpenXRMetaRecommendedLayerResolutionExtensionWrapper" inherits="OpenXRExtensionWrapperExtension" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/godotengine/godot/master/doc/class.xsd">
3+
<brief_description>
4+
Wraps the [code]XR_META_recommended_layer_resolution[/code] extension.
5+
</brief_description>
6+
<description>
7+
Wraps the [code]XR_META_recommended_layer_resolution[/code] extension.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
</class>

docs/manual/hybrid_apps.rst

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Hybrid Apps
2+
===========
3+
4+
.. note::
5+
6+
Check out the `Hybrid App Sample Project <https://github.com/GodotVR/godot_openxr_vendors/tree/master/samples/hybrid-app-sample>`_
7+
for a working demo of hybird app functionality.
8+
9+
Hybrid apps are applications capable of swapping between an immersive 3D mode and a 2D panel mode at runtime.
10+
11+
Project Settings
12+
----------------
13+
14+
To make a hybrid app, the feature must be enabled in your project settings. The setting can be found in **Project Settings** under the **OpenXR** section.
15+
The **Hybrid App** setting should be visible if **Advanced Settings** are enabled.
16+
17+
.. image:: img/hybrid_apps/hybrid_apps_project_setting.png
18+
19+
By default, hybrid app functionality is disabled. Selecting either of the other options will enable hybrid app features and determine the app's starting mode.
20+
21+
Switching Modes
22+
---------------
23+
24+
To switch between immersive and panel app modes in your hybrid app, use the :ref:`switch_mode <class_openxrhybridapp_method_switch_mode>` function.
25+
Switching modes restarts the application, so if you want it to start from where the user left off, you will need to use the second argument
26+
to pass data to the new mode as a ``String``, which can be accessed via the :ref:`get_launch_data <class_openxrhybridapp_method_get_launch_data>` function.
27+
28+
Storing the data you'd like to share in a `Dictionary <https://docs.godotengine.org/en/stable/classes/class_dictionary.html>`_
29+
and converting it to/from `JSON <https://docs.godotengine.org/en/stable/classes/class_json.html>`_ is one way you might utilize this feature.
30+
Here's what it might look like if your app is switching from immersive to panel mode and you have a ``current_score`` value you'd like to pass along:
31+
32+
.. code-block:: gdscript
33+
34+
var current_score = 100 # Game state we want to keep in the new mode.
35+
36+
var my_dictionary = {}
37+
my_dictionary["current_score"] = current_score
38+
39+
var my_string = JSON.stringify(my_dictionary)
40+
OpenXRHybridApp.switch_mode(OpenXRHybridApp.HYBRID_MODE_PANEL, my_string)
41+
42+
Then, in your newly launched panel application, you could access ``current_score`` like so:
43+
44+
.. code-block:: gdscript
45+
46+
var my_string = OpenXRHybridApp.get_launch_data()
47+
var my_dictionary = JSON.parse_string(my_string)
48+
var current_score = my_dictionary.get("current_score", 0) # Value we wanted to share
Loading

docs/manual/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ Manual
77
:maxdepth: 1
88
:name: toc-manual
99

10+
hybrid_apps
1011
meta/index
1112

docs/manual/meta/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ Meta
1010
composition_layers
1111
hand_tracking
1212
passthrough
13+
recommended_layer_resolution
1314
scene_manager
1415
spatial_anchors
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Meta Recommended Layer Resolution
2+
=================================
3+
4+
The Meta Recommended Layer Resolution OpenXR extension enables the OpenXR runtime to dynamically change the rendered resolution of an application.
5+
If an application has this extension enabled and is struggling with performance, the runtime may lower the resolution to help preserve a smooth user experience.
6+
7+
Project Settings
8+
----------------
9+
10+
To use Recommended Layer Resolution, the feature must be enabled in your project settings. The setting can be found in **Project Settings** under the **OpenXR** section.
11+
The **Recommended Layer Resolution** setting should be listed under **Extensions**.
12+
13+
.. image:: img/recommended_layer_resolution/recommended_layer_resolution_project_setting.png

plugin/src/main/cpp/register_types.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ void add_plugin_project_settings() {
298298
property_info["name"] = hybrid_app_setting;
299299
property_info["type"] = Variant::Type::INT;
300300
property_info["hint"] = PROPERTY_HINT_ENUM;
301-
property_info["hint_string"] = "Disabled,Start As Immersive,Start As Panel";
301+
property_info["hint_string"] = "Disabled:-1,Start As Immersive:0,Start As Panel:1";
302302
project_settings->add_property_info(property_info);
303303
}
304304
}

samples/hybrid-app-sample/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Hybrid App Sample
2+
3+
> Note: this project requires Godot 4.4 or later
4+
5+
This is a sample project demonstrating hybrid app functionality supported by the Godot OpenXR Vendors plugin.
6+
7+
# Screenshots
8+
9+
![Screenshot](screenshots/hybrid_app_screenshot_01.png)
10+
![Screenshot](screenshots/hybrid_app_screenshot_02.png)
Loading
Loading

0 commit comments

Comments
 (0)