add TextRenderable
This commit is contained in:
parent
d26b59cb1d
commit
a6f1657cac
@ -11,21 +11,23 @@ namespace hgl
|
|||||||
*/
|
*/
|
||||||
class TextRenderable:public vulkan::Renderable
|
class TextRenderable:public vulkan::Renderable
|
||||||
{
|
{
|
||||||
|
vulkan::Device *device;
|
||||||
|
|
||||||
vulkan::Renderable *render_obj;
|
vulkan::Renderable *render_obj;
|
||||||
|
|
||||||
uint32 max_count; ///<缓冲区最大容量
|
uint32 max_count; ///<缓冲区最大容量
|
||||||
uint32 cur_count; ///<当前容量
|
uint32 cur_count; ///<当前容量
|
||||||
|
|
||||||
vulkan::VertexAttribBuffer *vertex_buffer;
|
vulkan::VAB *vab_vertex;
|
||||||
vulkan::VertexAttribBuffer *tex_coord_buffer;
|
vulkan::VAB *vab_tex_coord;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TextRenderable();
|
TextRenderable(vulkan::Device *,int mc=1024);
|
||||||
virtual ~TextRenderable();
|
virtual ~TextRenderable();
|
||||||
|
|
||||||
|
void SetMaxCount(int);
|
||||||
};//class TextRenderable:public vulkan::Renderable
|
};//class TextRenderable:public vulkan::Renderable
|
||||||
|
|
||||||
|
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_GRAPH_TEXT_RENDERABLE_INCLUDE
|
#endif//HGL_GRAPH_TEXT_RENDERABLE_INCLUDE
|
||||||
|
@ -61,6 +61,8 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
void SetDrawCount (const uint32_t dc){draw_count=dc;} ///<设置当前对象绘制需要多少个顶点
|
||||||
|
|
||||||
const uint32_t GetDrawCount ()const ///<取得当前对象绘制需要多少个顶点
|
const uint32_t GetDrawCount ()const ///<取得当前对象绘制需要多少个顶点
|
||||||
{
|
{
|
||||||
if(indices_buffer)
|
if(indices_buffer)
|
||||||
|
58
src/SceneGraph/font/TextRenderable.cpp
Normal file
58
src/SceneGraph/font/TextRenderable.cpp
Normal 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
|
Loading…
x
Reference in New Issue
Block a user