Skip to content

mrt-prodz/docker-godot-gdextension-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Building Godot 4 GDExtension C++ example with Docker

Requirements

Instructions

[Windows]

You have to run all the following commands from a Git Bash prompt.

Clone this repository

git clone https://github.com/mrt-prodz/docker-godot-gdextension-builder
cd docker-godot-gdextension-builder

Building the docker image

Run the following command to build mrt-prodz/godot-gdextension-builder:latest docker image:

docker build -t mrt-prodz/godot-gdextension-builder:latest .

or you can use docker compose:

docker compose build

This docker image will contain the following softwares:

Getting the C++ bindings for the Godot Engine's GDExtensions API

Clone Godot 4.2 stable branch and initialize the submodules:

git clone -b 4.2 https://github.com/godotengine/godot-cpp
cd godot-cpp
git submodule update --init
cd ..

Building Godot GDExtension C++ example

The source files in the src directory of this repository are copies from the Godot 4.2 documentation.

From within this repository root directory:

[Windows] and [Linux]

You should now be able to build by just running the following command:

./build.sh

If your operating system is not detected automatically, you can still run one of the following command manually:

[Windows]

winpty docker run --rm -it -v /$(pwd):/mnt mrt-prodz/godot-gdextension-builder scons platform=windows -j4

[Linux]

docker run --rm -it -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -u $(id -u):$(id -g) -v ${PWD}:/mnt mrt-prodz/godot-gdextension-builder scons platform=linux -j4

Using your new extension

In order to use your newly built GDExtension you need to run a version of Godot equal or higher than the repository version you cloned.

For this repository, open Godot 4.2, create a project in the demo folder and you should see the GDExtension loading automatically.

Create a new 2D Scene, press CTRL + a then add a GDExample Node. You should see the position of the Node randomly moving.

Note

This repository was made to help people get started with Godot GDExtension C++ development without cluttering their operating system with various packages and softwares.

We use Godot 4.2 stable branch but if you would like to use a more recent version you will have to change 4.2 with another branch when cloning the godot-cpp repository.

Simply change the version in the git clone -b 4.x https://github.com/godotengine/godot-cpp command.

The GDExtension example in this repository is coming from the Godot 4.2 documentation. There is no Engine.is_editor_hint() check in the process method in order to avoid running the code inside the Godot editor. Keep this in mind if you start experimenting with heavy calculations to avoid crashing the editor.

Resources

GDExtension C++ example

About

Building Godot 4 GDExtension C++ example with Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published