summaryrefslogtreecommitdiff
path: root/src/font.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/font.hpp')
-rw-r--r--src/font.hpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/font.hpp b/src/font.hpp
index dd1b682..cdbc309 100644
--- a/src/font.hpp
+++ b/src/font.hpp
@@ -8,10 +8,11 @@
#include "vendor-glm-include.hpp"
#define PKE_FONT_MAX_FONT_TYPES 64
-#define PKE_FONT_MAX_FONT_RENDERS 64
TypeSafeInt_H(FontTypeIndex, uint16_t, 0xFFFF);
-TypeSafeInt_H(FontRenderIndex, uint16_t, 0xFFFF);
+struct FontRenderHandle : pk_bkt_arr_handle {};
+
+constexpr FontRenderHandle FontRenderHandle_MAX = FontRenderHandle{ pk_bkt_arr_handle_MAX_constexpr };
TypeSafeInt_H(FONT_GLYPH_CHAR_FLAG, uint8_t, 0xFF);
TypeSafeInt_H(FONT_RENDER_FLAG, uint8_t, 0xFF);
@@ -40,14 +41,14 @@ const FONT_RENDER_SURFACE_AREA_TYPE_FLAG FONT_RENDER_SURFACE_AREA_TYPE_FLAGS_CEN
const FONT_RENDER_SURFACE_AREA_TYPE_FLAG FONT_RENDER_SURFACE_AREA_TYPE_FLAGS_CENTER_BOTH
= FONT_RENDER_SURFACE_AREA_TYPE_FLAG((1u << 0) | (1u << 1));
-struct FontRenderHandle {
+struct FontTypeRender {
FontTypeIndex index_ft;
- FontRenderIndex index_fr;
+ FontRenderHandle handle_fr;
};
-constexpr struct FontRenderHandle FontRenderHandle_MAX = {
+constexpr FontTypeRender FontTypeRender_MAX = {
.index_ft = FontTypeIndex_MAX,
- .index_fr = FontRenderIndex_MAX,
+ .handle_fr = { pk_bkt_arr_handle_MAX },
};
struct FontGlyphChar {
@@ -71,6 +72,7 @@ struct FontRenderSettings {
};
struct FontRender : public Entity_Base {
uint32_t *glyph_indices = nullptr;
+ FontTypeIndex index_ft = FontTypeIndex{0};
FontRenderHandle fr_handle = FontRenderHandle_MAX;
uint32_t n_glyphs = 0;
uint32_t buffer_start_index = 0;
@@ -95,11 +97,9 @@ struct FontType : public Entity_Base {
AssetHandle fontTextureAssetHandle;
AssetHandle glyphDetailsAssetHandle;
FontGlyphChar *glyphs;
- FontRender *renders = nullptr;
glm::vec2 atlas_size;
uint32_t n_glyphs;
- FontRenderIndex n_render = FontRenderIndex{0};
- uint64_t unused_frs;
+ pk_bkt_arr_t<FontRender> renders;
FontTypeIndex index_ft = FontTypeIndex{0};
struct FontTypeMSDFSettings msdf_settings;
struct FontTypeSpacing spacing;
@@ -134,10 +134,10 @@ FontType* FontType_Get(FontTypeIndex idx);
FontType* FontType_GetByTitle(const pk_cstr title);
FontType* FontType_GetFonts(uint64_t &idx_unused);
FontTypeIndex FontType_RegisterFont(pk_cstr title, AssetHandle fontTextureHandle, AssetHandle glyphsHandle, FontTypeMSDFSettings *msdf_settings, FontTypeSpacing *spacing);
-FontRenderHandle FontType_AddStringRender(FontTypeIndex idx_ft, const pk_cstr &&str, FontRenderSettings *settings, Entity_Base *parent = nullptr, pk_uuid uuid = pk_uuid_zed);
-FontRender *FontType_GetFontRender(FontRenderHandle frh);
-void FontType_UpdateStringRender(FontRenderHandle frh, FontRenderSettings *settings);
-void FontType_UpdateStringRenderText(FontRenderHandle frh, pk_cstr &&cstr);
-void FontType_RemoveStringRender(FontRenderHandle frh);
+FontTypeRender FontType_AddStringRender(FontTypeIndex idx_ft, const pk_cstr &&str, FontRenderSettings *settings, Entity_Base *parent = nullptr, pk_uuid uuid = pk_uuid_zed);
+FontRender *FontType_GetFontRender(FontTypeRender frh);
+void FontType_UpdateStringRender(FontTypeRender frh, FontRenderSettings *settings);
+void FontType_UpdateStringRenderText(FontTypeRender frh, pk_cstr &&cstr);
+void FontType_RemoveStringRender(FontTypeRender frh);
#endif /* PKE_FONT_TYPE_HPP */