2024-07-26 03:27:32 +08:00
|
|
|
|
#include<hgl/io/LoadString.h>
|
2022-02-16 23:26:50 +08:00
|
|
|
|
#include<hgl/graph/font/TextRender.h>
|
2020-07-08 21:56:39 +08:00
|
|
|
|
#include"VulkanAppFramework.h"
|
2020-06-28 22:16:07 +08:00
|
|
|
|
|
|
|
|
|
using namespace hgl;
|
2020-07-08 21:56:39 +08:00
|
|
|
|
using namespace hgl::graph;
|
|
|
|
|
|
2020-07-31 18:01:28 +08:00
|
|
|
|
constexpr uint32_t SCREEN_WIDTH =1280;
|
2020-08-04 18:28:34 +08:00
|
|
|
|
constexpr uint32_t SCREEN_HEIGHT=SCREEN_WIDTH/16*9;
|
2020-07-08 21:56:39 +08:00
|
|
|
|
|
2024-07-26 03:27:32 +08:00
|
|
|
|
class TestApp:public CameraAppFramework
|
2022-02-16 18:19:41 +08:00
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
TextRender * text_render =nullptr;
|
|
|
|
|
|
2022-06-24 21:17:28 +08:00
|
|
|
|
TextPrimitive * text_primitive =nullptr;
|
2025-05-18 02:03:16 +08:00
|
|
|
|
Mesh * render_obj =nullptr;
|
2022-02-16 18:19:41 +08:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
~TestApp()
|
|
|
|
|
{
|
|
|
|
|
SAFE_CLEAR(text_render)
|
2020-08-08 22:54:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-16 18:19:41 +08:00
|
|
|
|
private:
|
|
|
|
|
|
2020-08-08 22:54:09 +08:00
|
|
|
|
bool InitTextRenderable()
|
|
|
|
|
{
|
2025-01-15 02:42:04 +08:00
|
|
|
|
U16String str;
|
2022-05-13 10:57:05 +08:00
|
|
|
|
|
|
|
|
|
LoadStringFromTextFile(str,OS_TEXT("res/text/DaoDeBible.txt"));
|
|
|
|
|
|
|
|
|
|
if(str.IsEmpty())return(false);
|
2020-08-08 22:54:09 +08:00
|
|
|
|
|
2022-02-17 20:02:59 +08:00
|
|
|
|
FontSource *fs=AcquireFontSource(OS_TEXT("微软雅黑"),12);
|
2022-02-17 11:02:55 +08:00
|
|
|
|
|
2022-05-13 10:57:05 +08:00
|
|
|
|
text_render=CreateTextRender(device,fs,device_render_pass,ubo_camera_info,str.Length());
|
2022-02-17 11:02:55 +08:00
|
|
|
|
if(!text_render)
|
|
|
|
|
return(false);
|
|
|
|
|
|
2022-06-24 21:17:28 +08:00
|
|
|
|
text_primitive=text_render->CreatePrimitive(str);
|
|
|
|
|
if(!text_primitive)
|
2022-02-16 18:19:41 +08:00
|
|
|
|
return(false);
|
2020-09-28 11:16:45 +08:00
|
|
|
|
|
2022-06-24 21:17:28 +08:00
|
|
|
|
render_obj=text_render->CreateRenderable(text_primitive);
|
|
|
|
|
if(!render_obj)
|
2022-02-16 18:19:41 +08:00
|
|
|
|
return(false);
|
2020-08-08 22:54:09 +08:00
|
|
|
|
|
2022-02-16 18:19:41 +08:00
|
|
|
|
return(true);
|
2020-08-03 21:22:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-08 21:56:39 +08:00
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
bool Init()
|
|
|
|
|
{
|
2020-07-31 18:01:28 +08:00
|
|
|
|
if(!VulkanApplicationFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
|
|
|
|
return(false);
|
|
|
|
|
|
2020-08-03 21:22:02 +08:00
|
|
|
|
if(!InitTextRenderable())
|
|
|
|
|
return(false);
|
2022-02-16 18:19:41 +08:00
|
|
|
|
|
2024-07-26 03:27:32 +08:00
|
|
|
|
VulkanApplicationFramework::BuildCommandBuffer(render_obj);
|
2020-07-08 21:56:39 +08:00
|
|
|
|
|
|
|
|
|
return(true);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-26 03:27:32 +08:00
|
|
|
|
void Resize(uint w,uint h)override
|
2020-07-08 21:56:39 +08:00
|
|
|
|
{
|
2022-03-09 20:55:09 +08:00
|
|
|
|
VulkanApplicationFramework::Resize(w,h);
|
2020-09-28 11:16:45 +08:00
|
|
|
|
|
2024-07-26 03:27:32 +08:00
|
|
|
|
VulkanApplicationFramework::BuildCommandBuffer(render_obj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildCommandBuffer(uint32_t index)
|
|
|
|
|
{
|
|
|
|
|
VulkanApplicationFramework::BuildCommandBuffer(index,render_obj);
|
2020-07-08 21:56:39 +08:00
|
|
|
|
}
|
|
|
|
|
};//class TestApp:public VulkanApplicationFramework
|
|
|
|
|
|
2020-07-31 18:01:28 +08:00
|
|
|
|
int main(int,char **)
|
2020-07-08 21:56:39 +08:00
|
|
|
|
{
|
|
|
|
|
TestApp app;
|
2020-06-28 22:16:07 +08:00
|
|
|
|
|
2020-07-08 21:56:39 +08:00
|
|
|
|
if(!app.Init())
|
|
|
|
|
return(-1);
|
2020-06-28 22:16:07 +08:00
|
|
|
|
|
2020-07-08 21:56:39 +08:00
|
|
|
|
while(app.Run());
|
2020-06-28 22:16:07 +08:00
|
|
|
|
|
2020-07-08 21:56:39 +08:00
|
|
|
|
return 0;
|
|
|
|
|
}
|