commit a25321afdf253af20b661f2ca0abc33b5b73aa07 Author: Xiang Silian Date: Tue Dec 9 16:29:37 2025 +0800 init diff --git a/demo/bin/gdexample.gdextension b/demo/bin/gdexample.gdextension new file mode 100644 index 0000000..958dbf8 --- /dev/null +++ b/demo/bin/gdexample.gdextension @@ -0,0 +1,20 @@ +[configuration] + +entry_symbol = "example_library_init" +compatibility_minimum = "4.5" +reloadable = true + +[libraries] + +macos.debug = "./libgdexample.macos.template_debug.dylib" +macos.release = "./libgdexample.macos.template_release.dylib" +windows.debug.x86_32 = "./gdexample.windows.template_debug.x86_32.dll" +windows.release.x86_32 = "./gdexample.windows.template_release.x86_32.dll" +windows.debug.x86_64 = "./gdexample.windows.template_debug.x86_64.dll" +windows.release.x86_64 = "./gdexample.windows.template_release.x86_64.dll" +linux.debug.x86_64 = "./libgdexample.linux.template_debug.x86_64.so" +linux.release.x86_64 = "./libgdexample.linux.template_release.x86_64.so" +linux.debug.arm64 = "./libgdexample.linux.template_debug.arm64.so" +linux.release.arm64 = "./libgdexample.linux.template_release.arm64.so" +linux.debug.rv64 = "./libgdexample.linux.template_debug.rv64.so" +linux.release.rv64 = "./libgdexample.linux.template_release.rv64.so" \ No newline at end of file diff --git a/demo/bin/gdexample.windows.template_debug.x86_64.dll b/demo/bin/gdexample.windows.template_debug.x86_64.dll new file mode 100644 index 0000000..0768b61 Binary files /dev/null and b/demo/bin/gdexample.windows.template_debug.x86_64.dll differ diff --git a/demo/bin/gdexample.windows.template_debug.x86_64.exp b/demo/bin/gdexample.windows.template_debug.x86_64.exp new file mode 100644 index 0000000..be1c273 Binary files /dev/null and b/demo/bin/gdexample.windows.template_debug.x86_64.exp differ diff --git a/demo/bin/gdexample.windows.template_debug.x86_64.lib b/demo/bin/gdexample.windows.template_debug.x86_64.lib new file mode 100644 index 0000000..80c3b9c Binary files /dev/null and b/demo/bin/gdexample.windows.template_debug.x86_64.lib differ diff --git a/src/gdexample.cpp b/src/gdexample.cpp new file mode 100644 index 0000000..c104c3e --- /dev/null +++ b/src/gdexample.cpp @@ -0,0 +1,24 @@ +#include "gdexample.h" +#include + +using namespace godot; + +void GDExample::_bind_methods() { +} + +GDExample::GDExample() { + // Initialize any variables here. + time_passed = 0.0; +} + +GDExample::~GDExample() { + // Add your cleanup here. +} + +void GDExample::_process(double delta) { + time_passed += delta; + + Vector2 new_position = Vector2(10.0 + (10.0 * sin(time_passed * 2.0)), 10.0 + (10.0 * cos(time_passed * 1.5))); + + set_position(new_position); +} \ No newline at end of file diff --git a/src/gdexample.h b/src/gdexample.h new file mode 100644 index 0000000..de07138 --- /dev/null +++ b/src/gdexample.h @@ -0,0 +1,23 @@ +#pragma once + +#include + +namespace godot { + +class GDExample : public Sprite2D { + GDCLASS(GDExample, Sprite2D) + +private: + double time_passed; + +protected: + static void _bind_methods(); + +public: + GDExample(); + ~GDExample(); + + void _process(double delta) override; +}; + +} // namespace godot \ No newline at end of file diff --git a/src/gdexample.windows.template_debug.x86_64.obj b/src/gdexample.windows.template_debug.x86_64.obj new file mode 100644 index 0000000..0e24f66 Binary files /dev/null and b/src/gdexample.windows.template_debug.x86_64.obj differ diff --git a/src/register_types.cpp b/src/register_types.cpp new file mode 100644 index 0000000..90d1622 --- /dev/null +++ b/src/register_types.cpp @@ -0,0 +1,36 @@ +#include "register_types.h" + +#include "gdexample.h" + +#include +#include +#include + +using namespace godot; + +void initialize_example_module(ModuleInitializationLevel p_level) { + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { + return; + } + + GDREGISTER_RUNTIME_CLASS(GDExample); +} + +void uninitialize_example_module(ModuleInitializationLevel p_level) { + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { + return; + } +} + +extern "C" { +// Initialization. +GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { + godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); + + init_obj.register_initializer(initialize_example_module); + init_obj.register_terminator(uninitialize_example_module); + init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); + + return init_obj.init(); +} +} \ No newline at end of file diff --git a/src/register_types.h b/src/register_types.h new file mode 100644 index 0000000..02acc69 --- /dev/null +++ b/src/register_types.h @@ -0,0 +1,8 @@ +#pragma once + +#include + +using namespace godot; + +void initialize_example_module(ModuleInitializationLevel p_level); +void uninitialize_example_module(ModuleInitializationLevel p_level); \ No newline at end of file diff --git a/src/register_types.windows.template_debug.x86_64.obj b/src/register_types.windows.template_debug.x86_64.obj new file mode 100644 index 0000000..ee3fb80 Binary files /dev/null and b/src/register_types.windows.template_debug.x86_64.obj differ