Skip to content

Add an example class to the project. #87

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

Comment on lines +1 to +2
#ifndef EXAMPLE_CLASS_H
#define EXAMPLE_CLASS_H
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we migrate to #pragma once here too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants