fixed OffscreenRender sample.
This commit is contained in:
parent
dda6f3c473
commit
1cf6d48d02
@ -1 +1 @@
|
||||
Subproject commit dfcc07773caec8b971039cf64ea6650ce868bfe6
|
||||
Subproject commit 93761c0a4bcd44eda312ff00122a67d9dfa0e011
|
@ -5,7 +5,7 @@
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint OFFSCREEN_SIZE =16;
|
||||
constexpr uint OFFSCREEN_SIZE =256;
|
||||
constexpr uint SCREEN_WIDTH =1024;
|
||||
constexpr uint SCREEN_HEIGHT =(SCREEN_WIDTH/16)*9;
|
||||
|
||||
@ -15,14 +15,14 @@ class TestApp:public CameraAppFramework
|
||||
{
|
||||
Camera cam;
|
||||
|
||||
MaterialParameters * material_instance =nullptr;
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
GPUBuffer * ubo_camera_info =nullptr;
|
||||
};
|
||||
|
||||
struct:public RenderObject
|
||||
{
|
||||
RenderTarget * render_taget =nullptr;
|
||||
RenderCmdBuffer * command_buffer =nullptr;
|
||||
RenderCmdBuffer * command_buffer =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
RenderableInstance *renderable_instance =nullptr;
|
||||
@ -48,14 +48,15 @@ class TestApp:public CameraAppFramework
|
||||
RenderableInstance *renderable_instance =nullptr;
|
||||
|
||||
SceneNode scene_root;
|
||||
RenderList render_list;
|
||||
RenderList *render_list =nullptr;
|
||||
}cube;
|
||||
|
||||
public:
|
||||
|
||||
~TestApp()
|
||||
{
|
||||
delete os.render_taget;
|
||||
SAFE_CLEAR(cube.render_list);
|
||||
SAFE_CLEAR(os.render_taget);
|
||||
}
|
||||
|
||||
bool InitUBO(RenderObject *ro,const VkExtent2D &extent)
|
||||
@ -70,8 +71,17 @@ public:
|
||||
if(!ro->ubo_camera_info)
|
||||
return(false);
|
||||
|
||||
ro->material_instance->BindUBO("camera",ro->ubo_camera_info);
|
||||
ro->material_instance->Update();
|
||||
{
|
||||
MaterialParameters *mp_global=ro->material_instance->GetMP(DescriptorSetType::Global);
|
||||
|
||||
if(!mp_global)
|
||||
return(false);
|
||||
|
||||
if(!mp_global->BindUBO("g_camera",ro->ubo_camera_info))return(false);
|
||||
|
||||
mp_global->Update();
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -88,7 +98,7 @@ public:
|
||||
os.material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/VertexColor2D"));
|
||||
if(!os.material_instance)return(false);
|
||||
|
||||
os.pipeline=os.render_taget->CreatePipeline(os.material_instance,InlinePipeline::Solid2D,Prim::Fan);
|
||||
os.pipeline=os.render_taget->GetRenderPass()->CreatePipeline(os.material_instance,InlinePipeline::Solid2D,Prim::Fan);
|
||||
if(!os.pipeline)return(false);
|
||||
|
||||
if(!InitUBO(&os,os.render_taget->GetExtent()))
|
||||
@ -97,12 +107,12 @@ public:
|
||||
{
|
||||
CircleCreateInfo cci;
|
||||
|
||||
cci.center.Set(OFFSCREEN_SIZE*0.5,OFFSCREEN_SIZE*0.5);
|
||||
cci.radius.Set(OFFSCREEN_SIZE*0.45,OFFSCREEN_SIZE*0.45);
|
||||
cci.center=Vector2f(OFFSCREEN_SIZE*0.5,OFFSCREEN_SIZE*0.5);
|
||||
cci.radius=Vector2f(OFFSCREEN_SIZE*0.45,OFFSCREEN_SIZE*0.45);
|
||||
cci.field_count=32;
|
||||
cci.has_color=true;
|
||||
cci.center_color.Set(1,1,1,1);
|
||||
cci.border_color.Set(1,1,1,0);
|
||||
cci.center_color=Vector4f(1,1,1,1);
|
||||
cci.border_color=Vector4f(1,1,1,0);
|
||||
|
||||
Renderable *render_obj=CreateRenderableCircle(db,os.material_instance->GetMaterial(),&cci);
|
||||
if(!render_obj)return(false);
|
||||
@ -121,18 +131,27 @@ public:
|
||||
|
||||
bool InitCube()
|
||||
{
|
||||
cube.render_list=new RenderList(device);
|
||||
|
||||
cube.material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/TextureMask3D"));
|
||||
if(!cube.material_instance)return(false);
|
||||
|
||||
cube.pipeline=CreatePipeline(cube.material_instance,InlinePipeline::Solid3D);
|
||||
cube.pipeline=CreatePipeline(cube.material_instance,InlinePipeline::Solid3D,Prim::Triangles);
|
||||
if(!cube.pipeline)return(false);
|
||||
|
||||
cube.sampler=db->CreateSampler();
|
||||
if(!cube.sampler)return(false);
|
||||
|
||||
{
|
||||
MaterialParameters *mp_texture=cube.material_instance->GetMP(DescriptorSetType::Value);
|
||||
|
||||
if(!mp_texture)
|
||||
return(false);
|
||||
|
||||
if(!mp_texture->BindSampler("tex",os.render_taget->GetColorTexture(),cube.sampler))return(false);
|
||||
|
||||
cube.material_instance->BindSampler("tex",os.render_taget->GetColorTexture(),cube.sampler);
|
||||
cube.material_instance->BindUBO("camera",GetCameraInfoBuffer());
|
||||
cube.material_instance->Update();
|
||||
mp_texture->Update();
|
||||
}
|
||||
|
||||
{
|
||||
CubeCreateInfo cci;
|
||||
@ -142,13 +161,13 @@ public:
|
||||
|
||||
cube.renderable_instance=db->CreateRenderableInstance(render_obj,cube.material_instance,cube.pipeline);
|
||||
|
||||
cube.scene_root.Add(cube.renderable_instance);
|
||||
cube.scene_root.CreateSubNode(cube.renderable_instance);
|
||||
}
|
||||
|
||||
camera->pos=Vector4f(5,5,5,1.0);
|
||||
|
||||
cube.scene_root.RefreshMatrix();
|
||||
cube.scene_root.ExpendToList(&cube.render_list);
|
||||
|
||||
camera->pos.Set(5,5,5,1.0);
|
||||
cube.render_list->Expend(GetCameraInfo(),&cube.scene_root);
|
||||
|
||||
return(true);
|
||||
}
|
||||
@ -171,7 +190,10 @@ public:
|
||||
|
||||
void BuildCommandBuffer(uint32 index)
|
||||
{
|
||||
VulkanApplicationFramework::BuildCommandBuffer(index,&cube.render_list);
|
||||
cube.scene_root.RefreshMatrix();
|
||||
cube.render_list->Expend(GetCameraInfo(),&cube.scene_root);
|
||||
|
||||
VulkanApplicationFramework::BuildCommandBuffer(index,cube.render_list);
|
||||
}
|
||||
};//class TestApp:public CameraAppFramework
|
||||
|
||||
|
2
res
2
res
@ -1 +1 @@
|
||||
Subproject commit 583927299e8c123418552ff126b7bb3f7c634dcd
|
||||
Subproject commit 1ce9f858669c9004f1a170bf996a9d36ccca1cb8
|
Loading…
x
Reference in New Issue
Block a user