add TextRenderable

This commit is contained in:
hyzboy 2020-08-07 22:34:07 +08:00
parent d26b59cb1d
commit a6f1657cac
3 changed files with 68 additions and 6 deletions

View File

@ -11,21 +11,23 @@ namespace hgl
*/
class TextRenderable:public vulkan::Renderable
{
vulkan::Renderable * render_obj;
vulkan::Device *device;
vulkan::Renderable *render_obj;
uint32 max_count; ///<缓冲区最大容量
uint32 cur_count; ///<当前容量
vulkan::VertexAttribBuffer *vertex_buffer;
vulkan::VertexAttribBuffer *tex_coord_buffer;
vulkan::VAB *vab_vertex;
vulkan::VAB *vab_tex_coord;
public:
TextRenderable();
TextRenderable(vulkan::Device *,int mc=1024);
virtual ~TextRenderable();
void SetMaxCount(int);
};//class TextRenderable:public vulkan::Renderable
}//namespace graph
}//namespace hgl
#endif//HGL_GRAPH_TEXT_RENDERABLE_INCLUDE

View File

@ -61,6 +61,8 @@ public:
public:
void SetDrawCount (const uint32_t dc){draw_count=dc;} ///<设置当前对象绘制需要多少个顶点
const uint32_t GetDrawCount ()const ///<取得当前对象绘制需要多少个顶点
{
if(indices_buffer)

View File

@ -0,0 +1,58 @@
#include<hgl/graph/font/TextRenderable.h>
namespace hgl
{
namespace graph
{
namespace
{
vulkan::Pipeline *text_pipeline=nullptr;
}//namespace
TextRenderable::TextRenderable(Device *dev,int mc)
{
device=dev;
render_obj=nullptr;
vab_vertex=nullptr;
vab_tex_coord=nullptr;
max_count=mc;
cur_count=mc;
SetMaxCount(mc);
}
TextRenderable::~TextRenderable()
{
SAFE_CLEAR(vab_tex_coord);
SAFE_CLEAR(vab_vertex);
SAFE_CLEAR(render_obj);
}
void TextRenderable::SetMaxCount(int mc)
{
if(mc<max_count)return;
max_count=mc;
if(vab_vertex)
{
delete vab_vertex;
vab_vertex =device->CreateVAB(VAF_VEC4,max_count);
render_obj->Set(VAN::Vertex,vab_vertex);
}
if(vab_tex_coord)
{
delete vab_tex_coord;
vab_tex_coord =device->CreateVAB(VAF_VEC4,max_count);
render_obj->Set(VAN::TexCoord,vab_tex_coord);
}
}
}//namespace graph
}//namespace hgl