2020-07-11 21:35:14 +08:00
|
|
|
#include<hgl/graph/RenderableCreater.h>
|
|
|
|
#include<hgl/graph/vulkan/VKShaderModule.h>
|
|
|
|
|
|
|
|
namespace hgl
|
|
|
|
{
|
|
|
|
namespace graph
|
|
|
|
{
|
|
|
|
RenderableCreater::RenderableCreater(SceneDB *sdb,vulkan::Material *m)
|
|
|
|
{
|
|
|
|
db =sdb;
|
|
|
|
mtl =m;
|
|
|
|
vsm =mtl->GetVertexShaderModule();
|
|
|
|
|
|
|
|
render_obj =nullptr;
|
|
|
|
vertices_number =0;
|
2020-07-14 14:03:26 +08:00
|
|
|
vabc_vertex =nullptr;
|
2020-07-11 21:35:14 +08:00
|
|
|
ibo =nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RenderableCreater::~RenderableCreater()
|
|
|
|
{
|
|
|
|
SAFE_CLEAR(render_obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RenderableCreater::Init(const uint32 count)
|
|
|
|
{
|
|
|
|
if(count<=0)return(false);
|
|
|
|
|
|
|
|
vertices_number=count;
|
|
|
|
|
|
|
|
render_obj=mtl->CreateRenderable(vertices_number);
|
|
|
|
|
|
|
|
return(true);
|
|
|
|
}
|
|
|
|
|
2020-07-14 14:03:26 +08:00
|
|
|
VertexAttribBufferCreater *RenderableCreater::CreateVAB(const AnsiString &name)
|
2020-07-11 21:35:14 +08:00
|
|
|
{
|
|
|
|
if(!vsm)return(false);
|
|
|
|
|
2020-07-14 14:03:26 +08:00
|
|
|
VertexAttribBufferCreater *vabc;
|
2020-07-11 21:35:14 +08:00
|
|
|
|
2020-07-14 14:03:26 +08:00
|
|
|
if(vabc_maps.Get(name,vabc))
|
|
|
|
return vabc;
|
2020-07-11 21:35:14 +08:00
|
|
|
|
|
|
|
const vulkan::ShaderStage *ss=vsm->GetStageInput(name);
|
|
|
|
|
|
|
|
if(!ss)
|
|
|
|
return(nullptr);
|
|
|
|
|
2020-07-14 14:03:26 +08:00
|
|
|
vabc=hgl::graph::CreateVABCreater(ss->base_type,ss->component,vertices_number);
|
2020-07-11 21:35:14 +08:00
|
|
|
|
2020-07-14 14:03:26 +08:00
|
|
|
vabc_maps.Add(name,vabc);
|
2020-07-11 21:35:14 +08:00
|
|
|
|
2020-07-14 14:03:26 +08:00
|
|
|
return vabc;
|
2020-07-11 21:35:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16 *RenderableCreater::CreateIBO16(uint count,const uint16 *data)
|
|
|
|
{
|
|
|
|
if(!ibo)return(nullptr);
|
|
|
|
|
|
|
|
ibo=db->CreateIBO16(count,data);
|
|
|
|
return (uint16 *)ibo->Map();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 *RenderableCreater::CreateIBO32(uint count,const uint32 *data)
|
|
|
|
{
|
|
|
|
if(!ibo)return(nullptr);
|
|
|
|
|
|
|
|
ibo=db->CreateIBO32(count,data);
|
|
|
|
return (uint32 *)ibo->Map();
|
|
|
|
}
|
|
|
|
|
|
|
|
vulkan::Renderable *RenderableCreater::Finish()
|
|
|
|
{
|
|
|
|
const uint si_count=vsm->GetStageInputCount();
|
|
|
|
|
2020-07-14 14:03:26 +08:00
|
|
|
if(vabc_maps.GetCount()!=si_count)
|
2020-07-11 21:35:14 +08:00
|
|
|
return(nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}//namespace graph
|
|
|
|
}//namespace hgl
|