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

Conversation

paddy-exe
Copy link
Contributor

@paddy-exe paddy-exe commented Sep 22, 2022

Aims to implement #5618 in its basic form (more can be added later in additional PRs)

Part of #5121

What this PR explains:

  • Getting the necessary files to work on
  • What each file in there does
  • Generate the bindings (for each platform, and cross-platform)
  • Creating the First Extension
  • Overriding/Extending Engine features (if possible)
  • Compiling your extension
  • Adding properties to the Node you are extending from
    • Adding a property hint range to show one option for further customizability
  • Signals

@paddy-exe paddy-exe force-pushed the gdextension-docs branch 2 times, most recently from 4db73a7 to c3853a5 Compare October 15, 2022 22:47
@paddy-exe
Copy link
Contributor Author

@mhilbrunner Since your last commit, I noticed that the SConstruct file you put in the folder structure doesn't actually run. Also, it is quite complex to understand. Since the build system was revamped the SConstruct doesn't need to that complicated anymore. At least for my template I have it way simpler so my reworked version would be this:

#!/usr/bin/env python
import os
import sys

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

# For the 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/osx/libgdexample.{}.framework".format(
            env["platform"],
        ),
        source=sources,
    )
elif env["platform"] == "windows":
    library = env.SharedLibrary(
        "demo/bin/win64/libgdexample.{}.{}{}".format(env["platform"], env["arch"], env["SHLIBSUFFIX"]),
        source=sources,
    )
else:
    library = env.SharedLibrary(
        "demo/bin/linux/libgdexample.{}.{}{}".format(env["platform"], env["arch"], env["SHLIBSUFFIX"]),
        source=sources,
    )

Default(library)

And the .gdextension file:

[configuration]

entry_symbol = "example_library_init"

[libraries]

linux.64="res://bin/linux/libgdexample.linux.64.so"
windows.x86_64="res://bin/win64/libgdexample.windows.x86_64.dll"
macos="res://bin/osx/libgdexample.macos.framework"

Imho this would be clearer for new users. What do you think?


GDExtension add-ons compiled for a given Godot version are only guaranteed to work
with the same minor release series. For example, a GDExtension add-on compiled for
Godot 4.0 will only work with Godot 4.0, 4.0.1, 4.0.2… but not Godot 3.5 or 3.6.
Copy link

@Zireael07 Zireael07 Nov 11, 2022

Choose a reason for hiding this comment

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

Nitpick: I'd rephrase to make it clearer that 3.5 and 3.6 don't have GDExtension at all (unless I missed something, GDExtension was NOT backported to 3.x branch)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point👍🏻 I made it clearer that GDExtension isn't compatible with GDNative

@Zireael07
Copy link

Hmm. If all that GDExtension does is call on a dll, could I have some logic NOT using any Godot specific stuff e.g. in Golang and call on it WITHOUT having any Golang bindings?

@paddy-exe
Copy link
Contributor Author

Hmm. If all that GDExtension does is call on a dll, could I have some logic NOT using any Godot specific stuff e.g. in Golang and call on it WITHOUT having any Golang bindings?

Good question! Not sure how that applies to other languages but I think in Python used with GDNative it was possible to use some modules assuming they were imported properly.

@Zireael07
Copy link

Something that just occurred to me, and which IIRC is also missing from GDNative docs in 3.5, what's the debugger/remote tree situation? I expect to have to use the debugger for the language I'm using, but what about remote tree variables if I use a gdns straight on a node, e.g. the player, as is the case with many of the demo projects out there?

@paddy-exe
Copy link
Contributor Author

Something that just occurred to me, and which IIRC is also missing from GDNative docs in 3.5, what's the debugger/remote tree situation? I expect to have to use the debugger for the language I'm using, but what about remote tree variables if I use a gdns straight on a node, e.g. the player, as is the case with many of the demo projects out there?

I am not sure what you mean with your question. Could you elaborate?

@paddy-exe paddy-exe changed the title Addition of GDExtension docs / Rewrite of GDNative docs Addition of GDExtension docs Nov 18, 2022
@Zireael07
Copy link

Literally what I said. Suppose I use a gdns file for my player node. Can I see e.g. the player's position or speed in the Godot remote tree?

@paddy-exe
Copy link
Contributor Author

