增加INLINE几何体测试场景
This commit is contained in:
parent
bc4a19c69b
commit
57a5dede7a
@ -12,3 +12,5 @@ CreateProject(5.SceneTree SceneTree.cpp)
|
|||||||
|
|
||||||
CreateProject(6.LoadModel LoadModel.cpp TGATexture.cpp AssimpLoaderMesh.h AssimpLoaderMesh.cpp)
|
CreateProject(6.LoadModel LoadModel.cpp TGATexture.cpp AssimpLoaderMesh.h AssimpLoaderMesh.cpp)
|
||||||
target_link_libraries(6.LoadModel assimp)
|
target_link_libraries(6.LoadModel assimp)
|
||||||
|
|
||||||
|
CreateProject(7.InlineGeometryScene InlineGeometryScene.cpp)
|
@ -84,8 +84,6 @@ private:
|
|||||||
|
|
||||||
bool InitPipeline()
|
bool InitPipeline()
|
||||||
{
|
{
|
||||||
constexpr os_char PIPELINE_FILENAME[]=OS_TEXT("2DSolid.pipeline");
|
|
||||||
|
|
||||||
{
|
{
|
||||||
vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass(),device->GetExtent());
|
vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass(),device->GetExtent());
|
||||||
pipeline_creater->SetDepthTest(true);
|
pipeline_creater->SetDepthTest(true);
|
||||||
@ -117,7 +115,6 @@ private:
|
|||||||
render_root.ExpendToList(&render_list);
|
render_root.ExpendToList(&render_list);
|
||||||
|
|
||||||
BuildCommandBuffer(&render_list);
|
BuildCommandBuffer(&render_list);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
169
example/Vulkan/InlineGeometryScene.cpp
Normal file
169
example/Vulkan/InlineGeometryScene.cpp
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
// 7.InlineGeometryScene
|
||||||
|
// 全内置几何体场景
|
||||||
|
|
||||||
|
#include"VulkanAppFramework.h"
|
||||||
|
#include<hgl/filesystem/FileSystem.h>
|
||||||
|
#include<hgl/graph/InlineGeometry.h>
|
||||||
|
#include<hgl/graph/SceneDB.h>
|
||||||
|
#include<hgl/graph/RenderableInstance.h>
|
||||||
|
#include<hgl/graph/RenderList.h>
|
||||||
|
|
||||||
|
using namespace hgl;
|
||||||
|
using namespace hgl::graph;
|
||||||
|
|
||||||
|
constexpr uint32_t SCREEN_WIDTH=128;
|
||||||
|
constexpr uint32_t SCREEN_HEIGHT=128;
|
||||||
|
|
||||||
|
class TestApp:public CameraAppFramework
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
SceneNode render_root;
|
||||||
|
RenderList render_list;
|
||||||
|
|
||||||
|
vulkan::Material * material =nullptr;
|
||||||
|
vulkan::DescriptorSets * descriptor_sets =nullptr;
|
||||||
|
|
||||||
|
vulkan::Renderable *ro_plane_grid,
|
||||||
|
*ro_cube,
|
||||||
|
*ro_sphere;
|
||||||
|
|
||||||
|
vulkan::Pipeline *pipeline_line =nullptr,
|
||||||
|
*pipeline_solid =nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool InitMaterial()
|
||||||
|
{
|
||||||
|
material=shader_manage->CreateMaterial(OS_TEXT("OnlyPosition3D.vert.spv"),
|
||||||
|
OS_TEXT("FlatColor.frag.spv"));
|
||||||
|
if(!material)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
descriptor_sets=material->CreateDescriptorSets();
|
||||||
|
|
||||||
|
db->Add(material);
|
||||||
|
db->Add(descriptor_sets);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateRenderObject()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
struct PlaneGridCreateInfo pgci;
|
||||||
|
|
||||||
|
pgci.coord[0].Set(-100,-100,0);
|
||||||
|
pgci.coord[1].Set( 100,-100,0);
|
||||||
|
pgci.coord[2].Set( 100, 100,0);
|
||||||
|
pgci.coord[3].Set(-100, 100,0);
|
||||||
|
|
||||||
|
pgci.step.u=20;
|
||||||
|
pgci.step.v=20;
|
||||||
|
|
||||||
|
pgci.side_step.u=10;
|
||||||
|
pgci.side_step.v=10;
|
||||||
|
|
||||||
|
pgci.color.Set(0.75,0,0,1);
|
||||||
|
pgci.side_color.Set(1,0,0,1);
|
||||||
|
|
||||||
|
ro_plane_grid=CreatePlaneGrid(db,material,&pgci);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
struct CubeCreateInfo cci;
|
||||||
|
ro_cube=CreateCube(db,material,&cci);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ro_sphere=CreateRenderableSphere(db,material,16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InitUBO()
|
||||||
|
{
|
||||||
|
if(!InitCameraUBO(descriptor_sets,material->GetUBO("world")))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
descriptor_sets->Update();
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InitPipeline()
|
||||||
|
{
|
||||||
|
vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass(),device->GetExtent());
|
||||||
|
pipeline_creater->SetDepthTest(true);
|
||||||
|
pipeline_creater->SetDepthWrite(true);
|
||||||
|
pipeline_creater->Set(PRIM_LINES);
|
||||||
|
|
||||||
|
pipeline_line=pipeline_creater->Create();
|
||||||
|
db->Add(pipeline_line);
|
||||||
|
|
||||||
|
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||||
|
pipeline_solid=pipeline_creater->Create();
|
||||||
|
db->Add(pipeline_solid);
|
||||||
|
|
||||||
|
delete pipeline_creater;
|
||||||
|
|
||||||
|
if(!pipeline_line)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
if(!pipeline_solid)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InitScene()
|
||||||
|
{
|
||||||
|
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_plane_grid));
|
||||||
|
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_cube ),translate(-10,0,0)*scale(10,10,10));
|
||||||
|
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_sphere ),translate( 10,0,0)*scale(10,10,10));
|
||||||
|
|
||||||
|
render_root.RefreshMatrix();
|
||||||
|
render_root.ExpendToList(&render_list);
|
||||||
|
|
||||||
|
BuildCommandBuffer(&render_list);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool Init()
|
||||||
|
{
|
||||||
|
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
if(!InitMaterial())
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
CreateRenderObject();
|
||||||
|
|
||||||
|
if(!InitUBO())
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
if(!InitPipeline())
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
if(!InitScene())
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Resize(int,int)override
|
||||||
|
{
|
||||||
|
BuildCommandBuffer(&render_list);
|
||||||
|
}
|
||||||
|
};//class TestApp:public CameraAppFramework
|
||||||
|
|
||||||
|
int main(int,char **)
|
||||||
|
{
|
||||||
|
TestApp app;
|
||||||
|
|
||||||
|
if(!app.Init())
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
while(app.Run());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user