Mirror of godotengine/godot-cpp
  • C++ 78.2%
  • Python 13.8%
  • CMake 6.5%
  • GDScript 1%
  • NASL 0.2%
  • Other 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
David Snopek 507ed9d840
Merge pull request #2035 from dsnopek/v10-not-beta-anymore
Remove text from README saying v10 is beta
2026-09-15 07:22:56 -05:00
.github Merge pull request #2034 from dsnopek/require-api-version 2026-08-11 17:28:52 -05:00
cmake Merge pull request #2034 from dsnopek/require-api-version 2026-08-11 17:28:52 -05:00
gdextension Require 'api_version' and allow extensions to provide a default 2026-07-30 10:42:01 -05:00
include/godot_cpp Merge pull request #2051 from Togira123/sync_more_templates 2026-09-02 08:53:50 -05:00
misc Require 'api_version' and allow extensions to provide a default 2026-07-30 10:42:01 -05:00
natvis Add godot-cpp.natvis debug visualizers 2026-06-04 08:05:42 +02:00
src Sync math structs by adding constexpr constructors/operators 2026-08-25 18:58:25 -04:00
test sync more templates 2026-09-01 19:43:38 +02:00
tools Fix looking for extension_api.json with custom gdextension_dir 2026-08-31 12:28:41 -05:00
.clang-format Don't right-align escaped newlines, e.g. for #define. This has previously led to long diffs in the commit history. 2026-06-08 15:06:15 +02:00
.editorconfig CI: Various version bumps; sync with main repo 2025-04-26 12:23:07 -05:00
.gdignore Add .gdignore file to godot-cpp, for use as submodule in Godot projects 2022-12-22 16:01:03 +01:00
.git-blame-ignore-revs Ignore right-align escaped newlines commit. 2026-06-08 15:06:37 +02:00
.gitattributes Add .editorconfig, consolidate .gitattributes 2024-06-25 08:46:06 -05:00
.gitignore Modernise Existing CMakeLists.txt 2024-11-21 11:01:00 +10:30
.gitmodules Remove godot-headers submodule, copy files directly 2022-03-15 10:19:07 +01:00
.pre-commit-config.yaml Require 'api_version' and allow extensions to provide a default 2026-07-30 10:42:01 -05:00
binding_generator.py Always swap in generated move operator 2026-09-08 15:22:13 -05:00
build_profile.py sync more templates 2026-09-01 19:43:38 +02:00
CMakeLists.txt Require 'api_version' and allow extensions to provide a default 2026-07-30 10:42:01 -05:00
doc_source_generator.py Generate GDExtension interface header and loader from JSON 2025-12-18 12:09:41 -06:00
LICENSE.md Sync license copyright with upstream GH-70885 2023-01-10 16:15:31 +01:00
make_interface_header.py gdextension: Sync with upstream commit 481f36ed20520db3195a09cc309abf48c03cf51a (4.6-rc1) 2026-01-15 08:35:40 -06:00
Makefile Require 'api_version' and allow extensions to provide a default 2026-07-30 10:42:01 -05:00
pyproject.toml CI: Various version bumps; sync with main repo 2025-04-26 12:23:07 -05:00
README.md Merge pull request #2035 from dsnopek/v10-not-beta-anymore 2026-09-15 07:22:56 -05:00
SConstruct Merge pull request #2034 from dsnopek/require-api-version 2026-08-11 17:28:52 -05:00

godot-cpp

Note

For GDNative (Godot 3.x), switch to the 3.x or the 3.6 branch.

This repository contains the C++ bindings for the Godot Engine's GDExtensions API.

Versioning

Starting with version 10.x, godot-cpp is versioned independently from Godot. Using the api_version parameter (see below), godot-cpp v10 can target Godot 4.3 or later.

Compatibility

GDExtensions targeting an earlier version of Godot should work in later minor versions, but not vice-versa. For example, a GDExtension targeting Godot 4.3 should work just fine in Godot 4.4, but one targeting Godot 4.4 won't work in Godot 4.3.

You can specify which version you are targeting with the api_version option:

scons api_version=4.3

... or by providing a custom extension_api.json generated by the Godot version you are targeting:

godot --dump-extension-api
scons custom_api_file=extension_api.json

Extension authors can provide a default target API version by passing it to godot-cpp's SConstruct, for example:

env = SConscript("godot-cpp/SConstruct", {"api_version": "4.7"})

This is highly recommended! It allows the extension author to ensure that their extension is built with a version that provides all the necessary features by default.

Contributing

We greatly appreciate help in maintaining and extending this project. If you wish to help out, please visit the godot-cpp section of the Contributing docs.

Getting started

You need the same C++ pre-requisites installed that are required for the godot repository. Follow the official build instructions for your target platform.

Building your extension will create a shared library. To use this in your Godot project you'll need a .gdextension file, for example:

[configuration]

entry_symbol = "example_library_init"
compatibility_minimum = "4.1"

[libraries]

macos.debug = "res://bin/libgdexample.macos.debug.framework"
macos.release = "res://bin/libgdexample.macos.release.framework"
windows.debug.x86_64 = "res://bin/libgdexample.windows.debug.x86_64.dll"
windows.release.x86_64 = "res://bin/libgdexample.windows.release.x86_64.dll"
linux.debug.x86_64 = "res://bin/libgdexample.linux.debug.x86_64.so"
linux.release.x86_64 = "res://bin/libgdexample.linux.release.x86_64.so"
# Repeat for other architectures to support arm64, rv64, etc.

See the example.gdextension used in the template project for a complete example.

The entry_symbol is the name of the function that initializes your library, for example:

extern "C" {

// Initialization.

GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
	godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);

	init_obj.register_initializer(initialize_example_module);
	init_obj.register_terminator(uninitialize_example_module);
	init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);

	return init_obj.init();
}
}

The initialize_example_module() should register the classes in ClassDB, similar to a Godot module:

using namespace godot;
void initialize_example_module(ModuleInitializationLevel p_level) {
	if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
		return;
	}
	GDREGISTER_CLASS(Example);
}

Any node and resource you register will be available in the corresponding Create... dialog. Any class will be available to scripting as well.

Examples and templates

See the godot-cpp-template project for a generic reusable template.

Or checkout the code for the Summator example as shown in the official documentation.