godotengine / godot-docs

Godot Engine official documentation
https://docs.godotengine.org
Other
3.94k stars 3.22k forks source link

Using Godot with C++ #140

Open akien-mga opened 8 years ago

akien-mga commented 8 years ago

Moved from https://github.com/godotengine/godot/issues/4525

baptx commented 6 years ago

Is there maybe an unofficial C++ / GDNative tutorial for Godot so we can already start using it?

It could be added later here: https://godot.readthedocs.io/en/3.0/getting_started/scripting/index.html (referred on the page https://godot.readthedocs.io/en/3.0/about/faq.html#which-languages-are-supported-in-godot).

It would also be good to compare C++ and GDScript code, like it is done with C#: https://godot.readthedocs.io/en/3.0/getting_started/step_by_step/scripting.html#handling-a-signal

Croydon commented 5 years ago

Having a working C++ only example would save me quite some troubles right now 👍

clayjohn commented 5 years ago

There is a tutorial which may be a little out of date http://docs.godotengine.org/en/latest/tutorials/plugins/gdnative/gdnative-cpp-example.html

There is also a lot of info on the GDNative Github https://github.com/GodotNativeTools/godot-cpp/blob/master/README.md

neikeq commented 5 years ago

godotengine/godot#4525 and this issue were about writing Godot games in C++ by compiling the engine from source, most likely with modules which I don't think is possible right now (not without modifying the engine). GDNative and godot-cpp didn't exist at that point.

Croydon commented 5 years ago

I'm still not sure if GDNative is what I want.

I need low-level, unrestricted Godot and C++ capabilities. I'm trying to figure out if I can port an existing game to Godot and having a limited scripting API is a non-starter.

Can I do with GDNative C++ bindings everything I could do when I would directly edit Godot's source code? (except directly removing or altering Godot functionality of course, I don't want to fork Godot and I'm trying to use it in a way which makes updating as simple as possible, while still having all low-level functionality)


That is also how I interpreted the original issue godotengine/godot#4525:

There is no easy way I can know how to use godot completely in C++.

ryanpeach commented 4 years ago

So I want to make some things more clear in the documentation that I see as very unclear:

https://docs.godotengine.org/en/stable/tutorials/plugins/gdnative/gdnative-cpp-example.html

This is the tutorial I'm referencing btw. I can't find it in this repo.

  1. It says in this note godot-cpp now includes godot_headers as a nested submodule but then later says You should now have demo, godot-cpp, godot_headers, and src directories in your GDNative module. Same Once you've downloaded the SConstruct file, place it in your GDNative module folder besides godot-cpp, godot_headers and demo, then run:

  2. resource_name = "gdexample" There is no explanation of resource name. Where does it come from? What is it's purpose?

  3. Lastly, I think we need a concrete repo linked in this example that provides a working demo of it.

Thoughts? Answers? I'm glad to provide these changes with help.

Calinou commented 4 years ago

resource_name = "gdexample" There is no explanation of resource name. Where does it come from? What is it's purpose?

In Godot, all Resources have a resource_name property which is used for the purposes of serialization (and sometimes special purposes, like in GDNative).

ryanpeach commented 4 years ago

But does it have to be called anything special, or does it just have to be unique? Like class name comes from the code.

Calinou commented 4 years ago

But does it have to be called anything special, or does it just have to be unique?

I don't know, I haven't used GDNative myself. I don't have much time to dedicate to it, unfortunately :slightly_frowning_face: