ULRE/src/SceneGraph/Vulkan/VKTileFont.cpp

42 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include<hgl/graph/font/TileFont.h>
#include<hgl/graph/RenderFramework.h>
#include<hgl/graph/module/TextureManager.h>
#include<hgl/graph/module/SwapchainModule.h>
VK_NAMESPACE_BEGIN
/**
* 创建只使用一种字符的Tile字符管理对象
* @param f 字体需求信息
* @param limit_count 缓冲字符数量上限
*/
TileFont *RenderFramework::CreateTileFont(FontSource *fs,int limit_count)
{
if(!fs)return(nullptr);
const uint32_t height=hgl_align_pow2(fs->GetCharHeight()+2,4); //上下左右各空一个象素并保证可以被4整除
if(limit_count<=0)
{
VkExtent2D ext;
if(!sc_module->GetSwapchainSize(&ext))
{
ext.width=1920;
ext.height=1080;
}
limit_count=(ext.width/height)*(ext.height/height); //按全屏幕放满不一样的字符为上限
}
if(!fs)
return(nullptr);
TileData *td=tex_manager->CreateTileData(UPF_R8,height,height,limit_count);
if(!td)
return nullptr;
return(new TileFont(td,fs));
}
VK_NAMESPACE_END