2022-02-17 10:48:12 +08:00
|
|
|
|
#ifndef HGL_GRAPH_TEXT_RENDER_INCLUDE
|
2022-02-16 23:26:50 +08:00
|
|
|
|
#define HGL_GRAPH_TEXT_RENDER_INCLUDE
|
|
|
|
|
|
|
|
|
|
#include<hgl/graph/VK.h>
|
2023-02-19 19:28:47 +08:00
|
|
|
|
#include<hgl/color/Color4f.h>
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
|
|
|
|
namespace hgl
|
|
|
|
|
{
|
|
|
|
|
namespace graph
|
|
|
|
|
{
|
|
|
|
|
class FontSource;
|
|
|
|
|
class TileFont;
|
|
|
|
|
class TextLayout;
|
2022-06-24 17:51:05 +08:00
|
|
|
|
class TextPrimitive;
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
|
|
|
|
class TextRender
|
|
|
|
|
{
|
2022-02-17 11:02:55 +08:00
|
|
|
|
GPUDevice * device;
|
|
|
|
|
RenderResource * db;
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
2022-02-17 11:02:55 +08:00
|
|
|
|
Material * material;
|
|
|
|
|
MaterialInstance * material_instance;
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
2022-02-17 11:02:55 +08:00
|
|
|
|
Sampler * sampler;
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
2022-02-17 11:02:55 +08:00
|
|
|
|
Pipeline * pipeline;
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
2022-02-17 11:02:55 +08:00
|
|
|
|
FontSource * font_source;
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
2022-02-17 11:02:55 +08:00
|
|
|
|
TileFont * tile_font;
|
|
|
|
|
TextLayout * tl_engine;
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
|
|
|
|
Color4f color;
|
2022-10-14 17:52:35 +08:00
|
|
|
|
DeviceBuffer * ubo_color;
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
2022-06-24 17:51:05 +08:00
|
|
|
|
SortedSets<TextPrimitive *> tr_sets;
|
2022-02-21 17:13:12 +08:00
|
|
|
|
|
2022-02-16 23:26:50 +08:00
|
|
|
|
private:
|
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
friend TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit=-1);
|
2022-02-17 10:48:12 +08:00
|
|
|
|
TextRender(GPUDevice *dev,FontSource *);
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
2022-05-13 10:57:05 +08:00
|
|
|
|
bool InitTileFont(int limit);
|
2022-02-16 23:26:50 +08:00
|
|
|
|
bool InitTextLayoutEngine();
|
|
|
|
|
bool InitUBO();
|
2022-10-14 17:52:35 +08:00
|
|
|
|
bool InitMaterial(RenderPass *,DeviceBuffer *);
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2022-02-17 10:48:12 +08:00
|
|
|
|
~TextRender();
|
|
|
|
|
|
2022-10-14 17:52:35 +08:00
|
|
|
|
bool Init(RenderPass *rp,DeviceBuffer *ubo_camera_info,int limit);
|
2022-02-16 23:26:50 +08:00
|
|
|
|
|
2022-02-17 10:48:12 +08:00
|
|
|
|
public:
|
|
|
|
|
|
2022-06-24 17:51:05 +08:00
|
|
|
|
TextPrimitive *CreatePrimitive();
|
2025-01-04 14:14:47 +08:00
|
|
|
|
TextPrimitive *CreatePrimitive(const U16String &str);
|
2022-02-17 20:02:59 +08:00
|
|
|
|
|
2025-01-04 14:14:47 +08:00
|
|
|
|
bool Layout(TextPrimitive *tr,const U16String &str);
|
2022-02-17 20:02:59 +08:00
|
|
|
|
|
2022-06-24 21:17:28 +08:00
|
|
|
|
Renderable *CreateRenderable(TextPrimitive *text_primitive);
|
2022-02-21 17:13:12 +08:00
|
|
|
|
|
2022-06-24 17:51:05 +08:00
|
|
|
|
void Release(TextPrimitive *);
|
2022-02-16 23:26:50 +08:00
|
|
|
|
};//class TextRender
|
|
|
|
|
|
2022-02-17 10:48:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* 创建一个CJK字体源
|
|
|
|
|
* @param cf CJK字体名称
|
|
|
|
|
* @param lf 其它字体名称
|
|
|
|
|
* @param size 字体象素高度
|
|
|
|
|
*/
|
|
|
|
|
FontSource *CreateCJKFontSource(const os_char *cf,const os_char *lf,const uint32_t size);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建一个字体源
|
|
|
|
|
* @param name 字体名称
|
|
|
|
|
* @param size 字体象素高度
|
|
|
|
|
*/
|
2022-02-17 20:02:59 +08:00
|
|
|
|
FontSource *AcquireFontSource(const os_char *name,const uint32_t size);
|
2022-02-17 10:48:12 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2022-05-13 10:57:05 +08:00
|
|
|
|
* 创建一个文本渲染器
|
|
|
|
|
* @param limit 节数限制(-1表示自动)
|
2022-02-17 10:48:12 +08:00
|
|
|
|
*/
|
2022-10-14 17:52:35 +08:00
|
|
|
|
TextRender *CreateTextRender(GPUDevice *,FontSource *,RenderPass *,DeviceBuffer *,int limit);
|
2022-02-16 23:26:50 +08:00
|
|
|
|
}//namespace graph
|
|
|
|
|
}//namespace hgl
|
|
|
|
|
#endif//HGL_GRAPH_TEXT_RENDER_INCLUDE
|