FuncDoodle
Loading...
Searching...
No Matches
FuncDoodle::AssetLoader Class Reference

Convenient abstraction that's responsible for loading assets at a given assetsPath. More...

#include <AssetLoader.h>

Public Member Functions

 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.

Private Attributes

std::filesystem::path m_AssetsPath
UniquePtr< AudioManagerm_AudioManager
ImFont * m_FontRegular = nullptr
ImFont * m_FontBold = nullptr

Detailed Description

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.

Constructor & Destructor Documentation

◆ AssetLoader()

FuncDoodle::AssetLoader::AssetLoader ( std::filesystem::path assetsPath)
explicit

Creates an asset loader rooted at the given assets directory.

Parameters
assetsPathFilesystem path containing runtime assets.

◆ ~AssetLoader()

FuncDoodle::AssetLoader::~AssetLoader ( )

Member Function Documentation

◆ 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
nameAsset name to load.
Returns
OpenGL texture ID for the loaded image.

◆ LoadSound()

AudioData FuncDoodle::AssetLoader::LoadSound ( std::filesystem::path soundPath)

Loads a sound asset into memory.

Parameters
soundNameRelative sound asset path.
Returns
Decoded audio data.

◆ PlaySound()

void FuncDoodle::AssetLoader::PlaySound ( AudioData data)

Plays decoded audio data through the audio manager.

Parameters
dataAudio 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
nameAsset name to render.
drawListDraw list to submit image commands to.
posTop-left position in screen space.
sizeRender size in pixels.
tintTint color applied while rendering.

◆ SetPath()

void FuncDoodle::AssetLoader::SetPath ( const std::filesystem::path & assetsPath)
inline

Changes the assets directory used for future loads.

Parameters
assetsPathNew assets directory.

◆ UnloadAssets()

void FuncDoodle::AssetLoader::UnloadAssets ( )

Releases loaded asset resources.

Member Data Documentation

◆ m_AssetsPath

std::filesystem::path FuncDoodle::AssetLoader::m_AssetsPath
private

◆ m_AudioManager

UniquePtr<AudioManager> FuncDoodle::AssetLoader::m_AudioManager
private

◆ 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: