|
Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
|
Editor-only asset utilities for GPU resource management. More...
#include <EditorAssets.h>
Public Types | |
| using | ImageLoaderFn = uint8_t* (*)(const char* path, int32_t& outWidth, int32_t& outHeight, bool& outHasAlpha) |
| Load a .dtex image file as RGBA pixel data. Caller must free() the returned buffer. | |
| using | FontFromDfontFn = void* (*)(const char* dfontPath, uint8_t** outAtlasRGBA, int32_t& outAtlasW, int32_t& outAtlasH) |
| Load a .dfont file, returning an opaque BitmapFont* and the atlas RGBA data for GPU upload. | |
| using | FontDestroyFn = void (*)(void* font) |
| Destroy an opaque BitmapFont* returned by FontFromDfontFn. | |
| using | FontBakeCallback = std::function<BitmapFont*(const std::string&, int)> |
| Callback for font baking. | |
| using | FontAtlasCallback = std::function<uint32_t(const std::string&, int, uint32_t*, uint32_t*)> |
| Callback for getting font atlas texture. | |
Public Member Functions | |
| uint32_t | LoadTexture (const std::string &guid, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr) |
| Load texture by GUID and upload to GPU. | |
| void | InvalidateTexture (const std::string &guid) |
| Invalidate cached texture (forces reload on next access). | |
| void | ClearTextureCache () |
| Clear all cached textures (frees GPU memory). | |
| uint32_t | LoadFontAtlas (const std::string &bakedGuid, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr) |
| Load font atlas by baked GUID and upload to GPU. | |
| uint32_t | LoadFontAtlasFromPath (const std::string &dfontPath, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr) |
| Load font atlas from filesystem path. | |
| BitmapFont * | GetBitmapFont (const std::string &bakedGuid) |
| Get BitmapFont by baked GUID (for glyph metrics). | |
| void | InvalidateFontAtlas (const std::string &bakedGuid) |
| Invalidate cached font (forces reload on next access). | |
| void | ClearFontCache () |
| Clear all cached fonts (frees GPU memory). | |
| void | SetFontBakingCallbacks (FontBakeCallback bakeFont, FontAtlasCallback getAtlas) |
| Set callbacks for font baking (called by editor on startup). | |
| void | ClearFontBakingCallbacks () |
| Clear font baking callbacks before package DLL unload. | |
| BitmapFont * | GetBitmapFontWithBaking (const std::string &sourceGuid, int fontSize) |
| Get BitmapFont by source GUID and size (triggers baking if needed). | |
| uint32_t | LoadFontAtlasWithBaking (const std::string &sourceGuid, int fontSize, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr) |
| Load font atlas by source GUID and size (triggers baking if needed). | |
| bool | LoadSpriteSettings (const std::string &guid, int *outFrameWidth=nullptr, int *outFrameHeight=nullptr) |
| Load sprite settings (frame dimensions) from .data file. | |
| uint32_t | LoadFrameTexture (const std::string &frameGuid, uint32_t *outWidth=nullptr, uint32_t *outHeight=nullptr) |
| Load texture for a frame sprite (loads parent spritesheet texture). | |
| bool | GetFrameUVs (const std::string &frameGuid, float *outU0, float *outV0, float *outU1, float *outV1) |
| Get UV coordinates for a frame sprite. | |
Static Public Member Functions | |
| static void | RegisterImageLoader (ImageLoaderFn fn) |
| static void | RegisterFontFactory (FontFromDfontFn factory, FontDestroyFn destroyer) |
| static ImageLoaderFn | GetImageLoader () |
| static void | ClearPackageInjectedCallbacks () |
| Null all package-injected function pointers. | |
| static EditorAssets * | Get () |
| Get singleton instance. | |
| static void | Shutdown () |
| Shutdown and cleanup all GPU resources. | |
Editor-only asset utilities for GPU resource management.
Provides Unity-like asset loading for editor use: uint32_t texId = EditorAssets::Get()->LoadTexture(guid, &w, &h); BitmapFont* font = EditorAssets::Get()->GetBitmapFont(bakedGuid);
Features:
Note: Uses AssetManager's GUID table for path resolution. The editor must populate the GUID table on project load.
| using DekiEditor::EditorAssets::ImageLoaderFn = uint8_t* (*)(const char* path, int32_t& outWidth, int32_t& outHeight, bool& outHasAlpha) |
Load a .dtex image file as RGBA pixel data. Caller must free() the returned buffer.
| using DekiEditor::EditorAssets::FontFromDfontFn = void* (*)(const char* dfontPath, uint8_t** outAtlasRGBA, int32_t& outAtlasW, int32_t& outAtlasH) |
Load a .dfont file, returning an opaque BitmapFont* and the atlas RGBA data for GPU upload.
The caller must free() outAtlasRGBA after uploading. The returned font is owned by the caller.
| using DekiEditor::EditorAssets::FontDestroyFn = void (*)(void* font) |
Destroy an opaque BitmapFont* returned by FontFromDfontFn.
| using DekiEditor::EditorAssets::FontBakeCallback = std::function<BitmapFont*(const std::string&, int)> |
Callback for font baking.
| sourceGuid | TTF asset GUID |
| fontSize | Font size in pixels |
| using DekiEditor::EditorAssets::FontAtlasCallback = std::function<uint32_t(const std::string&, int, uint32_t*, uint32_t*)> |
Callback for getting font atlas texture.
| sourceGuid | TTF asset GUID |
| fontSize | Font size in pixels |
| outWidth | Output atlas width |
| outHeight | Output atlas height |
|
static |
|
static |
|
static |
|
static |
Null all package-injected function pointers.
Must be called before a package DLL is unloaded — otherwise any subsequent LoadTexture/LoadFontAtlas would invoke code that no longer exists, crashing the editor.
|
static |
Get singleton instance.
|
static |
Shutdown and cleanup all GPU resources.
| uint32_t DekiEditor::EditorAssets::LoadTexture | ( | const std::string & | guid, |
| uint32_t * | outWidth = nullptr, | ||
| uint32_t * | outHeight = nullptr ) |
Load texture by GUID and upload to GPU.
| guid | Asset GUID (looked up via AssetManager) |
| outWidth | Optional output for texture width |
| outHeight | Optional output for texture height |
Textures are cached - subsequent calls with same GUID return cached texture.
| void DekiEditor::EditorAssets::InvalidateTexture | ( | const std::string & | guid | ) |
Invalidate cached texture (forces reload on next access).
| guid | Asset GUID |
| void DekiEditor::EditorAssets::ClearTextureCache | ( | ) |
Clear all cached textures (frees GPU memory).
| uint32_t DekiEditor::EditorAssets::LoadFontAtlas | ( | const std::string & | bakedGuid, |
| uint32_t * | outWidth = nullptr, | ||
| uint32_t * | outHeight = nullptr ) |
Load font atlas by baked GUID and upload to GPU.
| bakedGuid | Deterministic GUID of the baked font (font.guid) |
| outWidth | Optional output for atlas width |
| outHeight | Optional output for atlas height |
Uses AssetManager::LookupPath() to resolve the baked GUID to a .dfont path.
| uint32_t DekiEditor::EditorAssets::LoadFontAtlasFromPath | ( | const std::string & | dfontPath, |
| uint32_t * | outWidth = nullptr, | ||
| uint32_t * | outHeight = nullptr ) |
Load font atlas from filesystem path.
| dfontPath | Full path to the .dfont file |
| outWidth | Optional output for atlas width |
| outHeight | Optional output for atlas height |
| BitmapFont * DekiEditor::EditorAssets::GetBitmapFont | ( | const std::string & | bakedGuid | ) |
Get BitmapFont by baked GUID (for glyph metrics).
| bakedGuid | Deterministic GUID of the baked font |
| void DekiEditor::EditorAssets::InvalidateFontAtlas | ( | const std::string & | bakedGuid | ) |
Invalidate cached font (forces reload on next access).
| bakedGuid | Baked font GUID |
| void DekiEditor::EditorAssets::ClearFontCache | ( | ) |
Clear all cached fonts (frees GPU memory).
| void DekiEditor::EditorAssets::SetFontBakingCallbacks | ( | FontBakeCallback | bakeFont, |
| FontAtlasCallback | getAtlas ) |
Set callbacks for font baking (called by editor on startup).
| void DekiEditor::EditorAssets::ClearFontBakingCallbacks | ( | ) |
Clear font baking callbacks before package DLL unload.
Must be called BEFORE FreeLibrary on the package that set the callbacks, so the std::function destructor can safely invoke the old callable's manager function while the DLL code is still mapped.
| BitmapFont * DekiEditor::EditorAssets::GetBitmapFontWithBaking | ( | const std::string & | sourceGuid, |
| int | fontSize ) |
Get BitmapFont by source GUID and size (triggers baking if needed).
| sourceGuid | TTF asset GUID |
| fontSize | Font size in pixels |
| uint32_t DekiEditor::EditorAssets::LoadFontAtlasWithBaking | ( | const std::string & | sourceGuid, |
| int | fontSize, | ||
| uint32_t * | outWidth = nullptr, | ||
| uint32_t * | outHeight = nullptr ) |
Load font atlas by source GUID and size (triggers baking if needed).
| sourceGuid | TTF asset GUID |
| fontSize | Font size in pixels |
| outWidth | Optional output for atlas width |
| outHeight | Optional output for atlas height |
| bool DekiEditor::EditorAssets::LoadSpriteSettings | ( | const std::string & | guid, |
| int * | outFrameWidth = nullptr, | ||
| int * | outFrameHeight = nullptr ) |
Load sprite settings (frame dimensions) from .data file.
| guid | Asset GUID |
| outFrameWidth | Optional output for frame width |
| outFrameHeight | Optional output for frame height |
For spritesheets, this returns the individual frame dimensions. For regular textures without sprite settings, returns false.
| uint32_t DekiEditor::EditorAssets::LoadFrameTexture | ( | const std::string & | frameGuid, |
| uint32_t * | outWidth = nullptr, | ||
| uint32_t * | outHeight = nullptr ) |
Load texture for a frame sprite (loads parent spritesheet texture).
| frameGuid | Frame GUID (format: "parent:frame-N") |
| outWidth | Optional output for parent texture width |
| outHeight | Optional output for parent texture height |
Frame sprites reference the same texture as their parent spritesheet. Use GetFrameUVs() to get the UV coordinates for the specific frame.
| bool DekiEditor::EditorAssets::GetFrameUVs | ( | const std::string & | frameGuid, |
| float * | outU0, | ||
| float * | outV0, | ||
| float * | outU1, | ||
| float * | outV1 ) |
Get UV coordinates for a frame sprite.
| frameGuid | Frame GUID (format: "parent:frame-N") |
| outU0 | Output for top-left U coordinate |
| outV0 | Output for top-left V coordinate |
| outU1 | Output for bottom-right U coordinate |
| outV1 | Output for bottom-right V coordinate |
UV coordinates are normalized (0.0 to 1.0) based on frame position within parent texture.