paddy-exe commented Nov 18, 2022

Literally what I said. Suppose I use a gdns file for my player node. Can I see e.g. the player's position or speed in the Godot remote tree?

This here is the GDExtension docs addition, not GDNative.
There are no gdns files with GDExtension.
GDExtension is very much just extending Godot itself so you can see it like if it's programmed inside of Godot itself.

@Zireael07
Copy link

Ah, I was confused (again) by the fact you started from renaming the GDNative docs :P of course I meant Extension

namespace godot {

class GDExample : public Sprite2D {
GD_CLASS(GDExample, Sprite2D)

Choose a reason for hiding this comment

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

Suggested change
GD_CLASS(GDExample, Sprite2D)
GDCLASS(GDExample, Sprite2D)

I think you meant GDCLASS. I got stuck here for a little while 🤓

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yudi-azvd Thanks for noticing! It's updated now.

@paddy-exe
Copy link
Contributor Author

paddy-exe commented Dec 5, 2022

Alright, here's a little update what is already done in this PR and works (tested locally by me):

  • Getting the necessary files to work on
  • What is each file in there does
  • Generate the bindings (for each platform, and cross-platform)
  • Creating the First Extension
  • Overriding/Extending Engine features (if possible)
  • Compiling your extension
  • Adding properties to the Node you are extending from

What still needs to be done:

  • Signals

@BastiaanOlij
Copy link
Contributor

Generally looks good to me, just a few things that I guess were translated from the GDNative version but now work slightly differently in GDExtensions.

@paddy-exe paddy-exe force-pushed the gdextension-docs branch 2 times, most recently from 889d3fd to 97517d9 Compare February 25, 2023 12:40
@paddy-exe
Copy link
Contributor Author

I worked in the feedback, added a property hint example (with PROPERTY_HINT_RANGE), squashed all commits and rebased my changes on master

@paddy-exe paddy-exe force-pushed the gdextension-docs branch 3 times, most recently from e87daca to 5f1ae28 Compare February 25, 2023 15:37
@BastiaanOlij
Copy link
Contributor

Looking pretty good so far to me.

@paddy-exe paddy-exe force-pushed the gdextension-docs branch 2 times, most recently from 80507b4 to bd90ed4 Compare February 26, 2023 14:19
Copy link
Member

@mhilbrunner mhilbrunner left a comment

Choose a reason for hiding this comment

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

Looks good to me, gave it another read and spotted nothing else!

Could you convert the .pngs to .webp? We decided to change format for the docs.
Besides that, I'm happy to merge this. :)

@paddy-exe
Copy link
Contributor Author

@mhilbrunner Awesome! I converted the .png's to .webp now :D should be ready to merge

@paddy-exe paddy-exe force-pushed the gdextension-docs branch 3 times, most recently from 9fb46a1 to c633524 Compare February 26, 2023 15:32
@paddy-exe
Copy link
Contributor Author

Alright, the redirect.csv should now be correctly done (I hope). I rebased everyting as well

@YuriSizov
Copy link
Contributor

Yep, redirects are now fine, good work! :)

Renames from GDNative to GDExtension


Add Pictures/Gifs and clarified compatability


Remove GDNative language bindings from GDExtension docs


Update SConstruct and AddingProperties section


updated with suggestions


Added property hint example + updated to API naming changes


Fixed redirect.csv
@paddy-exe
Copy link
Contributor Author

paddy-exe commented Feb 26, 2023

It is done :O 😅 there was an issue with the renaming of the .png to .webp inside the documents themselves. Is fixed now. ready to merge @mhilbrunner

@mhilbrunner mhilbrunner merged commit d724dc1 into godotengine:master Feb 27, 2023
@mhilbrunner
Copy link
Member

Merged, finally! 🎉 Amazing work. Thanks for keeping up with all the reviews and change requests for so long.

Amazing docs contribution and nice we have that in now for 4.0 launch. :)

@mhilbrunner mhilbrunner added this to the Godot 4.0 milestone Feb 27, 2023
@paddy-exe paddy-exe deleted the gdextension-docs branch February 27, 2023 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:manual Issues and PRs related to the Manual/Tutorials section of the documentation content:new page Issues and PRs related to creation of new documentation pages for new or undocumented features enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.