ResourceFormatLoader is a factory interface for loading file assets. Resources are primary containers. When load is called on the same file path again, the previous loaded Resource will be referenced. Naturally, loaded resources must be stateless.
This guide assumes the reader knows how to create C++ modules and Godot data types. If not, refer to this guide Custom modules in C++.
ImageFormatLoader should be used to load images.
Each file format consist of a data container and a ResourceFormatLoader.
ResourceFormatLoaders are usually simple classes which return all the necessary metadata for supporting new extensions in Godot. The class must the return the format name and the extension string.
In addition, ResourceFormatLoaders must convert file paths into resources with the load function. To load a resource, load must read and handle data serialization.
Godot may not have a proper substitute within its Core types or managed resources. Godot needs a new registered data type to understand additional binary formats such as machine learning models.
Some libraries may not define certain common routines such as IO handling. Therefore, Godot call translations are required.
For example, here is the code for translating FileAccess calls into std::istream.
Godot registers ResourcesFormatLoader with a ResourceLoader handler. The handler selects the proper loader automatically when load is called.