Added WorkObject::CreateRenderable(...)
This commit is contained in:
parent
3c2f7ad705
commit
a03770fd00
@ -2,7 +2,6 @@
|
||||
#include<hgl/WorkManager.h>
|
||||
#include<hgl/math/HalfFloat.h>
|
||||
#include<hgl/graph/VKVertexInputConfig.h>
|
||||
#include<hgl/graph/PrimitiveCreater.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
@ -28,6 +27,7 @@ constexpr float color_data[VERTEX_COUNT*4]=
|
||||
0,0,1,1
|
||||
};
|
||||
|
||||
|
||||
class TestApp:public WorkObject
|
||||
{
|
||||
private:
|
||||
@ -65,14 +65,11 @@ private:
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
PrimitiveCreater rpc(GetDevice(),material_instance->GetVIL());
|
||||
|
||||
rpc.Init("Triangle",VERTEX_COUNT);
|
||||
|
||||
if(!rpc.WriteVAB(VAN::Position, VF_V2F, position_data))return(false);
|
||||
if(!rpc.WriteVAB(VAN::Color, VF_V4F, color_data ))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(&rpc,material_instance,pipeline);
|
||||
render_obj=CreateRenderable("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
{
|
||||
{VAN::Position,VF_V2F,position_data},
|
||||
{VAN::Color, VF_V4F,color_data}
|
||||
});
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
@ -81,11 +78,6 @@ public:
|
||||
TestApp(RenderFramework *rf):WorkObject()
|
||||
{
|
||||
Join(rf,rf->GetSwapchainRenderTarget());
|
||||
}
|
||||
|
||||
void Join(RenderFramework *rf,IRenderTarget *rt)
|
||||
{
|
||||
WorkObject::Join(rf,rt);
|
||||
|
||||
if(!InitAutoMaterial())
|
||||
return;
|
||||
@ -97,8 +89,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
void Tick(double)override
|
||||
{}
|
||||
void Tick(double)override{}
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/type/object/TickObject.h>
|
||||
#include<hgl/graph/RenderFramework.h>
|
||||
#include<hgl/Time.h>
|
||||
//#include<iostream>
|
||||
|
||||
@ -60,6 +60,12 @@ namespace hgl
|
||||
{
|
||||
return render_pass->CreatePipeline(args...);
|
||||
}
|
||||
|
||||
graph::Renderable *CreateRenderable( const AnsiString &name,
|
||||
uint32_t vertices_count,
|
||||
graph::MaterialInstance *mi,
|
||||
graph::Pipeline *pipeline,
|
||||
const std::initializer_list<graph::VertexAttribDataPtr> &vad_list);
|
||||
};//class WorkObject
|
||||
|
||||
/**
|
||||
|
@ -25,6 +25,13 @@ constexpr size_t VK_DESCRIPTOR_TYPE_END_RANGE=VK_DESCRIPTOR_TYPE_INPUT_ATTACHMEN
|
||||
constexpr size_t VK_DESCRIPTOR_TYPE_RANGE_SIZE=VK_DESCRIPTOR_TYPE_END_RANGE-VK_DESCRIPTOR_TYPE_BEGIN_RANGE+1;
|
||||
#endif//VK_DESCRIPTOR_TYPE_RANGE_SIZE
|
||||
|
||||
struct VertexAttribDataPtr
|
||||
{
|
||||
const char * name;
|
||||
const VkFormat format;
|
||||
const void * data;
|
||||
};
|
||||
|
||||
using BindingMap =Map<AnsiString,int>;
|
||||
using BindingMapArray =BindingMap[VK_DESCRIPTOR_TYPE_RANGE_SIZE];
|
||||
|
||||
|
@ -3,7 +3,10 @@
|
||||
#include<hgl/graph/module/SwapchainModule.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/VKRenderTarget.h>
|
||||
#include<hgl/type/object/TickObject.h>
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
#include<hgl/graph/PrimitiveCreater.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/PrimitiveCreater.h>
|
||||
#include<hgl/Time.h>
|
||||
//#include<iostream>
|
||||
|
||||
@ -51,4 +54,29 @@ namespace hgl
|
||||
|
||||
//std::cout<<"WorkObject::Render End"<<std::endl;
|
||||
}
|
||||
|
||||
graph::Renderable *WorkObject::CreateRenderable( const AnsiString &name,
|
||||
uint32_t vertices_count,
|
||||
graph::MaterialInstance *mi,
|
||||
graph::Pipeline *pipeline,
|
||||
const std::initializer_list<graph::VertexAttribDataPtr> &vad_list)
|
||||
{
|
||||
auto *pc=new graph::PrimitiveCreater(GetDevice(),mi->GetVIL());
|
||||
|
||||
pc->Init(name,vertices_count);
|
||||
|
||||
for(const auto &vad:vad_list)
|
||||
{
|
||||
if(!pc->WriteVAB(vad.name,vad.format,vad.data))
|
||||
{
|
||||
delete pc;
|
||||
return(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
auto *result=db->CreateRenderable(pc,mi,pipeline);
|
||||
|
||||
delete pc;
|
||||
return result;
|
||||
}
|
||||
}//namespcae hgl
|
||||
|
Loading…
x
Reference in New Issue
Block a user