DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches

Loads assets onto the GPU for the editor, cached by GUID: uint32_t texId = EditorAssets::Get()->LoadTexture(guid, &w, &h); Deki2D::BitmapFont* font = EditorAssets::Get()->GetBitmapFont(bakedGuid);. More...

#include <C:/Users/kirby/Documents/Github/deki/deki-editor/deki-editor/include/deki-editor/EditorAssets.h>

Public Types

using FontAtlasCallback = std::function<uint32_t(const std::string&, int, uint32_t*, uint32_t*)>
 The EditorTexture atlas of a TTF asset (GUID) at a pixel size, with its width and height, or 0 on failure.
using FontBakeCallback = std::function<Deki2D::BitmapFont*(const std::string&, int)>
 Bakes a TTF asset (GUID) at a pixel size.
using FontDestroyFn = void (*)(void* font)
 Destroys a font returned by FontFromDfontFn.
using FontFromDfontFn
 Loads a .dfont file, returning an opaque Deki2D::BitmapFont* and the atlas RGBA data to upload.
using ImageLoaderFn = uint8_t* (*)(const char* path, int32_t& outWidth, int32_t& outHeight, bool& outHasAlpha)
 Loads a .dtex image file as RGBA pixels. The caller must free() the buffer.

Public Member Functions

void ClearFontBakingCallbacks ()
 Must be called BEFORE FreeLibrary on the package that set the callbacks: the std::function destructor runs the callable's manager function, which must still be mapped.
void ClearFontCache ()
 Drops every cached font, freeing GPU memory.
void ClearTextureCache ()
 Drops every cached texture, freeing GPU memory.
Deki2D::BitmapFont * GetBitmapFont (const std::string &bakedGuid)
 The BitmapFont of a baked font, for glyph metrics, or nullptr if it is not cached.
Deki2D::BitmapFont * GetBitmapFontWithBaking (const std::string &sourceGuid, int fontSize)
 The BitmapFont of a TTF asset at a pixel size, baking it if needed, or nullptr if not found.
bool GetFrameUVs (const std::string &frameGuid, float *outU0, float *outV0, float *outU1, float *outV1)
 The normalized UVs (0 to 1) of a frame ("parent:frame-N") within its parent texture: (U0, V0) top-left, (U1, V1) bottom-right.
void InvalidateFontAtlas (const std::string &bakedGuid)
 Drops a cached font so the next access reloads it.
void InvalidateTexture (const std::string &guid)
 Drops a cached texture so the next access reloads it.
uint32_t LoadFontAtlas (const std::string &bakedGuid, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr)
 The EditorTexture atlas for a baked font (font.guid, resolved to a .dfont through AssetManager::LookupPath()), or 0 on failure.
uint32_t LoadFontAtlasFromPath (const std::string &dfontPath, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr)
 The EditorTexture atlas for the .dfont at a full path, or 0 on failure.
uint32_t LoadFontAtlasWithBaking (const std::string &sourceGuid, int fontSize, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr)
 The EditorTexture atlas of a TTF asset at a pixel size, baking it if needed, or 0 on failure.
uint32_t LoadFrameTexture (const std::string &frameGuid, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr)
 The EditorTexture of a frame's parent spritesheet, or 0 on failure.
bool LoadSpriteSettings (const std::string &guid, int *outFrameWidth=nullptr, int *outFrameHeight=nullptr)
 Reads a spritesheet's frame size from the asset's .data file.
uint32_t LoadTexture (const std::string &guid, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr)
 The EditorTexture for an asset GUID (resolved through AssetManager), uploading it on first use, or 0 on failure.
void SetFontBakingCallbacks (FontBakeCallback bakeFont, FontAtlasCallback getAtlas)
 Called by the editor at startup.

Static Public Member Functions

static void ClearPackageInjectedCallbacks ()
 Clears every function pointer packages registered.
static EditorAssets * Get ()
static ImageLoaderFn GetImageLoader ()
static void RegisterFontFactory (FontFromDfontFn factory, FontDestroyFn destroyer)
static void RegisterImageLoader (ImageLoaderFn fn)
static void Shutdown ()
 Frees every GPU resource.

Detailed Description

Loads assets onto the GPU for the editor, cached by GUID: uint32_t texId = EditorAssets::Get()->LoadTexture(guid, &w, &h); Deki2D::BitmapFont* font = EditorAssets::Get()->GetBitmapFont(bakedGuid);.

Paths come from AssetManager's GUID table, which the editor must fill when a project loads.

Member Typedef Documentation

◆ FontAtlasCallback

using DekiEditor::EditorAssets::FontAtlasCallback = std::function<uint32_t(const std::string&, int, uint32_t*, uint32_t*)>

The EditorTexture atlas of a TTF asset (GUID) at a pixel size, with its width and height, or 0 on failure.

◆ FontBakeCallback

using DekiEditor::EditorAssets::FontBakeCallback = std::function<Deki2D::BitmapFont*(const std::string&, int)>

Bakes a TTF asset (GUID) at a pixel size.

Returns the font, owned by the caller's cache, or nullptr on failure.

◆ FontDestroyFn

using DekiEditor::EditorAssets::FontDestroyFn = void (*)(void* font)

Destroys a font returned by FontFromDfontFn.

◆ FontFromDfontFn

Initial value:
void* (*)(const char* dfontPath, uint8_t** outAtlasRGBA, int32_t& outAtlasW,
int32_t& outAtlasH)

Loads a .dfont file, returning an opaque Deki2D::BitmapFont* and the atlas RGBA data to upload.

