ULRE/src/SceneGraph/Vulkan/VKTileFont.cpp

42 lines
1.0 KiB
C++
Raw Normal View History

2020-08-04 01:27:35 +08:00
#include<hgl/graph/font/TileFont.h>
#include<hgl/graph/RenderFramework.h>
#include<hgl/graph/module/TextureManager.h>
#include<hgl/graph/module/SwapchainModule.h>
2020-07-31 18:01:28 +08:00
VK_NAMESPACE_BEGIN
/**
* 使Tile字符管理对象
* @param f
* @param limit_count
*/
TileFont *RenderFramework::CreateTileFont(FontSource *fs,int limit_count)
2020-07-31 18:01:28 +08:00
{
2020-08-04 18:28:34 +08:00
if(!fs)return(nullptr);
2022-02-21 11:18:51 +08:00
const uint32_t height=hgl_align_pow2(fs->GetCharHeight()+2,4); //上下左右各空一个象素并保证可以被4整除
2020-07-31 18:01:28 +08:00
if(limit_count<=0)
{
2025-03-06 01:24:25 +08:00
VkExtent2D ext;
if(!sc_module->GetSwapchainSize(&ext))
{
ext.width=1920;
ext.height=1080;
}
2020-07-31 18:01:28 +08:00
2022-02-18 19:04:48 +08:00
limit_count=(ext.width/height)*(ext.height/height); //按全屏幕放满不一样的字符为上限
2020-07-31 18:01:28 +08:00
}
if(!fs)
return(nullptr);
TileData *td=tex_manager->CreateTileData(UPF_R8,height,height,limit_count);
2020-07-31 18:01:28 +08:00
if(!td)
return nullptr;
return(new TileFont(td,fs));
}
VK_NAMESPACE_END