added SceneAppFramework, global_descriptor.Bind used auto-mode.
This commit is contained in:
parent
cfed14d746
commit
6f58475abd
@ -1 +1 @@
|
||||
Subproject commit 88f064043f1402ced42c91ecb34f26a2b229a134
|
||||
Subproject commit b5f314d2c3ec63c8f012174f22d84aaee474ce1d
|
@ -61,8 +61,6 @@ private:
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
db->global_descriptor.Bind(material_instance->GetMaterial());
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
|
@ -12,16 +12,10 @@
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||
constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
|
||||
class TestApp:public CameraAppFramework
|
||||
class TestApp:public SceneAppFramework
|
||||
{
|
||||
private:
|
||||
|
||||
SceneNode render_root;
|
||||
RenderList * render_list =nullptr;
|
||||
|
||||
Material * material =nullptr;
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
@ -42,8 +36,6 @@ private:
|
||||
material=db->CreateMaterial(mci);
|
||||
if(!material)return(false);
|
||||
|
||||
db->global_descriptor.Bind(material);
|
||||
|
||||
Color4f GridColor;
|
||||
COLOR ce=COLOR::BlenderAxisRed;
|
||||
|
||||
@ -113,18 +105,11 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
~TestApp()
|
||||
bool Init(uint width,uint height) override
|
||||
{
|
||||
SAFE_CLEAR(render_list);
|
||||
}
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||
if(!SceneAppFramework::Init(width,height))
|
||||
return(false);
|
||||
|
||||
render_list=new RenderList(device);
|
||||
|
||||
if(!InitMDP())
|
||||
return(false);
|
||||
|
||||
@ -136,28 +121,9 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void BuildCommandBuffer(uint32 index)
|
||||
{
|
||||
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
{
|
||||
CameraAppFramework::Resize(w,h);
|
||||
|
||||
VulkanApplicationFramework::BuildCommandBuffer(render_list);
|
||||
}
|
||||
};//class TestApp:public CameraAppFramework
|
||||
|
||||
int main(int,char **)
|
||||
{
|
||||
TestApp app;
|
||||
|
||||
if(!app.Init())
|
||||
return(-1);
|
||||
|
||||
while(app.Run());
|
||||
|
||||
return 0;
|
||||
return RunApp<TestApp>(1280,720);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ static float lumiance_data[2]={1,1};
|
||||
static Color4f white_color(1,1,1,1);
|
||||
static Color4f yellow_color(1,1,0,1);
|
||||
|
||||
class TestApp:public CameraAppFramework
|
||||
class TestApp:public SceneAppFramework
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
@ -35,9 +35,6 @@ class TestApp:public CameraAppFramework
|
||||
|
||||
private:
|
||||
|
||||
SceneNode render_root;
|
||||
RenderList * render_list =nullptr;
|
||||
|
||||
Material * material =nullptr;
|
||||
MaterialInstance * mi_plane_grid =nullptr;
|
||||
MaterialInstance * mi_line =nullptr;
|
||||
@ -66,8 +63,6 @@ private:
|
||||
material=db->CreateMaterial(mci);
|
||||
if(!material)return(false);
|
||||
|
||||
db->global_descriptor.Bind(material);
|
||||
|
||||
mi_plane_grid=db->CreateMaterialInstance(material);
|
||||
if(!mi_plane_grid)return(false);
|
||||
mi_plane_grid->WriteMIData(white_color);
|
||||
|
@ -540,3 +540,54 @@ public:
|
||||
cmc->Update();
|
||||
}
|
||||
};//class CameraAppFramework
|
||||
|
||||
class SceneAppFramework:public CameraAppFramework
|
||||
{
|
||||
protected:
|
||||
|
||||
SceneNode render_root;
|
||||
RenderList * render_list =nullptr;
|
||||
|
||||
public:
|
||||
|
||||
SceneAppFramework()=default;
|
||||
|
||||
virtual ~SceneAppFramework()
|
||||
{
|
||||
SAFE_CLEAR(render_list);
|
||||
}
|
||||
|
||||
virtual bool Init(uint width,uint height)
|
||||
{
|
||||
if(!CameraAppFramework::Init(width,height))
|
||||
return(false);
|
||||
|
||||
render_list=new RenderList(device);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
virtual void BuildCommandBuffer(uint32 index) override
|
||||
{
|
||||
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
|
||||
}
|
||||
|
||||
virtual void Resize(int w,int h) override
|
||||
{
|
||||
CameraAppFramework::Resize(w,h);
|
||||
|
||||
VulkanApplicationFramework::BuildCommandBuffer(render_list);
|
||||
}
|
||||
};//class SceneAppFramework:public CameraAppFramework
|
||||
|
||||
template<typename T> int RunApp(uint w,uint h)
|
||||
{
|
||||
T app;
|
||||
|
||||
if(!app.Init(w,h))
|
||||
return(-1);
|
||||
|
||||
while(app.Run());
|
||||
|
||||
return 0;
|
||||
}
|
@ -55,7 +55,7 @@ class RenderResource
|
||||
public:
|
||||
|
||||
//注:并非一定要走这里,这里只是提供一个注册和自动绑定的机制
|
||||
DescriptorBinding global_descriptor; ///<全局属性描述符绑定管理
|
||||
DescriptorBinding global_descriptor; ///<全局属性描述符绑定管理
|
||||
|
||||
public:
|
||||
|
||||
|
@ -155,6 +155,8 @@ Material *RenderResource::CreateMaterial(const mtl::MaterialCreateInfo *mci)
|
||||
|
||||
Add(mtl);
|
||||
|
||||
global_descriptor.Bind(mtl);
|
||||
|
||||
material_by_name.Add(mtl_name,mtl);
|
||||
return mtl.Finish();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user