Giter Club home page Giter Club logo

gdnative-demos's Introduction

GDNative demos

The top level folders split this repo into demos for different languages. Each folder inside of those is a GDNative project. Once compiled, the project.godot file can be opened with Godot Engine, the open source 2D and 3D game engine.

Important: Each demo depends on submodules for the godot-headers and godot-cpp GDNative dependencies. You should initialize this repository by checking out the submodules recursively:

git submodule update --init --recursive

For non-GDNative demos (GDScript, VisualScript, and C#), please see the Godot demo projects repo.

Godot versions

The master branch is compatible with the 3.x development branch of Godot.

Numbered branches are compatible with the corresponding Godot branch. The following numbered branches are available:

Older Godot versions are not supported by this repo.

Useful links

License

Those demos are distributed under the terms of the MIT license, as described in the LICENSE.md file.

gdnative-demos's People

Contributors

27thliz avatar aaronfranke avatar akien-mga avatar bastiaanolij avatar capnm avatar geekrelief avatar itotaljustice avatar karroffel avatar lupodharkael avatar onyxblade avatar rameshravone avatar sdtv9507 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdnative-demos's Issues

Linux. GLFW Crash after terminating the Godot Project

➜  glfw git:(master) ✗ scons platform=linux bits=64 
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: project/gdnative/linuxbsd/libglfw_godot.so is up to date.
scons: done building targets.

➜  glfw git:(master) ✗ Godot_v3.2.2-stable_x11.64 --path project 
Godot Engine v3.2.2.stable.official - https://godotengine.org
OpenGL ES 2.0 Renderer: GeForce GTX 1060/PCIe/SSE2
OpenGL ES 2.0 Batching: ON
 
GLFW._init()
create window: 400x400
user says: "please close."
glfw_close
glfw_close
glfw_destructor
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /usr/lib/libc.so.6(+0x3d6a0) [0x7ff6a3d916a0] (??:0)
[2] /usr/lib/libpthread.so.0(pthread_mutex_lock+0x4) [0x7ff6a3a02664] (??:0)
[3] /usr/lib/libX11.so.6(XrmDestroyDatabase+0x2f) [0x7ff6a3c31d0f] (??:0)
[4] /usr/lib/libX11.so.6(_XFreeDisplayStructure+0x3bc) [0x7ff6a3c18a2c] (??:0)
[5] /usr/lib/libX11.so.6(XCloseDisplay+0xd3) [0x7ff6a3c06313] (??:0)
[6] Godot_v3.2.2-stable_x11.64() [0x29746fe] (<artificial>:?)
[7] Godot_v3.2.2-stable_x11.64() [0x2a5a792] (<artificial>:?)
[8] Godot_v3.2.2-stable_x11.64() [0x8582ff] (??:?)
[9] /usr/lib/libc.so.6(__libc_start_main+0xf2) [0x7ff6a3d7c152] (??:0)
[10] Godot_v3.2.2-stable_x11.64() [0x86695e] (??:?)
-- END OF BACKTRACE --
[1]    83286 abort (core dumped)  Godot_v3.2.2-stable_x11.64 --path project

I'm on Arch linux 64.
If I get rid of the GLFW code, I wont get the crash dump like this.

Sconstruct not update path include .cpp .hpp

I watch tutorial at https://www.youtube.com/watch?v=voXapBgDdts&list=PLZ2NyOcFnfQOko5ZysZeGkH3bfw2UtbOK
but include .cpp .hpp of godot such as classes, core, variant. it's different path in 2021 and 2019. 😥

I download on godot-cpp, godot-header, dodge_the_creeps-cpp

I can not create .dll

SConstruct of dodge_the_creeps

godot_headers_path = "godot-cpp/godot-headers"
godot_bindings_path = "godot-cpp"
.
.
.
env.Append(
    CPPPATH=[
        godot_headers_path,
        godot_bindings_path + "/include",
        godot_bindings_path + "/include/gen/",
        godot_bindings_path + "/include/core/",
    ]
)

Cannot open include file: 'godot_cpp/godot.hpp

E:\0DataJue\zzDownload\Godot\GodotProj\gdnative_cpp_example\gdnative-demos-master\cpp\dodge_the_creeps>scons platform=windows
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fogodot-cpp\src\godot.obj /c godot-cpp\src\godot.cpp /TP /nologo /Z7 /Od /EHsc /D_DEBUG /MDd /DDEBUG_ENABLED /DDEBUG_METHODS_ENABLED /DTYPED_METHOD_BIND /Igodot-cpp /Igodot-cpp\godot-headers /Iinclude /Igen\include
godot.cpp
godot-cpp\src\godot.cpp(31): fatal error C1083: Cannot open include file: 'godot_cpp/godot.hpp': No such file or directory
scons: *** [godot-cpp\src\godot.obj] Error 2
scons: building terminated because of errors.

At godot-cpp folder when using the scons command it creates a gen folder, it's not in the godot_cpp folder.

godot-cpp/gen/
godot-cpp/gen/include
godot-cpp/gen/src
.
.
.
\godot-cpp\include\godot_cpp
\godot-cpp\include\godot_cpp\classes
\godot-cpp\include\godot_cpp\core
\godot-cpp\include\godot_cpp\variant

At godot-cpp\include folder has godot_cpp folder inside before have classes, cores, variables inside.

  • [my issue not gdnative-demos isssue ]

Need to make target=release work on linux and mac

The scons file in several demos check target=release/debug for windows and switch whether or not to include debug symbols.

It seems this may be different on Linux and Mac because neither have specific switches build in. I'm not sure what is required here but need to look into this.

Add README files to all projects in the style of godot-demo-projects

In the godot-demo-projects repository, every demo has a README file. These include a description of what the project is, a description of how the project works, which renderer and languages are used, and screenshots. For this repository, the README might also need to include instructions on how to compile and use the project, and maybe also a list of supported operating systems.

Reorganise projects so source is separate from godot project

Most of our sample projects have a structure where the godot project is in the root, we then have a src folder with sources.

The problem on Windows is that after compiling the sources we have a bunch of .obj files (compiled source) and Godot is attempting to import those as wavefront meshes.

A structure like:

sample
  + Source
    - SConstruct
    - sample.c
  + Demo
    + bin
      - libsample.gdnlib
      - sampleobj.gdns
      - libsample.dll
    - project.godot
    - main.tscn

Would probably be better

How do I run the C++ demos on OSX?

I compiled the cpp/SimpleDemo code using scons platform=osx and I edited the .gdnlib file from the Godot editor to add the .dylib file, but when I then try to run the demo, I get the error does not have a library for the current platform. Am I missing something?

Samples are out of date, and don't compile cleanly on Windows 10

Tested on Windows 10, Godot 3.x, with Visual Studio 2019.

The submodules should point to https://github.com/godotengine/godot-headers.
The C samples need their submodules updated.

The c/instance_binding sample has several errors. The create_wrapper_object function needs 3 parameters.
Here's the correct signature:

void *create_wrapper_object(void *data, const void *global_type_tag, godot_object *object)

The struct construction in godot_nativescript_init needs to be updated too:

void GDN_EXPORT godot_nativescript_init(void *handle) {
	printf("nativescript_init\n");

	fflush(stdout);

	// register instance binding functions
	{
		godot_instance_binding_functions bind = {
			.alloc_instance_binding_data = &create_wrapper_object,
			.free_instance_binding_data = &destroy_wrapper_object
		};

		language_binding_index = nativescript_1_1_api->godot_nativescript_register_instance_binding_data_functions(bind);
	}

	// register class
	{
		godot_instance_create_func constructor = {
			.create_func = &ibd_constructor
		};

		godot_instance_destroy_func destructor = {
			.destroy_func = &ibd_destructor
		};

		nativescript_api->godot_nativescript_register_class(handle, "InstanceBinding", "Reference", constructor, destructor);
	}
}

The cpp samples' assume linux as the platform and need to be updated to support other platforms. In SConstruct:
https://github.com/geekrelief/gdnative-demos/blob/fe95d4316da4fe0562afade3158b5814f772e068/cpp/cpp_constructors/SConstruct#L55-L58
should be changed to:

if target == "debug":
    env.Append(LIBS=["libgodot-cpp."+platform+".debug.64"])
else:
    env.Append(LIBS=["libgodot-cpp."+platform+".release.64"]

Compiling the cpp_constructors sample, updating the bin\constructor.gdnlib for Windows.64, I get a crash when running:

Hello World
CrashHandlerException: Program crashed
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[0] RaiseException
[1] RaiseException
[2] _CxxThrowException (d:\A01\_work\12\s\src\vctools\crt\vcruntime\src\eh\throw.cpp:75)
[3] __RTDynamicCast (d:\A01\_work\12\s\src\vctools\crt\vcruntime\src\eh\rtti.cpp:291)
[4] Object::cast_to<Timer> (C:\godot\geekrelief_godot\core\object.h:622)
[5] MethodBind1<Timer,float>::ptrcall (C:\godot\geekrelief_godot\core\method_bind.gen.inc:875)
[6] godot_method_bind_ptrcall (C:\godot\geekrelief_godot\modules\gdnative\gdnative\gdnative.cpp:70)
[7] godot_nativescript_init
[8] godot_nativescript_init
[9] godot_nativescript_init
[10] godot_nativescript_init
[11] godot_nativescript_init
[12] NativeScriptInstance::call (C:\godot\geekrelief_godot\modules\gdnative\nativescript\nativescript.cpp:709)
[13] Object::call (C:\godot\geekrelief_godot\core\object.cpp:898)
[14] Variant::call_ptr (C:\godot\geekrelief_godot\core\variant_call.cpp:1149)
[15] GDScriptFunction::call (C:\godot\geekrelief_godot\modules\gdscript\gdscript_function.cpp:1089)
[16] GDScriptInstance::_ml_call_reversed (C:\godot\geekrelief_godot\modules\gdscript\gdscript.cpp:1239)
[17] GDScriptInstance::call_multilevel_reversed (C:\godot\geekrelief_godot\modules\gdscript\gdscript.cpp:1248)
[18] Node::_notification (C:\godot\geekrelief_godot\scene\main\node.cpp:152)
[19] Node::_notificationv (C:\godot\geekrelief_godot\scene\main\node.h:46)
[20] CanvasItem::_notificationv (C:\godot\geekrelief_godot\scene\2d\canvas_item.h:166)
[21] Control::_notificationv (C:\godot\geekrelief_godot\scene\gui\control.h:48)
[22] Object::notification (C:\godot\geekrelief_godot\core\object.cpp:931)
[23] Node::_propagate_ready (C:\godot\geekrelief_godot\scene\main\node.cpp:197)
[24] Node::_propagate_ready (C:\godot\geekrelief_godot\scene\main\node.cpp:189)
[25] Node::_set_tree (C:\godot\geekrelief_godot\scene\main\node.cpp:2626)
[26] SceneTree::init (C:\godot\geekrelief_godot\scene\main\scene_tree.cpp:466)
[27] OS_Windows::run (C:\godot\geekrelief_godot\platform\windows\os_windows.cpp:3437)
[28] widechar_main (C:\godot\geekrelief_godot\platform\windows\godot_windows.cpp:162)
[29] _main (C:\godot\geekrelief_godot\platform\windows\godot_windows.cpp:184)
[30] main (C:\godot\geekrelief_godot\platform\windows\godot_windows.cpp:196)
[31] __scrt_common_main_seh (d:\A01\_work\12\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
[32] BaseThreadInitThunk
-- END OF BACKTRACE --

The crash occurs @ https://github.com/geekrelief/gdnative-demos/blob/fe95d4316da4fe0562afade3158b5814f772e068/cpp/cpp_constructors/src/TestClass.hpp#L27

The kinematic_char example is also erroring in player.cpp
https://github.com/geekrelief/gdnative-demos/blob/fe95d4316da4fe0562afade3158b5814f772e068/cpp/kinematic_character/Script/src/player.cpp#L172

Script\src\player.cpp(172): error C2668: 'godot::register_signal': ambiguous call to overloaded function
C:\godot\geekrelief_gdnative-demos\cpp\godot-cpp\include\core\Godot.hpp(539): note: could be 'void godot::register_signal<GDPlayer,>(godot::String)'
C:\godot\geekrelief_gdnative-demos\cpp\godot-cpp\include\core\Godot.hpp(499): note: or       'void godot::register_signal<GDPlayer>(godot::String,godot::Dictionary)'
Script\src\player.cpp(172): note: while trying to match the argument list '(const char [5])'

Unknown template GodotScript

I have a C++ NativeScript plugin working well, but when I try to create a subclass of one of the Node types, I get the error: unknown template name 'GodotScript'.

Are these examples written in an older version of Godot? What is the new way to create a subclass of the Node classes?

ie)

class CustomNode : public GodotScript<Node2D>
{
	GODOT_CLASS(CustomNode);

simple_get_data leaks memory

Thanks to Karroffel I now know simple_get_data leaks memory :)
Just to remind myself I need to fix this tomorrow as I'm going to bed in a minute :)

Request: Demo of an EditorPlugin

I have been trying to figure out how to create an editorplugin with UI. It would be great if someone could provide a very barebones example, perhaps similar to the "Custom Dock" demo that is part of the "Godot Demo Projects" repository, but implemented in GDNative (preferrably with C++.) If an example exists anywhere for this, I haven't been able to find it.

godot_native_init not found

Hey @karroffel ,

Probably something stupid I've done wrong but was just creating a new project just to get some mileage with GDNative:
https://github.com/BastiaanOlij/GDNative-demos/tree/space_colonization/cpp/space_colonization

GDNative seems to be unable to call some of its functions:

ERROR: get_dynamic_library_symbol_handle: Can't resolve symbol godot_native_init. Error: dlsym(0x7fcd6272eb90, godot_native_init): symbol not found
   At: drivers/unix/os_unix.cpp:465.
ERROR: set_library: Condition ' initalize_status != OK ' is true.
   At: modules/gdnative/gdnative.cpp:455.
ERROR: get_script_data: Condition ' !native_library->scripts.has(p_name) ' is true. returned: __null
   At: modules/gdnative/gdnative.cpp:749.
ERROR: set_script_name: Condition ' !script_data ' is true.
   At: modules/gdnative/gdnative.cpp:478.

I've got all three dylibs (testing on Mac OS X) in the bin folder, it originally was complaining about not being able to find them all, so I'm guessing they are getting loaded now.

Any idea what I might be doing wrong?

Windows running cpp/simple project results in failure.

After following the steps outlined in cpp/README.md, I tried to build the simple project for godot 3.2.3.

(So cd godot-cpp; scons platform=windows generate_bindings=yes; cd ..; scons platform=windows)

The first problem I ran into was the following:

scons: Building targets ...
link /nologo /WX /dll /out:bin\libsimple.dll /implib:bin\libsimple.lib /LIBPATH:godot-cpp\bin libgodot-cpp.linux.debug.64.lib src\entry.obj src\Simple.obj
LINK : fatal error LNK1181: cannot open input file 'libgodot-cpp.linux.debug.64.lib'
scons: *** [bin\libsimple.dll] Error 1181
scons: building terminated because of errors.

After changing libgodot-cpp.linux.debug.64 to libgodot-cpp.windows.debug.64 in the SConstruct scons did not fail, but when opening the project in godot I'm met with the following error.

ERROR: does not have a library for the current platform.
At: modules/gdnative/nativescript/nativescript.cpp:1483

trying to build the demo Simple i get fatal error: 'gdnative_api_struct.gen.h' file not found

when i build the demo "simple" running "scons platform=osx" i get errors

richs-MacBook-Air:simple rich$ scons platform=osx scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... g++ -o src/Simple.os -c -g -O3 -std=c++14 -arch x86_64 -fPIC -Igodot-cpp/godot_headers -Igodot-cpp/include -Igodot-cpp/include/gen -Igodot-cpp/include/core src/Simple.cpp In file included from src/Simple.cpp:1: In file included from src/Simple.hpp:1: godot-cpp/include/core/Godot.hpp:7:10: fatal error: 'gdnative_api_struct.gen.h' file not found #include <gdnative_api_struct.gen.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. scons: *** [src/Simple.os] Error 1 scons: building terminated because of errors. richs-MacBook-Air:simple rich$

I'm trying to follow the instructions for compiling this, i compiled the godot-cpp folder

the instructions are unclear where the godot-cpp folder should be located, i've tried it in the folder "simple" and the folder above

macos 10.13.6
Python 3.9

GLFWDemo is outdated to the api and the headers

GCC reports missing godot.h when compiling the init.os.

And Godot seems not recognizing .gdn:
ERROR: _load: No loader found for resource: res://GLFW.gdn At: core/io/resource_loader.cpp:186.

I was using Godot 3.0.2 and the master branch of godot_headers.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.