Topic was automatically imported from the old Question2Answer platform.
Asked By
DriNeo
Old Version
Published before Godot 3 was released.
Hello. I try to translate the bunnymark scripts into binary scripts using GDNative but I’m stucked on the the preload function. I don’t know which file to include to the cpp file.
Any information is welcome.
preload is a GDScript feature, which basically calls load behind the scenes when the game starts. You won’t find the exact equivalent in GDNative, which is C/C++. However, you can load resources by including <godot_cpp/ResourceLoader.hpp> and calling ResourceLoader::load("resource path"), which returns a Resource that you can cast to the resource type you need (see Object method for checking if the type is correct before casting).
On a personal note, while I understand it’s for having an example of the bunnymark project in C++, I would advise against hardcoding resource paths in a GDNative library (and prefer GDScript or properties for this data/high-level stuff), unless you really want to only use C++ as your scripting language
C++ will be the only scripting language in this project but this is a project for testing (and for fun) only . Thanks for the advice.