Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register singletons the usual way #73

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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