diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c75e98c --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Binaries. +bin/ + +# Objects. +*.os + +# SConstruct +.sconf_temp +.sconsign.dblite +*.pyc + +# MacOS +.DS_Store/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..29bd727 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "godot-cpp"] + path = godot-cpp + url = https://github.com/godotengine/godot-cpp.git diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000..79fe653 --- /dev/null +++ b/SConstruct @@ -0,0 +1,25 @@ +#!/usr/bin/env python +import os +import sys + +env = SConscript("godot-cpp/SConstruct") + +env.Append(CPPPATH=["src/"]) +sources = Glob("src/*.cpp") + +if env["platform"] == "osx": + library = env.SharedLibrary( + "bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format( + env["platform"], env["target"], env["platform"], env["target"] + ), + source=sources, + ) +else: + library = env.SharedLibrary( + "bin/libgdexample.{}.{}.{}{}".format( + env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"] + ), + source=sources, + ) + +Default(library) diff --git a/godot-cpp b/godot-cpp new file mode 160000 index 0000000..8dbaf5a --- /dev/null +++ b/godot-cpp @@ -0,0 +1 @@ +Subproject commit 8dbaf5a7ff0b75222948d9e53633f584499f12bf diff --git a/src/example.cpp b/src/example.cpp new file mode 100644 index 0000000..cf594d6 --- /dev/null +++ b/src/example.cpp @@ -0,0 +1,27 @@ +#include "example.hpp" + +#include + +#include +#include +#include + +using namespace godot; + +void Example::_bind_methods() +{ + ClassDB::bind_method(D_METHOD("hello_extension"), &Example::hello_extension); +} + +Example::Example() +{ +} + +Example::~Example() +{ +} + +void Example::hello_extension() +{ + UtilityFunctions::print("Hello GDExtension!"); +} diff --git a/src/example.hpp b/src/example.hpp new file mode 100644 index 0000000..2fef158 --- /dev/null +++ b/src/example.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include +#include +#include + +#include + +using namespace godot; + +class Example : public Node +{ + GDCLASS(Example, Node); + +protected: + static void _bind_methods(); + +public: + Example(); + ~Example(); + + void hello_extension(); +}; diff --git a/src/register_types.cpp b/src/register_types.cpp new file mode 100644 index 0000000..b419c45 --- /dev/null +++ b/src/register_types.cpp @@ -0,0 +1,29 @@ +#include "register_types.h" + +#include + +#include +#include +#include + +#include "example.hpp" + +using namespace godot; + +void initialize_example_module(ModuleInitializationLevel p_level) +{ + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) + { + return; + } + + ClassDB::register_class(); +} + +void uninitialize_example_module(ModuleInitializationLevel p_level) +{ + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) + { + return; + } +} diff --git a/src/register_types.h b/src/register_types.h new file mode 100644 index 0000000..00bddb9 --- /dev/null +++ b/src/register_types.h @@ -0,0 +1,7 @@ +#pragma once + +#include +using namespace godot; + +void initialize_example_module(ModuleInitializationLevel p_level); +void uninitialize_example_module(ModuleInitializationLevel p_level);