ResourceFormatLoader / ResourceFormatSaver base class undefined

Godot Version

4.22

Question

I followed the gdextension example and everything works fine. Now i wanted to create my own resource. But I fail at the most basic step and I just do not know why.
C:\Users\Nutzer\Desktop\Alles\VSCodeANDGodot\GodotCpp\src\vox.h(10): error C2504: “godot::ResourceFormatLoader”: Basisklasse undefiniert
C:\Users\Nutzer\Desktop\Alles\VSCodeANDGodot\GodotCpp\src\vox.h(16): error C2504: “godot::ResourceFormatSaver”: Basisklasse undefiniert
Basisklasse undefiniert = base class undefined

If I rightclick on ResourceFormatLoader it finds the source without problem. Why does the compiler not find it?. I am sorry for this probably rather stupid question. But I am not used to programm with VSCode and Godot. This problem drives me crazy and even Chatgpt does not help. Bellow is my header file. I deleted everything because the most basic of basics does not work dont even get me started with the overrides.

#ifndef VOX_H
#define VOX_H

#include <godot_cpp/classes/resource_loader.hpp>
#include <godot_cpp/classes/resource_saver.hpp>


namespace godot
{
    class ResourceFormatLoaderVox : public ResourceFormatLoader
    {
    public:

    };

    class ResourceFormatSaverVox : public ResourceFormatSaver
    {
    public:

    };
}
#endif

So first problem solved. The includes are wrong… you need this:

#include <godot_cpp/classes/resource_format_loader.hpp>
#include <godot_cpp/classes/resource_format_saver.hpp>

If someone else is using the godot_cpp and is doing the json resource example. You also need to change the methods… its not load it is _load and the parameters are sometimes different too.
Also the register_types.cpp is completly different than the basic example. If someone did that allready help would be appreciated


Finally done took more than 3 days to get the header files working. For anybody intersted who tried the jspn resource example and is using godot_cpp
instead of this:
ResourceLoader::add_resource_format_loader(json_loader);
this:
godot::ResourceLoader::get_singleton()->add_resource_format_loader( json_loader );

Of course you need to also change it for the other stuff…
With this I got my code to compile no idea if it works but atleast something.

So quick question how do i close this post and why is the godot_cpp so different from the source and should one perhaps edit the doc page
Custom resource format loaders — Godot Engine (stable) documentation in English

?

Post your solution as a reply and mark it as the answer by clicking this button:
image

This way other people know it is solved, and the topic will automatically be closed 30 days later.

1 Like