Skip to content

Commit

Permalink
Register singletons the usual way (GodotVR#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsnopek authored Jan 17, 2024
1 parent aa57a3a commit c1569d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions demo/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ func _ready():
if xr_interface and xr_interface.is_initialized():
var vp: Viewport = get_viewport()
vp.use_xr = true
scene_capture = OpenXRFbSceneCaptureExtensionWrapper.get_singleton()

scene_capture = Engine.get_singleton("OpenXRFbSceneCaptureExtensionWrapper")
scene_capture.connect("scene_capture_completed", _on_scene_capture_completed)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ OpenXRFbSceneCaptureExtensionWrapper::~OpenXRFbSceneCaptureExtensionWrapper() {

void OpenXRFbSceneCaptureExtensionWrapper::_bind_methods() {

ClassDB::bind_static_method("OpenXRFbSceneCaptureExtensionWrapper", D_METHOD("get_singleton"), &OpenXRFbSceneCaptureExtensionWrapper::get_singleton);
ClassDB::bind_method(D_METHOD("is_scene_capture_supported"), &OpenXRFbSceneCaptureExtensionWrapper::is_scene_capture_supported);
ClassDB::bind_method(D_METHOD("is_scene_capture_enabled"), &OpenXRFbSceneCaptureExtensionWrapper::is_scene_capture_enabled);
ClassDB::bind_method(D_METHOD("request_scene_capture"), &OpenXRFbSceneCaptureExtensionWrapper::request_scene_capture);
Expand Down
12 changes: 9 additions & 3 deletions godotopenxrmeta/src/main/cpp/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <gdextension_interface.h>

#include <godot_cpp/classes/engine.hpp>
#include <godot_cpp/core/class_db.hpp>
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/godot.hpp>
Expand All @@ -51,6 +52,13 @@ void initialize_plugin_module(ModuleInitializationLevel p_level)
OpenXRFbSceneCaptureExtensionWrapper::get_singleton()->register_extension_wrapper();
} break;

case MODULE_INITIALIZATION_LEVEL_SERVERS:
break;

case MODULE_INITIALIZATION_LEVEL_SCENE: {
Engine::get_singleton()->register_singleton("OpenXRFbSceneCaptureExtensionWrapper", OpenXRFbSceneCaptureExtensionWrapper::get_singleton());
} break;

case MODULE_INITIALIZATION_LEVEL_EDITOR: {
ClassDB::register_class<OpenXREditorExportPlugin>();
ClassDB::register_class<MetaEditorExportPlugin>();
Expand All @@ -59,8 +67,6 @@ void initialize_plugin_module(ModuleInitializationLevel p_level)
EditorPlugins::add_by_type<MetaEditorPlugin>();
} break;

case MODULE_INITIALIZATION_LEVEL_SERVERS:
case MODULE_INITIALIZATION_LEVEL_SCENE:
case MODULE_INITIALIZATION_LEVEL_MAX:
break;
}
Expand All @@ -80,7 +86,7 @@ extern "C"

init_obj.register_initializer(initialize_plugin_module);
init_obj.register_terminator(terminate_plugin_module);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_CORE);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);

return init_obj.init();
}
Expand Down

0 comments on commit c1569d3

Please sign in to comment.