Created game template

main
Sara 2024-03-07 20:16:30 +01:00
parent 3ec351897d
commit 09035af13b
21 changed files with 76 additions and 272 deletions

8
.gitattributes vendored
View File

@ -1,2 +1,10 @@
# 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

View File

@ -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 <code>```</code> tags.
validations:
required: true

View File

@ -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.

View File

@ -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 }}

29
.gitignore vendored
View File

@ -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
@ -48,3 +48,4 @@ compile_commands.json
# VSCode
.vscode/*
!.vscode/extensions.json
.cache/

6
.gitmodules vendored
View File

@ -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

View File

@ -1,6 +0,0 @@
{
"recommendations": [
"ms-vscode.cpptools-extension-pack",
"ms-python.python"
]
}

View File

@ -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<CLASS-NAME>();`.

View File

@ -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"])

View File

@ -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"

View File

@ -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"

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -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"

View File

@ -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<YourClass>();
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();
}
return init_obj.init();
}
}

1
src/utils Submodule

@ -0,0 +1 @@
Subproject commit 988d39bdb446f107d2b5d37e29d89d75f583768b