![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
Manage textures. More...
#include <texture_manager.hpp>
Public Types | |
using | DataType |
using | DataBlockType |
using | DataBlockPointer |
using | Map |
Public Member Functions | |
bool | initialize () override |
Initialize the manager. | |
bool | isInitialized () override |
void | uninitialize () override |
bool | loadFromSurface (std::string_view name, fge::Surface const &surface) |
Load a texture from a surface. | |
bool | loadFromFile (std::string_view name, std::filesystem::path const &path) |
Load a texture from a file. | |
bool | loadToGroupFromSurface (std::string_view name, fge::Surface const &surface) const |
Load a texture from a surface and add it to a group. | |
std::size_t | size () const |
Get the number of elements in the manager. | |
AccessLock< std::mutex > | acquireLock () const |
Acquire a AccessLock, with the manager mutex. | |
Map::const_iterator | begin (AccessLock< std::mutex > const &lock) const |
Get the "begin" iterator of the manager. | |
Map::const_iterator | end (AccessLock< std::mutex > const &lock) const |
Get the "end" iterator of the manager. | |
DataBlockPointer const & | getBadElement () const |
Get the "bad" element. | |
DataBlockPointer | getElement (std::string_view name) const |
Get the resource with the given name. | |
bool | contains (std::string_view name) const |
bool | unload (std::string_view name) |
void | unloadAll () |
bool | push (std::string_view name, DataBlockPointer block) |
Add a user handled resource. | |
Protected Attributes | |
DataBlockPointer | _g_badElement |
Manage textures.
This class is used to manage textures. It can load textures from files or surfaces. On initialization, a bad texture is created. This texture is used when a texture is not found in order to always return a "valid" texture.
|
nodiscardinherited |
Acquire a AccessLock, with the manager mutex.
In order to use iterators, you have to acquire a unique lock from this function. The lock is not differed and will lock the mutex.
|
nodiscardinherited |
Get the "begin" iterator of the manager.
You have to provide a valid reference to a AccessLock acquired with the function AcquireLock(). This function will throw if one of this is not respected :
lock | A AccessLock bound to this mutex |
|
nodiscardinherited |
Get the "end" iterator of the manager.
lock | A AccessLock bound to this mutex |
|
nodiscardinherited |
Get the "bad" element.
A bad element is a "valid" default resource that is returned when the requested resource is not found. return The "bad" element
|
nodiscardinherited |
Get the resource with the given name.
name | The name of the resource to get |
|
overridevirtual |
Initialize the manager.
The philosophy with this class is to always return a "valid" element even if the element is not found. When this method is called, a "bad" element is created and stored in the manager.
return true if the manager is initialized, false otherwise
Implements fge::manager::BaseManager< TextureType, DataBlock >.
|
nodiscardoverridevirtual |
bool fge::texture::TextureManager::loadFromFile | ( | std::string_view | name, |
std::filesystem::path const & | path ) |
Load a texture from a file.
name | The name of the texture to load |
path | The path of the file to load |
bool fge::texture::TextureManager::loadFromSurface | ( | std::string_view | name, |
fge::Surface const & | surface ) |
Load a texture from a surface.
name | The name of the texture to load |
surface | The surface to load |
bool fge::texture::TextureManager::loadToGroupFromSurface | ( | std::string_view | name, |
fge::Surface const & | surface ) const |
Load a texture from a surface and add it to a group.
name | The name of the texture to load |
surface | The surface to load |
|
inherited |
Add a user handled resource.
name | The name of the texture to add |
block | The block data to add |
|
nodiscardinherited |
Get the number of elements in the manager.
return The number of elements in the manager without the "bad" element
|
overridevirtual |