0 votes

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.

in Engine by (515 points)

1 Answer

+3 votes
Best answer

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 :)

by (27,952 points)
selected by

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.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.