diff options
Diffstat (limited to 'src/font.cpp')
| -rw-r--r-- | src/font.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/font.cpp b/src/font.cpp index 26004e3..6d47fa9 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -4,7 +4,6 @@ #include "pk.h" #include "window.hpp" #include "static-plane.hpp" -#include "vendor-stb-image-include.h" #include "game-settings.hpp" #include "ecs.hpp" #include "../embed/embedded-fonts.h" @@ -586,13 +585,8 @@ FontTypeIndex FontType_RegisterFont(pk_cstr title, AssetHandle fontTextureHandle ft->n_glyphs = glyphs->size / sizeof(FontGlyphChar); ft->glyphs = (FontGlyphChar*)glyphs->ptr; - int txtr_x, txtr_y, txtr_chan; - stbi_uc *txtr_bytes = stbi_load_from_memory((unsigned char*)fontTexture->ptr, fontTexture->size, &txtr_x, &txtr_y, &txtr_chan, 4); - assert(txtr_bytes != nullptr); - assert(txtr_chan == 4); - uint32_t imageSizeBytes = txtr_x * txtr_y * txtr_chan; - ft->atlas_size.x = (float)txtr_x; - ft->atlas_size.y = (float)txtr_y; + ft->atlas_size.x = (float)fontTexture->details.texture.width; + ft->atlas_size.y = (float)fontTexture->details.texture.height; ECS_CreateEntity(ft); @@ -647,20 +641,16 @@ FontTypeIndex FontType_RegisterFont(pk_cstr title, AssetHandle fontTextureHandle // texture pkvk_texture_upload_data txtr_data{}; - txtr_data.bytes = txtr_bytes; - txtr_data.n_bytes = imageSizeBytes; - txtr_data.width = (uint32_t)txtr_x; - txtr_data.height = (uint32_t)txtr_y; + txtr_data.texture_assets[0] = fontTexture; + txtr_data.n_textures = 1; pkvk_texture_upload_data_out txtr_out{}; pkvk_texture_upload(&txtr_data, &txtr_out); - ft->gr.textureImage = txtr_out.image; - ft->gr.textureImageView = txtr_out.image_view; + ft->gr.textureImage = txtr_out.images[0]; + ft->gr.textureImageView = txtr_out.image_views[0]; ft->gr.deviceMemoryTexture = txtr_out.device_memory; - free(txtr_bytes); - /* * Vulkan descriptor sets */ @@ -709,8 +699,6 @@ FontTypeIndex FontType_RegisterFont(pk_cstr title, AssetHandle fontTextureHandle vkUpdateDescriptorSets(vkDevice, (uint32_t)1, &writeDescriptorSet, 0, nullptr); - } else { - free(txtr_bytes); } AM_Release(fontTextureHandle); |
