This repository is for showcasing the new GDExtension system in Godot 4. The C++ code is from the Custom modules example of the Godot docs.
-> Feel free to use this repository as a template for your GDExtensions
This repository is being updated regularly to work with the latest version of the master branch. If you can't compile the extension, please open an issue.
Most Recent Update: Godot 4 Alpha 15 working
If you can't compile the extension, please open an issue with the error log in your terminal and/or the error log in the editor (if you can't run the example scene).
PRs for improvements are very welcome!
For the initial build you can run the vscode task initial-build-extension
. This compiles both godot-cpp and the extension. For all subsequent builds, you only need to run the task build-extension
.
To compile the extension you need to follow these steps:
-
Click on the green "Use this template" button to generate the repository for you
-
Clone the extension recursively from this repository
# --recursive to automatically load the submodule godot-cpp
# The git adress can be found under the green "Code" dropdown menu
git clone --recursive (--GITHUB ADRESS--)
- Make sure you are in the top level of the repository
pwd
.../GDExtensionSummator
- Go inside the godot-cpp folder
cd godot-cpp
- Compile godot-cpp and generate bindings (only need to do this once when starting development or when there is an update of the submodule)
scons target=debug generate_bindings=yes
- Go back to the top level of the directory
cd ..
- Compile the extension
scons target=debug
After compiling the extension succesfully, you can now use the Summator Class inside Godot 🎉
func _ready() -> void:
var s = Summator.new()
s.add(10)
s.add(20)
s.add(30)
print(s.get_total())
# outputs 60 in the console
s.reset()