godotengine / gdnative-demos Goto Github PK
View Code? Open in Web Editor NEWDemo projects for GDNative
License: MIT License
Demo projects for GDNative
License: MIT License
I'd really appreciate some pointers as to how compile the simple C++ example so the DLL will work for UWP and can be used on XBOX.
I keep getting resolution errors and defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
Currently, this repo does not have a README file at its root. There should be a README file similar to the one in godot-demo-projects, and also, the README file here should link to godot-demo-projects and vice versa.
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?
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])'
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 :)
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
➜ 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.
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.
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.
https://github.com/godotengine/godot-demo-projects/tree/master/networking
The WebRTC demos use GDNative, so they should be moved to this repository.
CC @Faless since you wrote these demos. Would you be able to handle this task?
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.
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);
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
Linux and Osx examples exist but nothing for windows.
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.
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
Are there any examples of Android/IOS builds. I noticed those are not listed in scons?
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?
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.