The caller owns the font and must free() outAtlasRGBA after uploading.

◆ ImageLoaderFn

using DekiEditor::EditorAssets::ImageLoaderFn = uint8_t* (*)(const char* path, int32_t& outWidth, int32_t& outHeight, bool& outHasAlpha)

Loads a .dtex image file as RGBA pixels. The caller must free() the buffer.

Member Function Documentation

◆ ClearFontBakingCallbacks()

void DekiEditor::EditorAssets::ClearFontBakingCallbacks ( )

Must be called BEFORE FreeLibrary on the package that set the callbacks: the std::function destructor runs the callable's manager function, which must still be mapped.

◆ ClearFontCache()

void DekiEditor::EditorAssets::ClearFontCache ( )

Drops every cached font, freeing GPU memory.

◆ ClearPackageInjectedCallbacks()

void DekiEditor::EditorAssets::ClearPackageInjectedCallbacks ( )
static

Clears every function pointer packages registered.

Must be called before a package DLL unloads, or the next LoadTexture/LoadFontAtlas calls code that is gone and the editor crashes.

◆ ClearTextureCache()

void DekiEditor::EditorAssets::ClearTextureCache ( )

Drops every cached texture, freeing GPU memory.

◆ Get()

EditorAssets * DekiEditor::EditorAssets::Get ( )
static

◆ GetBitmapFont()

Deki2D::BitmapFont * DekiEditor::EditorAssets::GetBitmapFont ( const std::string & bakedGuid)

The BitmapFont of a baked font, for glyph metrics, or nullptr if it is not cached.

◆ GetBitmapFontWithBaking()

Deki2D::BitmapFont * DekiEditor::EditorAssets::GetBitmapFontWithBaking ( const std::string & sourceGuid,
int fontSize )

The BitmapFont of a TTF asset at a pixel size, baking it if needed, or nullptr if not found.

◆ GetFrameUVs()

bool DekiEditor::EditorAssets::GetFrameUVs ( const std::string & frameGuid,
float * outU0,
float * outV0,
float * outU1,
float * outV1 )

The normalized UVs (0 to 1) of a frame ("parent:frame-N") within its parent texture: (U0, V0) top-left, (U1, V1) bottom-right.

Returns false when the frame is not found.

◆ GetImageLoader()

ImageLoaderFn DekiEditor::EditorAssets::GetImageLoader ( )
static

◆ InvalidateFontAtlas()

void DekiEditor::EditorAssets::InvalidateFontAtlas ( const std::string & bakedGuid)

Drops a cached font so the next access reloads it.

◆ InvalidateTexture()

void DekiEditor::EditorAssets::InvalidateTexture ( const std::string & guid)

Drops a cached texture so the next access reloads it.

◆ LoadFontAtlas()

uint32_t DekiEditor::EditorAssets::LoadFontAtlas ( const std::string & bakedGuid,
uint32_t * outWidth = nullptr,
uint32_t * outHeight = nullptr )

The EditorTexture atlas for a baked font (font.guid, resolved to a .dfont through AssetManager::LookupPath()), or 0 on failure.

◆ LoadFontAtlasFromPath()

uint32_t DekiEditor::EditorAssets::LoadFontAtlasFromPath ( const std::string & dfontPath,
uint32_t * outWidth = nullptr,
uint32_t * outHeight = nullptr )

The EditorTexture atlas for the .dfont at a full path, or 0 on failure.

◆ LoadFontAtlasWithBaking()

uint32_t DekiEditor::EditorAssets::LoadFontAtlasWithBaking ( const std::string & sourceGuid,
int fontSize,
uint32_t * outWidth = nullptr,
uint32_t * outHeight = nullptr )

The EditorTexture atlas of a TTF asset at a pixel size, baking it if needed, or 0 on failure.

◆ LoadFrameTexture()

uint32_t DekiEditor::EditorAssets::LoadFrameTexture ( const std::string & frameGuid,
uint32_t * outWidth = nullptr,
uint32_t * outHeight = nullptr )

The EditorTexture of a frame's parent spritesheet, or 0 on failure.

frameGuid has the form "parent:frame-N"; the size outputs get the parent texture's size. Use GetFrameUVs() for the frame's place in it.

◆ LoadSpriteSettings()

bool DekiEditor::EditorAssets::LoadSpriteSettings ( const std::string & guid,
int * outFrameWidth = nullptr,
int * outFrameHeight = nullptr )

Reads a spritesheet's frame size from the asset's .data file.

Returns false for a texture without sprite settings.

◆ LoadTexture()

uint32_t DekiEditor::EditorAssets::LoadTexture ( const std::string & guid,
uint32_t * outWidth = nullptr,
uint32_t * outHeight = nullptr )

The EditorTexture for an asset GUID (resolved through AssetManager), uploading it on first use, or 0 on failure.

Width and height are written to the optional outputs.

◆ RegisterFontFactory()

void DekiEditor::EditorAssets::RegisterFontFactory ( FontFromDfontFn factory,
FontDestroyFn destroyer )
static

◆ RegisterImageLoader()

void DekiEditor::EditorAssets::RegisterImageLoader ( ImageLoaderFn fn)
static

◆ SetFontBakingCallbacks()

void DekiEditor::EditorAssets::SetFontBakingCallbacks ( FontBakeCallback bakeFont,
FontAtlasCallback getAtlas )

Called by the editor at startup.

◆ Shutdown()

void DekiEditor::EditorAssets::Shutdown ( )
static

Frees every GPU resource.


The documentation for this class was generated from the following file: