2020-08-07 22:34:07 +08:00
|
|
|
#include<hgl/graph/font/TextRenderable.h>
|
2020-08-08 20:12:37 +08:00
|
|
|
#include<hgl/graph/vulkan/VKDevice.h>
|
|
|
|
#include<hgl/graph/vulkan/VKMaterial.h>
|
2020-08-07 22:34:07 +08:00
|
|
|
|
|
|
|
namespace hgl
|
|
|
|
{
|
|
|
|
namespace graph
|
|
|
|
{
|
2020-08-08 20:12:37 +08:00
|
|
|
TextRenderable::TextRenderable(vulkan::Device *dev,vulkan::Material *m,uint mc):vulkan::Renderable(m->GetVertexShaderModule(),mc)
|
2020-08-07 22:34:07 +08:00
|
|
|
{
|
|
|
|
device=dev;
|
2020-08-08 20:12:37 +08:00
|
|
|
mtl=m;
|
|
|
|
|
|
|
|
max_count=0;
|
2020-08-07 22:34:07 +08:00
|
|
|
|
|
|
|
vab_vertex=nullptr;
|
|
|
|
vab_tex_coord=nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextRenderable::~TextRenderable()
|
|
|
|
{
|
|
|
|
SAFE_CLEAR(vab_tex_coord);
|
|
|
|
SAFE_CLEAR(vab_vertex);
|
|
|
|
}
|
|
|
|
|
2020-08-08 20:12:37 +08:00
|
|
|
void TextRenderable::SetCharCount(const uint cc)
|
2020-08-07 22:34:07 +08:00
|
|
|
{
|
2020-08-08 20:12:37 +08:00
|
|
|
this->draw_count=cc;
|
|
|
|
if(cc<=max_count)return;
|
2020-08-07 22:34:07 +08:00
|
|
|
|
2020-08-08 20:12:37 +08:00
|
|
|
max_count=power_to_2(cc);
|
2020-08-07 22:34:07 +08:00
|
|
|
|
|
|
|
{
|
2020-08-08 20:12:37 +08:00
|
|
|
if(vab_vertex)
|
|
|
|
delete vab_vertex;
|
2020-08-07 22:34:07 +08:00
|
|
|
|
|
|
|
vab_vertex =device->CreateVAB(VAF_VEC4,max_count);
|
2020-08-08 20:12:37 +08:00
|
|
|
Set(VAN::Vertex,vab_vertex);
|
2020-08-07 22:34:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2020-08-08 20:12:37 +08:00
|
|
|
if(vab_tex_coord)
|
|
|
|
delete vab_tex_coord;
|
2020-08-07 22:34:07 +08:00
|
|
|
|
|
|
|
vab_tex_coord =device->CreateVAB(VAF_VEC4,max_count);
|
2020-08-08 20:12:37 +08:00
|
|
|
Set(VAN::TexCoord,vab_tex_coord);
|
2020-08-07 22:34:07 +08:00
|
|
|
}
|
|
|
|
}
|
2020-08-08 20:12:37 +08:00
|
|
|
|
|
|
|
bool TextRenderable::WriteVertex (const float *fp){if(!fp)return(false);if(!vab_vertex )return(false);return vab_vertex ->Write(fp,draw_count*4*sizeof(float));}
|
|
|
|
bool TextRenderable::WriteTexCoord (const float *fp){if(!fp)return(false);if(!vab_tex_coord)return(false);return vab_tex_coord ->Write(fp,draw_count*4*sizeof(float));}
|
2020-08-07 22:34:07 +08:00
|
|
|
}//namespace graph
|
|
|
|
}//namespace hgl
|