Today a major change was made to the way you extend the Godot game engine with the merger of GDExtension code changes which will replace GDNative interface. Right now, GDNative is one of three ways you can extend the Godot game engine using the C or C++ programming languages. The advantage to the GDNative (and now GDExtension) approach is it does not require you to change or even recompile the game engine.
Details of the change from the Godot Engine blog:
In the past month, the team has been hard at work introducing the new native extensions system for Godot 4.0. GDExtension is a new implementation of the GDNative layer that allows the creation of compiled plugins for the engine. At its core, GDExtension is a C API that enables registration of classes implemented within a dynamic library. This allows dynamic libraries to be used by Godot in a way that is much better integrated than its predecessor, GDNative. Together with the godot-cpp library, GDExtension introduces a system that allows extending Godot to nearly the same level as statically linked C++ modules can.
The new registration system is now part of Godot’s ClassDB. This means that classes implemented in plugins are indistinguishable from core classes.
The above blog post goes into details of how to work with the new GDNative replacement, GDExtensions. For the most part it’s simply better than what came before, however as of right now only Windows and Linux targets have been tested. This will be a code breaking change, so GDNative extensions will have to be ported to GDExtension to work in Godot 4.
- GDExtension Announcement Blog
- Godot Engine Nightly Builds (new build needed to run new extensions)
- Godot-cpp GitHub Repository
- Godot Headers GitHub Repository
You can learn more about the new GDExtension system in the video below.