what_is_gdextension.rst 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .. _doc_what_is_gdextension:
  2. What is GDExtension?
  3. ====================
  4. Introduction
  5. ------------
  6. **GDExtension** is a Godot-specific technology that lets the engine interact with
  7. native `shared libraries <https://en.wikipedia.org/wiki/Library_(computing)#Shared_libraries>`__
  8. at run-time. You can use it to run native code without compiling it with the engine.
  9. .. note:: GDExtension is *not* a scripting language and has no relation to
  10. :ref:`GDScript <doc_gdscript>`.
  11. Differences between GDExtension and C++ modules
  12. -----------------------------------------------
  13. You can use both GDExtension and :ref:`C++ modules <doc_custom_modules_in_c++>` to
  14. run C or C++ code in a Godot project.
  15. They also both allow you to integrate third-party libraries into Godot. The one
  16. you should choose depends on your needs.
  17. Advantages of GDExtension
  18. ^^^^^^^^^^^^^^^^^^^^^^^^^
  19. Unlike modules, GDExtension doesn't require compiling the engine's source code,
  20. making it easier to distribute your work. It gives you access to most of the API
  21. available to GDScript and C#, allowing you to code game logic with full control
  22. regarding performance. It's ideal if you need high-performance code you'd like
  23. to distribute as an add-on in the :ref:`asset library <doc_what_is_assetlib>`.
  24. Also:
  25. - GDExtension is not limited to C and C++. Thanks to :ref:`third-party bindings
  26. <doc_what_is_gdnative_third_party_bindings>`, you can use it with many other
  27. languages.
  28. - You can use the same compiled GDExtension library in the editor and exported
  29. project. With C++ modules, you have to recompile all the export templates you
  30. plan to use if you require its functionality at run-time.
  31. - GDExtension only requires you to compile your library, not the whole engine.
  32. That's unlike C++ modules, which are statically compiled into the engine.
  33. Every time you change a module, you need to recompile the engine. Even with
  34. incremental builds, this process is slower than using GDExtension.
  35. Advantages of C++ modules
  36. ^^^^^^^^^^^^^^^^^^^^^^^^^
  37. We recommend :ref:`C++ modules <doc_custom_modules_in_c++>` in cases where
  38. GDExtension isn't enough:
  39. - C++ modules provide deeper integration into the engine. GDExtension's access is not as deep as
  40. static modules
  41. - You can use C++ modules to provide additional features in a project without
  42. carrying native library files around. This extends to exported projects.
  43. Supported languages
  44. -------------------
  45. The Godot developers officially support the following language bindings for
  46. GDExtension:
  47. - C++ :ref:`(tutorial) <doc_gdextension_cpp_example>`
  48. .. note::
  49. There are no plans to support additional languages with GDExtension officially.
  50. That said, the community offers several bindings for other languages (see
  51. below).
  52. .. _doc_what_is_gdnative_third_party_bindings:
  53. The bindings below are developed and maintained by the community:
  54. .. 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.
  55. .. Please keep languages sorted in alphabetical order.
  56. - `Rust <https://github.com/godot-rust/gdextension>`__
  57. .. note::
  58. Not all bindings mentioned here may be production-ready. Make sure to
  59. research options thoroughly before starting a project with one of those.
  60. Also, double-check whether the binding is compatible with the Godot version
  61. you're using.
  62. Version compatibility
  63. ---------------------
  64. GDExtension add-ons compiled for a given Godot version are only guaranteed to work
  65. with the same minor release series. For example, a GDExtension add-on compiled for
  66. Godot 4.0 will only work with Godot 4.0, 4.0.1, 4.0.2. In addition, GDExtension is
  67. not compatible with Godot 3.x.