diff --git a/.gitattributes b/.gitattributes index 9893794..6f2fcd5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,11 @@ # Normalize EOL for all files that Git considers text files. * text=auto eol=lf +*.png filter=lfs diff=lfs merge=lfs -text +*.blend filter=lfs diff=lfs merge=lfs -text +*.fbx filter=lfs diff=lfs merge=lfs -text +*.glb filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text +*.apng filter=lfs diff=lfs merge=lfs -text +*.jpeg filter=lfs diff=lfs merge=lfs -text +*.gif filter=lfs diff=lfs merge=lfs -text *.kra filter=lfs diff=lfs merge=lfs -text diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 92f12af..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Bug report -description: Report a bug with the godot-cpp template -body: - -- type: markdown - attributes: - value: | - - Write a descriptive issue title above. - - Search [open](https://github.com/godotengine/godot-cpp-template/issues) and [closed](https://github.com/godotengine/godot-cpp-template/issues?q=is%3Aissue+is%3Aclosed) issues to ensure it has not already been reported. -- type: input - attributes: - label: Godot version - description: > - Specify the Git commit hash of your Godot build. - placeholder: v4.0.stable.official [92bee43ad] - validations: - required: true - -- type: input - attributes: - label: godot-cpp version - description: > - Specify the Git commit hash of the godot-cpp submodule in your project. You can run `git status` inside the folder to check it. - placeholder: v4.0.stable.official [9d1c396c5] - validations: - required: true - -- type: input - attributes: - label: System information - description: | - Specify the OS version. - placeholder: Windows 10 - validations: - required: true - -- type: textarea - attributes: - label: Issue description - description: | - Describe your issue briefly. What doesn't work, and how do you expect it to work instead? - You can include images or videos with drag and drop, and format code blocks or logs with ``` tags. - validations: - required: true \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index f787bec..0000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,14 +0,0 @@ -blank_issues_enabled: false - -contact_links: - - name: Godot proposals - url: https://github.com/godotengine/godot-proposals - about: Please submit feature proposals on the Godot proposals repository, not here. - - - name: Godot documentation repository - url: https://github.com/godotengine/godot-docs - about: Please report issues with documentation on the Godot documentation repository, not here. - - - name: Godot community channels - url: https://godotengine.org/community - about: Please ask for technical support on one of the other community channels, not here. diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml deleted file mode 100644 index 26b6d6c..0000000 --- a/.github/workflows/builds.yml +++ /dev/null @@ -1,123 +0,0 @@ -name: Builds - -on: push - -env: - LIBNAME: example - -concurrency: - group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-macos - cancel-in-progress: true - -jobs: - build: - runs-on: ${{matrix.os}} - name: ${{matrix.name}} - strategy: - fail-fast: false - matrix: - include: - - identifier: windows-debug - os: windows-latest - name: 🏁 Windows Debug - target: template_debug - platform: windows - arch: x86_64 - - identifier: windows-release - os: windows-latest - name: 🏁 Windows Release - target: template_release - platform: windows - arch: x86_64 - - identifier: macos-debug - os: macos-latest - name: 🍎 macOS (universal) Debug - target: template_debug - platform: macos - arch: universal - - identifier: macos-release - os: macos-latest - name: 🍎 macOS (universal) Release - target: template_release - platform: macos - arch: universal - - identifier: linux-debug - os: ubuntu-latest - name: 🐧 Linux Debug - runner: ubuntu-20.04 - target: template_debug - platform: linux - arch: x86_64 - - identifier: linux-release - os: ubuntu-latest - name: 🐧 Linux Release - runner: ubuntu-20.04 - target: template_release - platform: linux - arch: x86_64 - - steps: - - name: Checkout project - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.x' - - - name: Set up SCons - shell: bash - run: | - python -c "import sys; print(sys.version)" - python -m pip install scons - scons --version - - name: Linux dependencies - if: ${{ matrix.platform == 'linux' }} - run: | - sudo apt-get update -qq - sudo apt-get install -qqq build-essential pkg-config - - name: Setup MinGW for Windows/MinGW build - if: ${{ matrix.platform == 'windows' }} - uses: egor-tensin/setup-mingw@v2 - with: - version: 12.2.0 - - - name: Compile godot-cpp - shell: sh - run: | - scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' - working-directory: godot-cpp - - - name: Compile Extension - shell: sh - run: | - scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' - - name: Delete compilation files - if: ${{ matrix.platform == 'windows' }} - run: | - Remove-Item bin/* -Include *.exp,*.lib,*.pdb -Force - - name: Upload artifact - uses: actions/upload-artifact@v3 - with: - name: ${{ github.event.repository.name }} - path: | - ${{ github.workspace }}/bin/* - - name: Archive Release - uses: thedoctor0/zip-release@0.7.1 - with: - type: 'zip' - filename: '${{ env.LIBNAME }}.${{ matrix.platform }}.${{ matrix.arch }}.zip' - path: '${{ github.workspace }}/bin/' - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - - - name: Create and upload asset - if: success() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: "${{ env.LIBNAME }}.${{ matrix.platform }}.${{ matrix.arch }}.zip" - omitNameDuringUpdate: true - omitBodyDuringUpdate: true - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index de143d4..d8c2872 100644 --- a/.gitignore +++ b/.gitignore @@ -2,20 +2,20 @@ .godot/ # Ignore library files but not the gdextension file -demo/bin/* -!demo/bin/android -demo/bin/android/* -!demo/bin/android/.gitkeep -!demo/bin/linux -demo/bin/linux/* -!demo/bin/linux/.gitkeep -!demo/bin/macos -demo/bin/macos/* -!demo/bin/macos/.gitkeep -!demo/bin/windows -demo/bin/windows/* -!demo/bin/windows/.gitkeep -!demo/bin/*.gdextension +godot/bin/* +!godot/bin/android +godot/bin/android/* +!godot/bin/android/.gitkeep +!godot/bin/linux +godot/bin/linux/* +!godot/bin/linux/.gitkeep +!godot/bin/macos +godot/bin/macos/* +!godot/bin/macos/.gitkeep +!godot/bin/windows +godot/bin/windows/* +!godot/bin/windows/.gitkeep +!godot/bin/*.gdextension .sconsign*.dblite # Ignore custom.py @@ -47,4 +47,5 @@ compile_commands.json # VSCode .vscode/* -!.vscode/extensions.json \ No newline at end of file +!.vscode/extensions.json +.cache/ diff --git a/.gitmodules b/.gitmodules index 5f8a098..5c3d02c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,8 @@ [submodule "godot-cpp"] path = godot-cpp url = https://github.com/godotengine/godot-cpp.git - branch = 4.0 + branch = 4.1 + +[submodule "src/utils"] + path = src/utils + url = https://git.saragerretsen.nl/Sara/godot-cpp-utils.git diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index d1f137b..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "recommendations": [ - "ms-vscode.cpptools-extension-pack", - "ms-python.python" - ] -} \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 565d4da..0000000 --- a/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# godot-cpp template -This repository serves as a quickstart template for GDExtension development with Godot 4.0+. - -## Contents -* An empty Godot project (`demo/`) -* godot-cpp as a submodule (`godot-cpp/`) -* GitHub Issues template (`.github/ISSUE_TEMPLATE.yml`) -* GitHub CI/CD to publish your library packages when creating a release (`.github/workflows/builds.yml`) -* preconfigured source files for C++ development of the GDExtension (`src/`) - -## Usage -To use this template, log in to github and click the green "Use this template" button at the top of the repository page. -This will let you create a copy of this repository with a clean git history. Make sure you clone the correct branch as these are configured for development of their respective Godot development branches and differ from each other. Refer to the docs to see what changed between the versions. - -For getting started after cloning your own copy to your local machine, you should: -* initialize the godot-cpp git submodule via `git submodule update --init` -* change the name of your library - * change the name of the compiled library file inside the `SConstruct` file by modifying the `libname` string. - * change the pathnames of the to be loaded library name inside the `demo/bin/example.gdextension` file. By replacing `libgdexample` to the name specified in your `SConstruct` file. - * change the name of the `demo/bin/example.gdextension` file -* change the `entry_symbol` string inside your `demo/bin/your-extension.gdextension` file to be configured for your GDExtension name. This should be the same as the `GDExtensionBool GDE_EXPORT` external C function. As the name suggests, this sets the entry function for your GDExtension to be loaded by the Godot editors C API. -* register the classes you want Godot to interact with inside the `register_types.cpp` file in the initialization method (here `initialize_gdextension_types`) in the syntax `ClassDB::register_class();`. diff --git a/SConstruct b/SConstruct index 75c2372..c335828 100644 --- a/SConstruct +++ b/SConstruct @@ -11,8 +11,8 @@ def validate_parent_dir(key, val, env): raise UserError("'%s' is not a directory: %s" % (key, os.path.dirname(val))) -libname = "EXTENSION-NAME" -projectdir = "demo" +libname = "EXAMPLE" +projectdir = "godot" localEnv = Environment(tools=["default"], PLATFORM="") @@ -51,7 +51,7 @@ env.Alias("compiledb", compilation_db) env = SConscript("godot-cpp/SConstruct", {"env": env, "customs": customs}) env.Append(CPPPATH=["src/"]) -sources = Glob("src/*.cpp") +sources = Glob("src/*.cpp") + Glob("src/utils/*.cpp") file = "{}{}{}".format(libname, env["suffix"], env["SHLIBSUFFIX"]) diff --git a/demo/bin/example.gdextension b/demo/bin/example.gdextension deleted file mode 100644 index 99c1746..0000000 --- a/demo/bin/example.gdextension +++ /dev/null @@ -1,23 +0,0 @@ -[configuration] - -entry_symbol = "example_library_init" -compatibility_minimum = "4.1" - -[libraries] - -macos.debug = "res://bin/libgdexample.macos.template_debug.framework" -macos.release = "res://bin/libgdexample.macos.template_release.framework" -windows.debug.x86_32 = "res://bin/libgdexample.windows.template_debug.x86_32.dll" -windows.release.x86_32 = "res://bin/libgdexample.windows.template_release.x86_32.dll" -windows.debug.x86_64 = "res://bin/libgdexample.windows.template_debug.x86_64.dll" -windows.release.x86_64 = "res://bin/libgdexample.windows.template_release.x86_64.dll" -linux.debug.x86_64 = "res://bin/libgdexample.linux.template_debug.x86_64.so" -linux.release.x86_64 = "res://bin/libgdexample.linux.template_release.x86_64.so" -linux.debug.arm64 = "res://bin/libgdexample.linux.template_debug.arm64.so" -linux.release.arm64 = "res://bin/libgdexample.linux.template_release.arm64.so" -linux.debug.rv64 = "res://bin/libgdexample.linux.template_debug.rv64.so" -linux.release.rv64 = "res://bin/libgdexample.linux.template_release.rv64.so" -android.debug.x86_64 = "res://bin/libgdexample.android.template_debug.x86_64.so" -android.release.x86_64 = "res://bin/libgdexample.android.template_release.x86_64.so" -android.debug.arm64 = "res://bin/libgdexample.android.template_debug.arm64.so" -android.release.arm64 = "res://bin/libgdexample.android.template_release.arm64.so" diff --git a/godot/bin/EXAMPLE.gdextension b/godot/bin/EXAMPLE.gdextension new file mode 100644 index 0000000..6630268 --- /dev/null +++ b/godot/bin/EXAMPLE.gdextension @@ -0,0 +1,23 @@ +[configuration] + +entry_symbol = "EXAMPLE_library_init" +compatibility_minimum = "4.1" + +[libraries] + +macos.debug = "res://bin/macos/libEXAMPLE.macos.template_debug.framework" +macos.release = "res://bin/macos/libEXAMPLE.macos.template_release.framework" +windows.debug.x86_32 = "res://bin/windows/libEXAMPLE.windows.template_debug.x86_32.dll" +windows.release.x86_32 = "res://bin/windows/libEXAMPLE.windows.template_release.x86_32.dll" +windows.debug.x86_64 = "res://bin/windows/libEXAMPLE.windows.template_debug.x86_64.dll" +windows.release.x86_64 = "res://bin/windows/libEXAMPLE.windows.template_release.x86_64.dll" +linux.debug.x86_64 = "res://bin/linux/libEXAMPLE.linux.template_debug.x86_64.so" +linux.release.x86_64 = "res://bin/linux/libEXAMPLE.linux.template_release.x86_64.so" +linux.debug.arm64 = "res://bin/linux/libEXAMPLE.linux.template_debug.arm64.so" +linux.release.arm64 = "res://bin/linux/libEXAMPLE.linux.template_release.arm64.so" +linux.debug.rv64 = "res://bin/linux/libEXAMPLE.linux.template_debug.rv64.so" +linux.release.rv64 = "res://bin/linux/libEXAMPLE.linux.template_release.rv64.so" +android.debug.x86_64 = "res://bin/linux/libEXAMPLE.android.template_debug.x86_64.so" +android.release.x86_64 = "res://bin/linux/libEXAMPLE.android.template_release.x86_64.so" +android.debug.arm64 = "res://bin/linux/libEXAMPLE.android.template_debug.arm64.so" +android.release.arm64 = "res://bin/linux/libEXAMPLE.android.template_release.arm64.so" diff --git a/demo/bin/android/.gitkeep b/godot/bin/android/.gitkeep similarity index 100% rename from demo/bin/android/.gitkeep rename to godot/bin/android/.gitkeep diff --git a/demo/bin/linux/.gitkeep b/godot/bin/linux/.gitkeep similarity index 100% rename from demo/bin/linux/.gitkeep rename to godot/bin/linux/.gitkeep diff --git a/demo/bin/macos/.gitkeep b/godot/bin/macos/.gitkeep similarity index 100% rename from demo/bin/macos/.gitkeep rename to godot/bin/macos/.gitkeep diff --git a/demo/bin/windows/.gitkeep b/godot/bin/windows/.gitkeep similarity index 100% rename from demo/bin/windows/.gitkeep rename to godot/bin/windows/.gitkeep diff --git a/demo/icon.svg b/godot/icon.svg similarity index 100% rename from demo/icon.svg rename to godot/icon.svg diff --git a/demo/icon.svg.import b/godot/icon.svg.import similarity index 100% rename from demo/icon.svg.import rename to godot/icon.svg.import diff --git a/demo/project.godot b/godot/project.godot similarity index 85% rename from demo/project.godot rename to godot/project.godot index 9c5c174..3bf2c7b 100644 --- a/demo/project.godot +++ b/godot/project.godot @@ -11,5 +11,5 @@ config_version=5 [application] config/name="godot cpp template" -config/features=PackedStringArray("4.1", "Forward Plus") +config/features=PackedStringArray("4.2", "Forward Plus") config/icon="res://icon.svg" diff --git a/src/register_types.cpp b/src/register_types.cpp index 2c86044..4e684dd 100644 --- a/src/register_types.cpp +++ b/src/register_types.cpp @@ -8,28 +8,27 @@ using namespace godot; void initialize_gdextension_types(ModuleInitializationLevel p_level) { - if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { - return; - } - //ClassDB::register_class(); + if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { + return; + } } -void uninitialize_gdextension_types(ModuleInitializationLevel p_level) { - if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { - return; - } -} +//void uninitialize_gdextension_types(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, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) - { - GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); - init_obj.register_initializer(initialize_gdextension_types); - init_obj.register_terminator(uninitialize_gdextension_types); - init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); + // Initialization + GDExtensionBool GDE_EXPORT EXAMPLE_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) + { + GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); + init_obj.register_initializer(initialize_gdextension_types); +// init_obj.register_terminator(uninitialize_gdextension_types); + init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); - return init_obj.init(); - } -} \ No newline at end of file + return init_obj.init(); + } +} diff --git a/src/register_types.h b/src/register_types.h index e6fe2b0..53a91d4 100644 --- a/src/register_types.h +++ b/src/register_types.h @@ -4,4 +4,4 @@ void initialize_gdextension_types(); void uninitialize_gdextension_types(); -#endif // EXAMPLE_REGISTER_TYPES_H \ No newline at end of file +#endif // EXAMPLE_REGISTER_TYPES_H diff --git a/src/utils b/src/utils new file mode 160000 index 0000000..988d39b --- /dev/null +++ b/src/utils @@ -0,0 +1 @@ +Subproject commit 988d39bdb446f107d2b5d37e29d89d75f583768b