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