将WorkObject增加bool Init()=0纯虚函数用于负责初始化。
这一分支结束,下一分支基于03_auto_instance范例开发WorldManager用于全局World管理,直接由World提供RenderList/SceneRoot等。
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Billboard
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/WorkManager.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/InlineGeometry.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
@@ -11,6 +11,7 @@
|
||||
#include<hgl/graph/mtl/Material3DCreateConfig.h>
|
||||
#include<hgl/graph/VertexDataManager.h>
|
||||
#include<hgl/graph/VKVertexInputConfig.h>
|
||||
#include<hgl/graph/module/TextureManager.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
@@ -25,12 +26,16 @@ 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 SceneAppFramework
|
||||
class TestApp:public WorkObject
|
||||
{
|
||||
Color4f color;
|
||||
|
||||
private:
|
||||
|
||||
AutoDelete<RenderList> render_list =nullptr;
|
||||
|
||||
SceneNode render_root;
|
||||
|
||||
Material * mtl_plane_grid =nullptr;
|
||||
MaterialInstance * mi_plane_grid =nullptr;
|
||||
Pipeline * pipeline_plane_grid =nullptr;
|
||||
@@ -90,7 +95,9 @@ private:
|
||||
|
||||
bool InitTexture()
|
||||
{
|
||||
texture=db->LoadTexture2D(OS_TEXT("res/image/lena.Tex2D"),true);
|
||||
TextureManager *tex_manager=GetTextureManager();
|
||||
|
||||
texture=tex_manager->LoadTexture2D(OS_TEXT("res/image/lena.Tex2D"),true);
|
||||
if(!texture)return(false);
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
@@ -107,7 +114,7 @@ private:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
Mesh *Add(Primitive *r,MaterialInstance *mi,Pipeline *p)
|
||||
{
|
||||
Mesh *ri=db->CreateMesh(r,mi,p);
|
||||
@@ -126,9 +133,9 @@ private:
|
||||
bool CreateRenderObject()
|
||||
{
|
||||
using namespace inline_geometry;
|
||||
|
||||
|
||||
{
|
||||
PrimitiveCreater pc(device,mi_plane_grid->GetVIL());
|
||||
PrimitiveCreater pc(GetDevice(),mi_plane_grid->GetVIL());
|
||||
|
||||
struct PlaneGridCreateInfo pgci;
|
||||
|
||||
@@ -142,7 +149,7 @@ private:
|
||||
}
|
||||
|
||||
{
|
||||
PrimitiveCreater pc(device,mi_billboard->GetVIL());
|
||||
PrimitiveCreater pc(GetDevice(),mi_billboard->GetVIL());
|
||||
|
||||
pc.Init("Billboard",1);
|
||||
|
||||
@@ -150,6 +157,7 @@ private:
|
||||
return(false);
|
||||
|
||||
ro_billboard=db->CreateMesh(&pc,mi_billboard,pipeline_billboard);
|
||||
|
||||
if(!ro_billboard)
|
||||
return(false);
|
||||
}
|
||||
@@ -175,16 +183,15 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
~TestApp()
|
||||
{
|
||||
SAFE_CLEAR(prim_plane_grid);
|
||||
}
|
||||
|
||||
bool Init(uint w,uint h)
|
||||
bool Init()
|
||||
{
|
||||
if(!SceneAppFramework::Init(w,h))
|
||||
return(false);
|
||||
|
||||
if(!InitPlaneGridMP())
|
||||
return(false);
|
||||
|
||||
@@ -202,9 +209,9 @@ public:
|
||||
|
||||
return(true);
|
||||
}
|
||||
};//class TestApp:public CameraAppFramework
|
||||
};//class TestApp:public WorkObject
|
||||
|
||||
int main(int,char **)
|
||||
int os_main(int,os_char **)
|
||||
{
|
||||
return RunApp<TestApp>(1920,1080);
|
||||
return RunFramework<TestApp>(OS_TEXT("AutoInstance"),1024,1024);
|
||||
}
|
||||
|
@@ -98,15 +98,22 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
render_list=rf->CreateRenderList();
|
||||
render_list=GetRenderFramework()->CreateRenderList();
|
||||
|
||||
if(!render_list)
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)override
|
||||
|
@@ -111,15 +111,22 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
render_list=rf->CreateRenderList();
|
||||
render_list=GetRenderFramework()->CreateRenderList();
|
||||
|
||||
if(!render_list)
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBOAndRenderList())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)override
|
||||
@@ -130,7 +137,7 @@ public:
|
||||
render_list->Render(cmd);
|
||||
cmd->EndRenderPass();
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
};//class TestApp:public WorkObject
|
||||
|
||||
int os_main(int,os_char **)
|
||||
{
|
||||
|
@@ -119,19 +119,23 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
InitVIL();
|
||||
|
||||
if(!InitAutoMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitPipeline())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Tick(double)override{}
|
||||
|
@@ -90,14 +90,18 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
if(!InitMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)override
|
||||
|
@@ -71,16 +71,20 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TestApp(RenderFramework *rf):WorkObject(rf,rf->GetSwapchainRenderTarget())
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
if(!InitAutoMaterial())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitPipeline())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return;
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Tick(double)override{}
|
||||
|
Reference in New Issue
Block a user