yage.resource.manager
Authors:
Eric Poggel
License:
LGPL v3
- struct
ResourceManager
;
- The
ResourceManager
Manager is a static class that keeps track of which filesystem resources are in memory.
All functions that load resources insert the source path of what was loaded
as a key in the associative array while the value returns the class itself.
In order to prevent duplicates of resources loaded into memory, this class should be used
to acquire resources.
- static char[][]
getPaths
();
- Get the array of path strings
- static int
addPath
(char[] path);
- Add a path or array of paths to searh when loading resource files.
Paths are relative to the location of the executable.
Returns:
The number of paths defined after adding the path.
- static char[]
resolvePath
(char[] path, char[] current_dir = "");
- Resolve a relative path to a path relative to the working directory.
Any paths defined by ResourceManager.addPath() are taken into account.
Params:
char[] path |
Path to a file, relative to a path defined by addPath(). |
char[] current_dir |
Optional. A directory relative to the working directory to search for the file pointed to by path. |
Returns:
The resolved path.
Throws:
A ResourceException if the path could not be resolved.
- static bool
removePath
(char[] path);
- Remove a path from the array of resource search paths.
- static ubyte[]
getFile
(char[] filename);
- Simply load a file, using ResourceManager's paths to resolve relative paths.
- static Shader[char[]]
getShaders
();
static Model[char[]]
getModels
();
static Sound[char[]]
getSounds
();
- ditto
Return an associative array (indexed by filename) of a resource type.
- static Font
font
(char[] filename);
- Acquire and return a requested Font.
If it has already been loaded, the in-memory copy will be returned.
If not, it will be loaded and then returned.
Params:
char[] filename |
The Font file that will be loaded. |
- static Model
model
(char[] filename);
- Acquire and return a requested Model.
If it has already been loaded, the in-memory copy will be returned.
If not, it will be loaded and uploaded to video memory.
All associated Materials, Textures, and Shaders will be loaded into
the resource pool as well.
Params:
char[] filename |
The 3D Model file that will be loaded. |
- static Material
material
(char[] filename, char[] id);
- Params:
char[] filename |
Path and id to collada file. e.g. foo/bar.dae#IdForMaterial3 |
- static Sound
sound
(char[] filename);
- Acquire and return a requested Sound.
If the Sound has already been loaded, the in-memory copy will be returned.
If not, it will be loaded and stored in the resource pool.
Params:
char[] filename |
The path to the
sound
file that will be loaded. |
- static Texture
texture
(char[] filename, Format format = cast(Format)0, bool mipmap = true);
- Acquire and return a requested Texture.
If a
texture
with the given properties already been loaded, the in-memory copy will be returned.
If not, it will be loaded, uploaded to video memory, and stored in the resource pool.
This function is called automatically for each of a material's textures when loading a material.
Keep in mind that multiple requested textures may use the same Texture.
Params:
char[] filename |
The Texture image file that will be loaded. |
- static void
dispose
();
- Clear all references to loaded resources.
|