Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of GDExtension docs #6212

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions _tools/redirects/redirects.csv
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,7 @@ source,destination
/tutorials/physics/using_kinematic_body_2d.html,/tutorials/physics/using_character_body_2d.html
/tutorials/plugins/editor/spatial_gizmos.html,/tutorials/plugins/editor/3d_gizmos.html
/tutorials/3d/procedural_geometry/immediategeometry.html,/tutorials/3d/procedural_geometry/immediatemesh.html
/tutorials/scripting/gdnative/index.html,/tutorials/scripting/gdextension/index.html
/tutorials/scripting/gdnative/what_is_gdnative.html,/tutorials/scripting/gdnative/what_is_gdextension.html
/tutorials/scripting/gdnative/gdnative_c_example.html,/tutorials/plugins/gdextension/gdextension_cpp_example.html
/tutorials/scripting/gdnative/gdnative_cpp_example.html,/tutorials/plugins/gdextension/gdextension_cpp_example.html
1 change: 1 addition & 0 deletions about/docs_changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Scripting
- :ref:`doc_debugger_panel`
- :ref:`doc_creating_script_templates`
- :ref:`doc_evaluating_expressions`
- :ref:`doc_what_is_gdextension`
- :ref:`doc_gdscript_warning_system` (split from :ref:`doc_gdscript_static_typing`)

User Interface (UI)
Expand Down
2 changes: 1 addition & 1 deletion getting_started/first_2d_game/06.heads_up_display.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ We also need to process what happens when the player loses. The code below will
.. code-tab:: cpp

// This code goes in `hud.cpp`.
// There is no `yield` in GDNative, so we need to have every
// There is no `yield` in GDExtension, so we need to have every
// step be its own method that is called on timer timeout.
void HUD::show_get_ready() {
_message_label->set_text("Get Ready");
Expand Down
6 changes: 3 additions & 3 deletions getting_started/step_by_step/scripting_languages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ officially supported .NET option.
in GDScript, C#, or C++ won't have a significant impact on
performance.

C and C++ via GDExtension
~~~~~~~~~~~~~~~~~~~~~~~~~
C++ via GDExtension
~~~~~~~~~~~~~~~~~~~

GDExtension allows you to write game code in C or C++ without needing to recompile
GDExtension allows you to write game code in C++ without needing to recompile
or even restart Godot.

.. image:: img/scripting_cpp.png
Expand Down
2 changes: 1 addition & 1 deletion tutorials/export/feature_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ Customizing the build
---------------------

Feature tags can be used to customize a build process too, by writing a custom **ExportPlugin**.
They are also used to specify which shared library is loaded and exported in **GDNative**.
They are also used to specify which shared library is loaded and exported in **GDExtension**.
2 changes: 1 addition & 1 deletion tutorials/networking/webrtc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Using WebRTC in Godot

WebRTC is implemented in Godot via two main classes :ref:`WebRTCPeerConnection <class_WebRTCPeerConnection>` and :ref:`WebRTCDataChannel <class_WebRTCDataChannel>`, plus the multiplayer API implementation :ref:`WebRTCMultiplayerPeer <class_WebRTCMultiplayerPeer>`. See section on :ref:`high-level multiplayer <doc_high_level_multiplayer>` for more details.

.. note:: These classes are available automatically in HTML5, but **require an external GDNative plugin on native (non-HTML5) platforms**. Check out the `webrtc-native plugin repository <https://github.com/godotengine/webrtc-native>`__ for instructions and to get the latest `release <https://github.com/godotengine/webrtc-native/releases>`__.
.. note:: These classes are available automatically in HTML5, but **require an external GDExtension plugin on native (non-HTML5) platforms**. Check out the `webrtc-native plugin repository <https://github.com/godotengine/webrtc-native>`__ for instructions and to get the latest `release <https://github.com/godotengine/webrtc-native/releases>`__.

.. warning::

Expand Down
16 changes: 8 additions & 8 deletions tutorials/platform/android/android_plugin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,19 @@ From your script::
print(singleton.myPluginFunction("World"))


Bundling GDNative resources
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Bundling GDExtension resources
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

An Android plugin can define and provide C/C++ GDNative resources, either to provide and/or access functionality from the game logic.
The GDNative resources can be bundled within the plugin ``aar`` file which simplifies the distribution and deployment process:
An Android plugin can define and provide C/C++ GDExtension resources, either to provide and/or access functionality from the game logic.
The GDExtension resources can be bundled within the plugin ``aar`` file which simplifies the distribution and deployment process:

- The shared libraries (``.so``) for the defined GDNative libraries will be automatically bundled by the ``aar`` build system.
- The shared libraries (``.so``) for the defined GDExtension libraries will be automatically bundled by the ``aar`` build system.
- Godot ``*.gdnlib`` and ``*.gdns`` resource files must be manually defined in the plugin ``assets`` directory.
The recommended path for these resources relative to the ``assets`` directory should be: ``godot/plugin/v1/[PluginName]/``.

For GDNative libraries, the plugin singleton object must override the ``org.godotengine.godot.plugin.GodotPlugin::getPluginGDNativeLibrariesPaths()`` method,
and return the paths to the bundled GDNative libraries config files (``*.gdnlib``). The paths must be relative to the ``assets`` directory.
At runtime, the plugin will provide these paths to Godot core which will use them to load and initialize the bundled GDNative libraries.
For GDExtension libraries, the plugin singleton object must override the ``org.godotengine.godot.plugin.GodotPlugin::getPluginGDNativeLibrariesPaths()`` method,
and return the paths to the bundled GDExtension libraries config files (``*.gdextension``). The paths must be relative to the ``assets`` directory.
At runtime, the plugin will provide these paths to Godot core which will use them to load and initialize the bundled GDExtension libraries.

Reference implementations
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
32 changes: 32 additions & 0 deletions tutorials/scripting/gdextension/files/cpp_example/SConstruct
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env python
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure the docs are the best place to host and maintain this file.

If this doesn't already exist i.e. in the GDExtension repository/example, we should create one, or maybe add it to the demo repository.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you are right. It is mainly based on the test SConstruct file from here: https://github.com/godotengine/godot-cpp/blob/master/test/SConstruct

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @mhilbrunner, we should host the files used here in a repo of its own or find a way to incorporate the test project from godot-cpp in here.

import os
import sys

env = SConscript("godot-cpp/SConstruct")

# For reference:
# - CCFLAGS are compilation flags shared between C and C++
# - CFLAGS are for C-specific compilation flags
# - CXXFLAGS are for C++-specific compilation flags
# - CPPFLAGS are for pre-processor flags
# - CPPDEFINES are for pre-processor defines
# - LINKFLAGS are for linking flags

# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")

if env["platform"] == "macos":
library = env.SharedLibrary(
"demo/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary(
"demo/bin/libgdexample{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
source=sources,
)

Default(library)
Loading