Skip to content

Conversation

@Ivorforce
Copy link
Member

@Ivorforce Ivorforce commented Apr 14, 2025

When you first clone godot-cpp-template, you may still have no idea what to do next, because the gdextension doesn't actually do anything right now. This may be additionally confusing because you may not know how to check your GDExtension is even loading.
While the docs explain how to create and register classes, people may not look there when starting a project. It's may be easier to have some boilerplate for it ready and get right to programming C++.

This PR adds a minimal class for example purposes. I don't think we should try to cover a lot of functionality with it, but a single registered function and some docs is probably enough for people to kick off their project from.

@dsnopek
Copy link
Contributor

dsnopek commented Apr 14, 2025

I forget the details of the discussion, but I recall when @paddy-exe's template was moved to godot-cpp-template, we decided to remove the example class that was there previously. Assuming I'm not remembering that incorrectly :-) - does anyone remember the reasons for that?

@paddy-exe
Copy link
Collaborator

I forget the details of the discussion, but I recall when @paddy-exe's template was moved to godot-cpp-template, we decided to remove the example class that was there previously. Assuming I'm not remembering that incorrectly :-) - does anyone remember the reasons for that?

Yep I remember that discussion as you explained David. The reasoning behind this as far as I can recall was that it was easier to just set it up instead of having to rewrite/delete the old boilerplate code. Also the template is set up for people familiar with the system and specifically not for newcomers.

@Ivorforce
Copy link
Member Author

Ivorforce commented Apr 14, 2025

Interesting!
I'd definitely argue that not having an example increases the barrier to entry. While we probably want to guide new godot-cpp users to the docs / tutorials as much as possible, having one example class would have been enough to get me started more quickly when I first used godot-cpp. If you don't mind, perhaps we can quickly talk it over at the next GDExtension meeting (or when we have time anyway)?

Copy link
Contributor

@unvermuthet unvermuthet left a comment

Choose a reason for hiding this comment

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

I like it! Covers some common things. While I find the example scene a bit superfluous, I do like that it prints something on startup. When dsnopek was testing #78, he had to write a little script to validate that the extension was being loaded.

Copy link
Member

@aaronfranke aaronfranke left a comment

Choose a reason for hiding this comment

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

We should include an example of _notification and NOTIFICATION_READY in the example class. For example: https://github.com/godotengine/godot/pull/90979/files#diff-8611ca838946e49aa582ca85fe561a8803577de7f21e6b1f0a88b01015d16b4f

@Calinou's comment on my PR: "The example extension code should probably print something in its constructor (or NOTIFICATION_READY), so you see it having an effect right away when it's added to the scene tree."

@dsnopek
Copy link
Contributor

dsnopek commented Apr 29, 2025

Discussed at the GDExtension meeting and the folks present were all open to including a simple example to help folks get started. One caveat that was brought up was that this could lead to a "slippery slope" with regard to adding more and more things to the example. To avoid this, we don't want to expand the example beyond what is here.

@akien-mga From our recollection, it was you that requested that the original example class was removed when the "godot-cpp-template" project was created, but we're not sure where that conversation took place. Do you have any thoughts about this?

@aaronfranke aaronfranke requested a review from Calinou April 29, 2025 23:28
@paddy-exe paddy-exe added the enhancement New feature or request label Apr 30, 2025
@dsnopek
Copy link
Contributor

dsnopek commented Apr 30, 2025

We should include an example of _notification and NOTIFICATION_READY in the example class.

Personally, I don't think this is necessary. I think what we should just have the bare minimum here.

What we really need is a collection of demo projects, similar to the godot-demo-projects repo but for projects using godot-cpp, where we can show real full examples of various use cases.

@akien-mga
Copy link
Member

akien-mga commented Apr 30, 2025

@akien-mga From our recollection, it was you that requested that the original example class was removed when the "godot-cpp-template" project was created, but we're not sure where that conversation took place. Do you have any thoughts about this?

Personally I consider that a template is something that should be ready to use, without having to first delete unwanted demo content. Any project started from this template would need to delete ExampleClass / example.{cpp,h} after having seen it once to understand how it's used, or git mv it and rename the class. This pollutes the Git history too, though it's not egregious.

Demos to show how to do various common tasks are great, but they should not be part of the template and brought along every time someone starts a new project. They should live in their own repository which people can reference alongside the documentation to know how to implement stuff (possibly copying some of it to their template-generated project if they want).

Still, if there's otherwise consensus to add this here, this isn't a hill I would die on. The example is minimal and maybe people won't use this template frequently enough that having to delete/rename a demo class would be a bother.
And I do understand that getting started with godot-cpp isn't super trivial so having a concrete example does help set things in motion.

@Ivorforce
Copy link
Member Author

Personally I consider that a template is something that should be ready to use, without having to first delete unwanted demo content. Any project started from this template would need to delete ExampleClass / example.{cpp,h} after having seen it once to understand how it's used, or git mv it and rename the class. This pollutes the Git history too, though it's not egregious.

Personally i find it easier to edit a class than to add a new one from scratch. Most of the boilerplate is the same, just the name changes :)

Demos to show how to do various common tasks are great, but they should not be part of the template and brought along every time someone starts a new project. They should live in their own repository which people can reference alongside the documentation to know how to implement stuff (possibly copying some of it to their template-generated project if they want).

Totally agreed, the idea is just to have something so if you're new you have something to test.

Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Code looks good to me. Remember to apply the suggestion about the p_variant parameter name though.

@Ivorforce
Copy link
Member Author

All done!

@paddy-exe paddy-exe merged commit 3eb2751 into godotengine:main May 15, 2025
57 checks passed
@paddy-exe
Copy link
Collaborator

Merged thank you! Also thanks everyone for the reviews and discussion!

@Ivorforce Ivorforce deleted the example-class branch May 15, 2025 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants