aboutsummaryrefslogtreecommitdiff
path: root/extension/src/register_types.cpp
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-01-25 02:07:01 +0100
committer George L. Albany <Megacake1234@gmail.com>2023-01-25 02:07:01 +0100
commit5371a960c9f0665d7de594cc5e274db225620207 (patch)
treef0c5d01c2ae8c2293b60af9b120440730021ccc3 /extension/src/register_types.cpp
parentc16b58ddb07a4f814a4efa1dc3bf72e7bbe5f932 (diff)
feat(build): Implement scons building
feat(engine): Integrate basic Godot project feat(test): Demonstrate Godot using extension feat(dependency): Add OV2-compiler as deps submodule feat(dependency): Add godot-cpp as a submodule feat(git): Ignore Godot 4 files feat(docs): Updated readme with instructions feat: Can call `TestSingleton.hello_singleton()` from GDScript Adds basic workflow support but that is currently disabled
Diffstat (limited to 'extension/src/register_types.cpp')
-rw-r--r--extension/src/register_types.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/extension/src/register_types.cpp b/extension/src/register_types.cpp
new file mode 100644
index 0000000..775e6c3
--- /dev/null
+++ b/extension/src/register_types.cpp
@@ -0,0 +1,51 @@
+#include "register_types.h"
+#include <gdextension_interface.h>
+#include <godot_cpp/core/class_db.hpp>
+#include <godot_cpp/core/defs.hpp>
+#include <godot_cpp/godot.hpp>
+#include <godot_cpp/classes/engine.hpp>
+
+#include "TestSingleton.hpp"
+
+using namespace godot;
+using namespace OpenVic2;
+
+static TestSingleton *_test_singleton;
+
+void initialize_openvic2_types(ModuleInitializationLevel p_level)
+{
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
+
+ ClassDB::register_class<TestSingleton>();
+
+ _test_singleton = memnew(TestSingleton);
+ Engine::get_singleton()->register_singleton("TestSingleton", TestSingleton::get_singleton());
+}
+
+void uninitialize_openvic2_types(ModuleInitializationLevel p_level) {
+ if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
+ return;
+ }
+
+ Engine::get_singleton()->unregister_singleton("TestSingleton");
+ memdelete(_test_singleton);
+}
+
+extern "C"
+{
+
+ // Initialization.
+
+ GDExtensionBool GDE_EXPORT openvic2_library_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization)
+ {
+ GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
+
+ init_obj.register_initializer(initialize_openvic2_types);
+ init_obj.register_terminator(uninitialize_openvic2_types);
+ init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
+
+ return init_obj.init();
+ }
+} \ No newline at end of file