Convenient abstraction that's responsible for loading assets at a given assetsPath.
More...
#include <AssetLoader.h>
|
| | AssetLoader (std::filesystem::path assetsPath) |
| | Creates an asset loader rooted at the given assets directory.
|
| | ~AssetLoader () |
| const std::filesystem::path & | GetPath () const |
| | Returns the current assets directory.
|
| void | SetPath (const std::filesystem::path &assetsPath) |
| | Changes the assets directory used for future loads.
|
| void | InitAssets () |
| | Initializes fonts and other asset-backed runtime state.
|
| void | UnloadAssets () |
| | Releases loaded asset resources.
|
| void | LoadAssets () |
| | Loads shared textures and sounds from disk.
|
| void | RenderImage (const char *name, ImDrawList *drawList, const ImVec2 &pos, const ImVec2 &size, const ImVec4 &tint=ImVec4(1, 1, 1, 1)) |
| | Draws a loaded image into an ImGui draw list.
|
| uint32_t | LoadImage (const char *name) |
| | Loads an image asset and returns its texture handle.
|
| AudioData | LoadSound (std::filesystem::path soundPath) |
| | Loads a sound asset into memory.
|
| void | PlaySound (AudioData data) |
| | Plays decoded audio data through the audio manager.
|
| ImFont * | GetFontRegular () const |
| | Returns the regular UI font.
|
| ImFont * | GetFontBold () const |
| | Returns the bold UI font.
|
Convenient abstraction that's responsible for loading assets at a given assetsPath.
- Note
- Responsible for images, sounds and fonts.
-
Should be instantiated once per program execution.
◆ AssetLoader()
| FuncDoodle::AssetLoader::AssetLoader |
( |
std::filesystem::path | assetsPath | ) |
|
|
explicit |
Creates an asset loader rooted at the given assets directory.
- Parameters
-
| assetsPath | Filesystem path containing runtime assets. |
◆ ~AssetLoader()
| FuncDoodle::AssetLoader::~AssetLoader |
( |
| ) |
|
◆ GetFontBold()
| ImFont * FuncDoodle::AssetLoader::GetFontBold |
( |
| ) |
const |
|
inlinenodiscard |
Returns the bold UI font.
- Returns
- Pointer to the bold font.
◆ GetFontRegular()
| ImFont * FuncDoodle::AssetLoader::GetFontRegular |
( |
| ) |
const |
|
inlinenodiscard |
Returns the regular UI font.
- Returns
- Pointer to the regular font.
◆ GetPath()
| const std::filesystem::path & FuncDoodle::AssetLoader::GetPath |
( |
| ) |
const |
|
inlinenodiscard |
Returns the current assets directory.
- Returns
- Path used for asset loading.
◆ InitAssets()
| void FuncDoodle::AssetLoader::InitAssets |
( |
| ) |
|
Initializes fonts and other asset-backed runtime state.
◆ LoadAssets()
| void FuncDoodle::AssetLoader::LoadAssets |
( |
| ) |
|
Loads shared textures and sounds from disk.
◆ LoadImage()
| uint32_t FuncDoodle::AssetLoader::LoadImage |
( |
const char * | name | ) |
|
Loads an image asset and returns its texture handle.
- Parameters
-
- Returns
- OpenGL texture ID for the loaded image.
◆ LoadSound()
| AudioData FuncDoodle::AssetLoader::LoadSound |
( |
std::filesystem::path | soundPath | ) |
|
Loads a sound asset into memory.
- Parameters
-
| soundName | Relative sound asset path. |
- Returns
- Decoded audio data.
◆ PlaySound()
| void FuncDoodle::AssetLoader::PlaySound |
( |
AudioData | data | ) |
|
Plays decoded audio data through the audio manager.
- Parameters
-
| data | Audio sample buffer to play. |
◆ RenderImage()
| void FuncDoodle::AssetLoader::RenderImage |
( |
const char * | name, |
|
|
ImDrawList * | drawList, |
|
|
const ImVec2 & | pos, |
|
|
const ImVec2 & | size, |
|
|
const ImVec4 & | tint = ImVec4(1, 1, 1, 1) ) |
Draws a loaded image into an ImGui draw list.
- Parameters
-
| name | Asset name to render. |
| drawList | Draw list to submit image commands to. |
| pos | Top-left position in screen space. |
| size | Render size in pixels. |
| tint | Tint color applied while rendering. |
◆ SetPath()
| void FuncDoodle::AssetLoader::SetPath |
( |
const std::filesystem::path & | assetsPath | ) |
|
|
inline |
Changes the assets directory used for future loads.
- Parameters
-
| assetsPath | New assets directory. |
◆ UnloadAssets()
| void FuncDoodle::AssetLoader::UnloadAssets |
( |
| ) |
|
Releases loaded asset resources.
◆ m_AssetsPath
| std::filesystem::path FuncDoodle::AssetLoader::m_AssetsPath |
|
private |
◆ m_AudioManager
◆ m_FontBold
| ImFont* FuncDoodle::AssetLoader::m_FontBold = nullptr |
|
private |
◆ m_FontRegular
| ImFont* FuncDoodle::AssetLoader::m_FontRegular = nullptr |
|
private |
The documentation for this class was generated from the following files: