Skip to content

Commit

Permalink
Split C++ (godot-cpp) and GDExtension system info into separate categ…
Browse files Browse the repository at this point in the history
…ories, children of Scripting.
  • Loading branch information
Ivorforce committed Feb 6, 2025
1 parent 1afdbaf commit 068bda1
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 68 deletions.
25 changes: 18 additions & 7 deletions tutorials/scripting/gdextension/index.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
:allow_comments: False

GDExtension
===========
.. _doc_gdextension:

The GDExtension System
======================

**GDExtension** is a Godot-specific technology that lets the engine interact with
native `shared libraries <https://en.wikipedia.org/wiki/Library_(computing)#Shared_libraries>`__
at runtime. You can use it to run native code without compiling it with the engine.

.. note:: GDExtension is *not* a scripting language and has no relation to
:ref:`GDScript <doc_gdscript>`.

This section describes how GDExtension works, and is generally aimed at people wanting to make a GDExtension from
scratch, for example to create language bindings. If you want to use existing language bindings, please refer to other
articles instead, such as the articles about :ref:`C++ (godot-cpp) <doc_godot_cpp>` or one of the
:ref:`community-made ones <doc_what_is_gdnative_third_party_bindings>`.

.. toctree::
:maxdepth: 1
:name: toc-tutorials-gdnative
:name: toc-tutorials-gdextension

what_is_gdextension
gdextension_cpp_example
gdextension_c_example
gdextension_file
gdextension_docs_system
gdextension_c_example
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
.. _doc_what_is_gdextension:
:allow_comments: False
.. _doc_godot_cpp:

What is GDExtension?
====================
C++ (godot-cpp)
===============

Introduction
------------
This section describes how to get started with `godot-cpp <https://github.com/godotengine/godot-cpp>`__,
the official C++ GDExtension bindings maintained as part of the Godot project.

**GDExtension** is a Godot-specific technology that lets the engine interact with
native `shared libraries <https://en.wikipedia.org/wiki/Library_(computing)#Shared_libraries>`__
at runtime. You can use it to run native code without compiling it with the engine.
.. toctree::
:maxdepth: 1
:name: toc-tutorials-godot-cpp

.. note:: GDExtension is *not* a scripting language and has no relation to
:ref:`GDScript <doc_gdscript>`.
gdextension_cpp_example
gdextension_docs_system

Differences between GDExtension and C++ modules
Differences between godot-cpp and C++ modules
-----------------------------------------------

You can use both GDExtension and :ref:`C++ modules <doc_custom_modules_in_cpp>` to
You can use both godot-cpp and :ref:`C++ modules <doc_custom_modules_in_cpp>` to
run C or C++ code in a Godot project.

They also both allow you to integrate third-party libraries into Godot. The one
you should choose depends on your needs.

.. warning::

GDExtension is currently *experimental*, which means that we may
godot-cpp is currently *experimental*, which means that we may
break compatibility in order to fix major bugs or include critical features.

Advantages of GDExtension
~~~~~~~~~~~~~~~~~~~~~~~~~

Unlike modules, GDExtension doesn't require compiling the engine's source code,
making it easier to distribute your work. It gives you access to most of the API
available to GDScript and C#, allowing you to code game logic with full control
regarding performance. It's ideal if you need high-performance code you'd like
to distribute as an add-on in the :ref:`asset library <doc_what_is_assetlib>`.
Advantages of godot-cpp
~~~~~~~~~~~~~~~~~~~~~~~

Unlike modules, godot-cpp (and GDExtension systems in general) don't require
compiling the engine's source code, making it easier to distribute your work.
It gives you access to most of the API available to GDScript and C#, allowing
you to code game logic with full control regarding performance. It's ideal if
you need high-performance code you'd like to distribute as an add-on in the
:ref:`asset library <doc_what_is_assetlib>`.

Also:

- GDExtension is not limited to C and C++. Thanks to :ref:`third-party bindings
<doc_what_is_gdnative_third_party_bindings>`, you can use it with many other
languages.
- You can use the same compiled GDExtension library in the editor and exported
- You can use the same compiled godot-cpp library in the editor and exported
project. With C++ modules, you have to recompile all the export templates you
plan to use if you require its functionality at runtime.
- GDExtension only requires you to compile your library, not the whole engine.
- godot-cpp only requires you to compile your library, not the whole engine.
That's unlike C++ modules, which are statically compiled into the engine.
Every time you change a module, you need to recompile the engine. Even with
incremental builds, this process is slower than using GDExtension.
incremental builds, this process is slower than using godot-cpp.

Advantages of C++ modules
~~~~~~~~~~~~~~~~~~~~~~~~~

We recommend :ref:`C++ modules <doc_custom_modules_in_cpp>` in cases where
GDExtension isn't enough:
godot-cpp (or another GDExtension system) isn't enough:

- C++ modules provide deeper integration into the engine. GDExtension's access
is not as deep as static modules.
Expand All @@ -67,40 +67,6 @@ GDExtension isn't enough:
`godot-cpp repository <https://github.com/godotengine/godot-cpp>`__
to discuss implementation options for exposing the missing functionality.

Supported languages
-------------------

The Godot developers officially support the following language bindings for
GDExtension:

- C++ :ref:`(tutorial) <doc_gdextension_cpp_example>`

.. note::

There are no plans to support additional languages with GDExtension officially.
That said, the community offers several bindings for other languages (see
below).

.. _doc_what_is_gdnative_third_party_bindings:

The bindings below are developed and maintained by the community:

.. Binding developers: Feel free to open a pull request to add your binding if it's well-developed enough to be used in a project.
.. Please keep languages sorted in alphabetical order.
- `D <https://github.com/godot-dlang/godot-dlang>`__
- `Go <https://github.com/grow-graphics/gd>`__
- `Nim <https://github.com/godot-nim/gdext-nim>`__
- `Rust <https://github.com/godot-rust/gdext>`__
- `Swift <https://github.com/migueldeicaza/SwiftGodot>`__

.. note::

Not all bindings mentioned here may be production-ready. Make sure to
research options thoroughly before starting a project with one of those.
Also, double-check whether the binding is compatible with the Godot version
you're using.

.. _doc_what_is_gdextension_version_compatibility:

Version compatibility
Expand Down
2 changes: 2 additions & 0 deletions tutorials/scripting/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The sections below each focus on a given programming language.

gdscript/index
c_sharp/index
godot_cpp/index
other_languages
gdextension/index

Core features
Expand Down
33 changes: 33 additions & 0 deletions tutorials/scripting/other_languages.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Other Languages
---------------

The Godot developers officially support the following language bindings for
GDExtension:

- C++ :ref:`(tutorial) <doc_gdextension_cpp_example>`

.. note::

There are no plans to support additional languages with GDExtension officially.
That said, the community offers several bindings for other languages (see
below).

.. _doc_what_is_gdnative_third_party_bindings:

The bindings below are developed and maintained by the community:

.. Binding developers: Feel free to open a pull request to add your binding if it's well-developed enough to be used in a project.
.. Please keep languages sorted in alphabetical order.
- `D <https://github.com/godot-dlang/godot-dlang>`__
- `Go <https://github.com/grow-graphics/gd>`__
- `Nim <https://github.com/godot-nim/gdext-nim>`__
- `Rust <https://github.com/godot-rust/gdext>`__
- `Swift <https://github.com/migueldeicaza/SwiftGodot>`__

.. note::

Not all bindings mentioned here may be production-ready. Make sure to
research options thoroughly before starting a project with one of those.
Also, double-check whether the binding is compatible with the Godot version
you're using.

0 comments on commit 068bda1

Please sign in to comment.