summaryrefslogtreecommitdiff
path: root/src/font.hpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-01-23 21:57:31 -0500
committerJonathan Bradley <jcb@pikum.xyz>2025-01-23 21:57:31 -0500
commite93eb289ca44e98967482ab80fd5329f85ccd03e (patch)
tree4164b6d5b9ac2e40d18ec3eea52730c9f9606ccb /src/font.hpp
parent846a6e1185417ee3e187edc06ef327d180bf0d9b (diff)
pke: first-pass 2d overlay render pass scaffolding
Diffstat (limited to 'src/font.hpp')
-rw-r--r--src/font.hpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/font.hpp b/src/font.hpp
new file mode 100644
index 0000000..48a7b40
--- /dev/null
+++ b/src/font.hpp
@@ -0,0 +1,74 @@
+#ifndef PKE_FONT_TYPE_HPP
+#define PKE_FONT_TYPE_HPP
+
+#include "asset-manager.hpp"
+#include "components.hpp"
+#include "pk.h"
+
+#include <glm/vec4.hpp>
+
+/*
+Vert: (two triangles)
+vec2 vertex
+vec2 uv
+
+Inst:
+vec4 fg_color
+vec4 bg_color
+vec4 sprite_region
+float width
+
+Texture:
+the MTSDF
+*/
+
+TypeSafeInt_H(FontTypeIndex, uint16_t, 0xFFFF);
+TypeSafeInt_H(FontRenderIndex, uint16_t, 0xFFFF);
+
+struct FontGlyphChar {
+ uint32_t unicode;
+ glm::ivec4 bounds;
+};
+struct FontRender {
+ uint32_t len;
+ FontTypeIndex index_ft;
+ FontRenderIndex index_fr;
+};
+struct FontType : public Entity_Base {
+ pk_cstr title;
+ AssetHandle fontTextureAssetKey;
+ AssetHandle glyphDetailsAssetKey;
+ 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;
+ FontRender *renders = nullptr;
+ FontRenderIndex n_render = FontRenderIndex{0};
+ FontRenderIndex h_render = FontRenderIndex{0};
+ FontTypeIndex index_ft = FontTypeIndex{0};
+ struct FontTypeBindings {
+ BufferBindingDetails vertexBD;
+ BufferBindingDetails uvBD;
+ BufferBindingDetails indexBD;
+ BufferBindingDetails instanceBD;
+ uint32_t indexCount;
+ uint32_t instanceCounter = 0;
+ uint32_t instanceBufferMaxCount = 0;
+ } bindings;
+};
+
+
+void FontType_Init();
+void FontType_Teardown();
+// void FontType_Serialize(FontType *ft); // TODO
+// void FontType_Deserialize(FontType **ft); // TODO
+FontType* FontType_GetFonts(FontTypeIndex &count);
+FontTypeIndex FontType_RegisterFont(pk_cstr title, AssetKey fontTexture, AssetKey glyphs);
+void FontType_Unload(FontTypeIndex idx);
+FontRender FontType_AddStringRender(FontTypeIndex idx_ft, pk_cstr cstr);
+void FontType_RemoveStringRender(FontRender fr);
+
+#endif /* PKE_FONT_TYPE_HPP */