#ifndef PKE_FONT_TYPE_HPP #define PKE_FONT_TYPE_HPP #include "asset-manager.hpp" #include "components.hpp" #include "pk.h" #include TypeSafeInt_H(FontTypeIndex, uint16_t, 0xFFFF); TypeSafeInt_H(FontRenderIndex, uint16_t, 0xFFFF); struct FontGlyphChar { uint32_t unicode; glm::vec2 sprite_region_min; glm::vec2 sprite_region_max; }; struct FontRender { uint32_t len; FontTypeIndex index_ft; FontRenderIndex index_fr; }; struct FontType : public Entity_Base { pk_cstr title; AssetHandle fontTextureAssetHandle; AssetHandle glyphDetailsAssetHandle; VkDeviceMemory deviceMemoryVert = VK_NULL_HANDLE; VkDeviceMemory deviceMemoryTexture = VK_NULL_HANDLE; VkDeviceMemory deviceMemoryInst = VK_NULL_HANDLE; VkImage textureImage = VK_NULL_HANDLE; VkImageView textureImageView = VK_NULL_HANDLE; VkDescriptorPool vkDescriptorPool = VK_NULL_HANDLE; VkDescriptorSet *vkDescriptorSets = nullptr; FontGlyphChar *glyphs; FontRender *renders = nullptr; glm::vec2 atlas_size; uint32_t n_glyphs; FontRenderIndex n_render = FontRenderIndex{0}; FontRenderIndex h_render = FontRenderIndex{0}; FontTypeIndex index_ft = FontTypeIndex{0}; struct FontTypeBindings { BufferBindingDetails vertexBD; BufferBindingDetails uvBD; BufferBindingDetails atlasSizeBD; BufferBindingDetails indexBD; BufferBindingDetails instanceBD; uint32_t indexCount = 0; uint32_t instanceCounter = 0; } bindings; }; void FontType_Init(); void FontType_Teardown(); void FontType_Tick(); void FontType_Serialize(std::ofstream &stream, FontType *ft); void FontType_Deserialize(std::ifstream &stream); FontType* FontType_GetFonts(FontTypeIndex &count); FontTypeIndex FontType_RegisterFont(pk_cstr title, AssetHandle fontTextureHandle, AssetHandle glyphsHandle); void FontType_Unload(FontTypeIndex idx); FontRender FontType_AddStringRender(FontTypeIndex idx_ft, pk_cstr cstr); void FontType_RemoveStringRender(FontRender fr); #endif /* PKE_FONT_TYPE_HPP */