C++ bindings for the Godot script API
 
 
 
 
 
 
Go to file
George Marques 8eb6f129f8 Set initialization level to CORE
This should eventually be configurable with user callbacks, but for now
assume the lowest level to ensure the initialization is called.
2021-09-27 23:08:10 +10:00
.github CI: Disable test build to prepare for 4.0 extensions merge 2021-09-27 14:37:36 +02:00
godot-headers@68174528c9 headers: Track tag godot-3.3.3-stable 2021-09-26 13:20:50 +02:00
godot-headers-temp Set initialization level to CORE 2021-09-27 23:08:10 +10:00
include/godot_cpp Silence delete compile warning in memory.h/cpp on Windows 2021-09-27 23:08:09 +10:00
misc Replace bindgins to work with extensions 2021-09-27 23:08:08 +10:00
src Set initialization level to CORE 2021-09-27 23:08:10 +10:00
test Added TYPED_METHOD_BIND and c++17 flags to windows build and moved test project files 2021-09-27 23:08:09 +10:00
.clang-format Update clang-format to version 11 2021-02-28 16:57:34 -03:00
.gitattributes Getting this to compile on mac os x 2017-06-16 23:50:48 +10:00
.gitignore Added TYPED_METHOD_BIND and c++17 flags to windows build and moved test project files 2021-09-27 23:08:09 +10:00
.gitmodules Rename godot_headers to godot-headers to match upstream rename 2021-02-26 10:07:38 +01:00
CMakeLists.txt Do not override build path 2021-09-27 23:08:09 +10:00
LICENSE.md Update copyright statement to 'Godot Engine contributors' 2021-02-26 10:19:37 +01:00
Makefile Replace bindgins to work with extensions 2021-09-27 23:08:08 +10:00
README.md Add readme file (stub) 2021-09-27 23:08:08 +10:00
SConstruct Added TYPED_METHOD_BIND and c++17 flags to windows build and moved test project files 2021-09-27 23:08:09 +10:00
binding_generator.py Fix print file list 2021-09-27 23:08:10 +10:00

README.md

godot-cpp

C++ bindings for the Godot extension API.

Note: this is a work in progress for the extension system included in Godot 4.0

Stub

Both this whole bindings system and this document are still work in progress and thus it is still incomplete. It will be improved once the extension API is settled.

How to use

It's a bit similar to what it was for 3.x but also a bit different.

Compiling this repository generates a static library to be linked with your shared lib, just like before.

To use the shared lib in your Godot project you'll need a .gdextension file, which replaces what was the .gdnlibbefore. Follow the example:

[configuration]

entry_symbol = "example_library_init"

[libraries]

Linux.64 = "bin/x11/libgdexample.so"

The entry_symbol is the name of the function that initializes your library. It should be similar to following layout:

extern "C" {
GDNativeBool GDN_EXPORT example_library_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) {
	GDNativeBool result = godot::GDExtensionBinding::init(p_interface, p_library, r_initialization);

	if (result) {
		register_example_types();
	}

	return result;
}
}

The register_example_types() should register the classes in ClassDB, very like a Godot module would do.

using namespace godot;
void register_example_types() {
	ClassDB::register_class<Example>();
}

Extension registering has not yet been added to the Godot editor, so to make it recognize your extension you need to add the following section to your project.godot:

[native_extensions]

paths=["res://example.gdextension"]

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

Example

Check the project in the test folder for an example on how to use and register different things.

This project isn't yet made to run in CI.

Issues

This really needs to be tested and very likely has things missing that weren't noticed yet. Use at your own risk (and contribute back with reports and fixes if you can).