Skip to content

Commit cc38a80

Browse files
authored
Merge pull request #10570 from Maarrk/pr-gdextension-tooling
Improve GDExtension tutorial based on own experience
2 parents 091a449 + a5db650 commit cc38a80

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

tutorials/scripting/gdextension/gdextension_cpp_example.rst

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ There are a few prerequisites you'll need:
2525
- a copy of the `godot-cpp
2626
repository <https://github.com/godotengine/godot-cpp>`__.
2727

28-
See also :ref:`Compiling <toc-devel-compiling>` as the build tools are identical
28+
See also :ref:`Configuring an IDE <toc-devel-configuring_an_ide>`
29+
and :ref:`Compiling <toc-devel-compiling>` as the build tools are identical
2930
to the ones you need to compile Godot from source.
3031

3132
You can download the `godot-cpp repository <https://github.com/godotengine/godot-cpp>`__ from GitHub or let Git do the work for you.
@@ -272,7 +273,7 @@ GDExtension plugin.
272273
return;
273274
}
274275
275-
GDREGISTER_CLASS(GDExample);
276+
GDREGISTER_RUNTIME_CLASS(GDExample);
276277
}
277278
278279
void uninitialize_example_module(ModuleInitializationLevel p_level) {
@@ -298,7 +299,8 @@ The ``initialize_example_module`` and ``uninitialize_example_module`` functions
298299
called respectively when Godot loads our plugin and when it unloads it. All
299300
we're doing here is parse through the functions in our bindings module to
300301
initialize them, but you might have to set up more things depending on your
301-
needs. We call the ``GDREGISTER_CLASS`` macro for each of our classes in our library.
302+
needs. We call the ``GDREGISTER_RUNTIME_CLASS`` macro for each of our classes
303+
in our library. This will make them run only in game, like the default for GDScript.
302304

303305
The important function is the third function called ``example_library_init``.
304306
We first call a function in our bindings library that creates an initialization object.
@@ -327,10 +329,11 @@ At last, we need the header file for the ``register_types.cpp`` named
327329
Compiling the plugin
328330
--------------------
329331

330-
We cannot easily write by hand a ``SConstruct`` file that SCons would use for
331-
building. For the purpose of this example, just use
332-
:download:`this hardcoded SConstruct file <files/cpp_example/SConstruct>` we've
333-
prepared. We'll cover a more customizable, detailed example on how to use these
332+
To compile the project we need to define how SCons using should compile it
333+
using a ``SConstruct`` file which references the one in ``godot-cpp``.
334+
Writing it from scratch is outside the scope of this tutorial, but you can
335+
:download:`the SConstruct file we prepared <files/cpp_example/SConstruct>`.
336+
We'll cover a more customizable, detailed example on how to use these
334337
build files in a subsequent tutorial.
335338

336339
.. note::
@@ -465,7 +468,12 @@ We're going to assign the Godot logo to this node as our texture, disable the
465468

466469
We're finally ready to run the project:
467470

468-
.. image:: img/gdextension_cpp_animated.gif
471+
.. video:: img/gdextension_cpp_animated.webm
472+
:alt: Screen recording of a game window, with Godot logo moving in the top-left corner
473+
:autoplay:
474+
:loop:
475+
:muted:
476+
:align: default
469477

470478
Adding properties
471479
-----------------
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)