|
3 | 3 | What is GDExtension?
|
4 | 4 | ====================
|
5 | 5 |
|
6 |
| -Introduction |
7 |
| ------------- |
8 |
| - |
9 | 6 | **GDExtension** is a Godot-specific technology that lets the engine interact with
|
10 | 7 | native `shared libraries <https://en.wikipedia.org/wiki/Library_(computing)#Shared_libraries>`__
|
11 | 8 | at runtime. You can use it to run native code without compiling it with the engine.
|
12 | 9 |
|
13 |
| -.. note:: GDExtension is *not* a scripting language and has no relation to |
14 |
| - :ref:`GDScript <doc_gdscript>`. |
15 |
| - |
16 |
| -Differences between GDExtension and C++ modules |
17 |
| ------------------------------------------------ |
18 |
| - |
19 |
| -You can use both GDExtension and :ref:`C++ modules <doc_custom_modules_in_cpp>` to |
20 |
| -run C or C++ code in a Godot project. |
21 |
| - |
22 |
| -They also both allow you to integrate third-party libraries into Godot. The one |
23 |
| -you should choose depends on your needs. |
24 |
| - |
25 |
| -.. warning:: |
26 |
| - |
27 |
| - GDExtension is currently *experimental*, which means that we may |
28 |
| - break compatibility in order to fix major bugs or include critical features. |
29 |
| - |
30 |
| -Advantages of GDExtension |
31 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~ |
32 |
| - |
33 |
| -Unlike modules, GDExtension doesn't require compiling the engine's source code, |
34 |
| -making it easier to distribute your work. It gives you access to most of the API |
35 |
| -available to GDScript and C#, allowing you to code game logic with full control |
36 |
| -regarding performance. It's ideal if you need high-performance code you'd like |
37 |
| -to distribute as an add-on in the :ref:`asset library <doc_what_is_assetlib>`. |
38 |
| - |
39 |
| -Also: |
40 |
| - |
41 |
| -- GDExtension is not limited to C and C++. Thanks to :ref:`third-party bindings |
42 |
| - <doc_what_is_gdnative_third_party_bindings>`, you can use it with many other |
43 |
| - languages. |
44 |
| -- You can use the same compiled GDExtension library in the editor and exported |
45 |
| - project. With C++ modules, you have to recompile all the export templates you |
46 |
| - plan to use if you require its functionality at runtime. |
47 |
| -- GDExtension only requires you to compile your library, not the whole engine. |
48 |
| - That's unlike C++ modules, which are statically compiled into the engine. |
49 |
| - Every time you change a module, you need to recompile the engine. Even with |
50 |
| - incremental builds, this process is slower than using GDExtension. |
51 |
| - |
52 |
| -Advantages of C++ modules |
53 |
| -~~~~~~~~~~~~~~~~~~~~~~~~~ |
54 |
| - |
55 |
| -We recommend :ref:`C++ modules <doc_custom_modules_in_cpp>` in cases where |
56 |
| -GDExtension isn't enough: |
57 |
| - |
58 |
| -- C++ modules provide deeper integration into the engine. GDExtension's access |
59 |
| - is not as deep as static modules. |
60 |
| -- You can use C++ modules to provide additional features in a project without |
61 |
| - carrying native library files around. This extends to exported projects. |
62 |
| - |
63 |
| -.. note:: |
64 |
| - |
65 |
| - If you notice that specific systems are not accessible via GDExtension |
66 |
| - but are via custom modules, feel free to open an issue on the |
67 |
| - `godot-cpp repository <https://github.com/godotengine/godot-cpp>`__ |
68 |
| - to discuss implementation options for exposing the missing functionality. |
| 10 | +There are three primary methods with which this is achieved: |
69 | 11 |
|
70 |
| -Supported languages |
71 |
| -------------------- |
| 12 | +* ``gdextension_interface.h``: A set of C functions that Godot and a GDExtension can use to communicate. |
| 13 | +* ``extension_api.json``: A list of C functions that are exposed from Godot APIs (:ref:`Core Features <doc_scripting_core_features>`). |
| 14 | +* :ref:``*.gdextension <doc_gdextension_file>`: A file format read by Godot to load a GDExtension. |
72 | 15 |
|
73 |
| -The Godot developers officially support the following language bindings for |
74 |
| -GDExtension: |
75 |
| - |
76 |
| -- C++ :ref:`(tutorial) <doc_gdextension_cpp_example>` |
77 |
| - |
78 |
| -.. note:: |
79 |
| - |
80 |
| - There are no plans to support additional languages with GDExtension officially. |
81 |
| - That said, the community offers several bindings for other languages (see |
82 |
| - below). |
83 |
| - |
84 |
| -.. _doc_what_is_gdnative_third_party_bindings: |
85 |
| - |
86 |
| -The bindings below are developed and maintained by the community: |
87 |
| - |
88 |
| -.. 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. |
89 |
| -.. Please keep languages sorted in alphabetical order. |
90 |
| -
|
91 |
| -- `D <https://github.com/godot-dlang/godot-dlang>`__ |
92 |
| -- `Go <https://github.com/grow-graphics/gd>`__ |
93 |
| -- `Nim <https://github.com/godot-nim/gdext-nim>`__ |
94 |
| -- `Rust <https://github.com/godot-rust/gdext>`__ |
95 |
| -- `Swift <https://github.com/migueldeicaza/SwiftGodot>`__ |
96 |
| - |
97 |
| -.. note:: |
98 |
| - |
99 |
| - Not all bindings mentioned here may be production-ready. Make sure to |
100 |
| - research options thoroughly before starting a project with one of those. |
101 |
| - Also, double-check whether the binding is compatible with the Godot version |
102 |
| - you're using. |
103 |
| - |
104 |
| -.. _doc_what_is_gdextension_version_compatibility: |
| 16 | +Most people create GDExtensions with some existing language binding, such as :ref:`godot-cpp (for C++) <doc_godot_cpp>`, |
| 17 | +or one of the :ref:`community-made ones <doc_what_is_gdnative_third_party_bindings>`. |
105 | 18 |
|
106 | 19 | Version compatibility
|
107 | 20 | ---------------------
|
108 | 21 |
|
109 |
| -Usually, GDExtensions targeting an earlier version of Godot will work in later |
110 |
| -minor versions, but not vice-versa. For example, a GDExtension targeting Godot 4.2 |
111 |
| -should work just fine in Godot 4.3, but one targeting Godot 4.3 won't work in Godot 4.2. |
112 |
| - |
113 |
| -For this reason, when creating GDExtensions, you may want to target the lowest version of |
114 |
| -Godot that has the features you need, *not* the most recent version of Godot. This can |
115 |
| -save you from needing to create multiple builds for different versions of Godot. |
116 |
| - |
117 |
| -However, GDExtension is currently *experimental*, which means that we may |
118 |
| -break compatibility in order to fix major bugs or include critical features. |
119 |
| -For example, GDExtensions created for Godot 4.0 aren't compatible with Godot |
120 |
| -4.1 (see :ref:`updating_your_gdextension_for_godot_4_1`). |
121 |
| - |
122 |
| -GDExtensions are also only compatible with engine builds that use the same |
123 |
| -level of floating-point precision the extension was compiled for. This means |
124 |
| -that if you use an engine build with double-precision floats, the extension must |
125 |
| -also be compiled for double-precision floats and use an ``extension_api.json`` |
126 |
| -file generated by your custom engine build. See :ref:`doc_large_world_coordinates` |
127 |
| -for details. |
128 |
| - |
129 |
| -Generally speaking, if you build a custom version of Godot, you should generate an |
130 |
| -``extension_api.json`` from it for your GDExtensions, because it may have some differences |
131 |
| -from official Godot builds. |
| 22 | +See :ref:`_doc_what_is_gdextension_version_compatibility <godot-cpp Version Compatibility>`, which applies to all GDExtensions. |
0 commit comments