added few codes, but they can't run.
This commit is contained in:
parent
aca4047e5f
commit
3fbbdb8204
@ -28,11 +28,13 @@ CreateProject(00.triangle first_triangle.cpp)
|
|||||||
CreateProject(01.two_triangle two_triangle.cpp)
|
CreateProject(01.two_triangle two_triangle.cpp)
|
||||||
CreateProject(02.FragCoord FragCoordTest.cpp)
|
CreateProject(02.FragCoord FragCoordTest.cpp)
|
||||||
CreateProject(03.indices_rect indices_rect.cpp)
|
CreateProject(03.indices_rect indices_rect.cpp)
|
||||||
CreateProject(04.TextureFormat TextureFormat.cpp)
|
CreateProject(04.FullScreenRect FullScreenRect.cpp)
|
||||||
CreateProject(05.texture_rect texture_rect.cpp)
|
|
||||||
|
CreateProject(05.TextureFormat TextureFormat.cpp)
|
||||||
|
CreateProject(06.texture_rect texture_rect.cpp)
|
||||||
#CreateProject(05.HQFilterTexture HQFilterTexture.cpp)
|
#CreateProject(05.HQFilterTexture HQFilterTexture.cpp)
|
||||||
#CreateProject(06.Geometry2D Geometry2D.cpp)
|
#CreateProject(06.Geometry2D Geometry2D.cpp)
|
||||||
CreateProject(06.Geometry3D Geometry3D.cpp)
|
CreateProject(07.Geometry3D Geometry3D.cpp)
|
||||||
CreateProject(08.SceneTree SceneTree.cpp)
|
CreateProject(08.SceneTree SceneTree.cpp)
|
||||||
#CreateProject(09.LoadStaticMesh LoadStaticMesh.cpp LoadScene.cpp)
|
#CreateProject(09.LoadStaticMesh LoadStaticMesh.cpp LoadScene.cpp)
|
||||||
CreateProject(10.InlineGeometryScene InlineGeometryScene.cpp)
|
CreateProject(10.InlineGeometryScene InlineGeometryScene.cpp)
|
||||||
@ -55,3 +57,5 @@ CreateProject(16.DeferredRender DeferredRender.cpp)
|
|||||||
CreateProject(17.Cubemap Cubemap.cpp)
|
CreateProject(17.Cubemap Cubemap.cpp)
|
||||||
CreateProject(17.EquirectangularMap EquirectangularMap.cpp)
|
CreateProject(17.EquirectangularMap EquirectangularMap.cpp)
|
||||||
CreateProject(18.RayPicking RayPicking.cpp)
|
CreateProject(18.RayPicking RayPicking.cpp)
|
||||||
|
CreateProject(19.InstanceCube InstanceCube.cpp)
|
||||||
|
CreateProject(20.TerrainSimple TerrainSimple.cpp)
|
0
example/Vulkan/FullScreenRect.cpp
Normal file
0
example/Vulkan/FullScreenRect.cpp
Normal file
4
example/Vulkan/InstanceCube.cpp
Normal file
4
example/Vulkan/InstanceCube.cpp
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// Instance Cube
|
||||||
|
|
||||||
|
// 基本的Instance绘制测试用例
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
// SceneTree
|
// SceneTree
|
||||||
// 用于测试树形排列的场景中,每一级节点对变换矩阵的处理是否正确,以及Instance绘制
|
// 用于测试树形排列的场景中,每一级节点对变换矩阵的处理是否正确
|
||||||
|
|
||||||
#include"VulkanAppFramework.h"
|
#include"VulkanAppFramework.h"
|
||||||
#include<hgl/filesystem/FileSystem.h>
|
#include<hgl/filesystem/FileSystem.h>
|
||||||
@ -56,7 +56,7 @@ private:
|
|||||||
|
|
||||||
bool InitMaterial()
|
bool InitMaterial()
|
||||||
{
|
{
|
||||||
material=db->CreateMaterial(OS_TEXT("res/material/SimplestDirectionLight"));
|
material=db->CreateMaterial(OS_TEXT("res/material/PhongFullyRough"));
|
||||||
if(!material)
|
if(!material)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
@ -95,7 +95,6 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
BindCameraUBO(material_instance);
|
BindCameraUBO(material_instance);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +125,7 @@ private:
|
|||||||
count=(rand()%16)+1;
|
count=(rand()%16)+1;
|
||||||
|
|
||||||
for(uint n=0;n<count;n++)
|
for(uint n=0;n<count;n++)
|
||||||
cur_node->CreateSubNode(translate(0,0,size*n*1.01),ri);
|
cur_node->CreateSubNode(translate(0,0,size*n*1.1),ri);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_root.RefreshMatrix();
|
render_root.RefreshMatrix();
|
||||||
|
168
example/Vulkan/TerrainSimple.cpp
Normal file
168
example/Vulkan/TerrainSimple.cpp
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
// 最简单的地形渲染
|
||||||
|
// 在CPU端生成网格,在vertex中取样高度图
|
||||||
|
|
||||||
|
#include"VulkanAppFramework.h"
|
||||||
|
#include<hgl/filesystem/FileSystem.h>
|
||||||
|
#include<hgl/graph/InlineGeometry.h>
|
||||||
|
#include<hgl/graph/VKRenderResource.h>
|
||||||
|
#include<hgl/graph/RenderList.h>
|
||||||
|
#include<hgl/graph/Camera.h>
|
||||||
|
|
||||||
|
using namespace hgl;
|
||||||
|
using namespace hgl::graph;
|
||||||
|
|
||||||
|
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||||
|
constexpr uint32_t SCREEN_HEIGHT=720;
|
||||||
|
|
||||||
|
struct TerrainCreateInfo
|
||||||
|
{
|
||||||
|
uint Xcount; ///<X轴网格数
|
||||||
|
uint Ycount; ///<Y轴网格数
|
||||||
|
|
||||||
|
struct //翻倍边缘
|
||||||
|
{
|
||||||
|
bool top,left,right,bottom;
|
||||||
|
}dual;
|
||||||
|
};//struct TerrainCreateInfo
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个地形网格
|
||||||
|
*/
|
||||||
|
Renderable *CreateRenderableTerrain(RenderResource *db,const VAB *vab,const TerrainCreateInfo *tci)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestApp:public CameraAppFramework
|
||||||
|
{
|
||||||
|
Color4f color;
|
||||||
|
|
||||||
|
GPUBuffer *ubo_color=nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
SceneNode render_root;
|
||||||
|
RenderList *render_list=nullptr;
|
||||||
|
|
||||||
|
Material * material =nullptr;
|
||||||
|
MaterialInstance * material_instance =nullptr;
|
||||||
|
Pipeline * pipeline =nullptr;
|
||||||
|
|
||||||
|
Renderable * renderable =nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool InitMDP()
|
||||||
|
{
|
||||||
|
material=db->CreateMaterial(OS_TEXT("res/material/VertexColor3D"));
|
||||||
|
if(!material)return(false);
|
||||||
|
|
||||||
|
material_instance=db->CreateMaterialInstance(material);
|
||||||
|
if(!material_instance)return(false);
|
||||||
|
|
||||||
|
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid3D,Prim::TriangleStrip);
|
||||||
|
if(!pipeline)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderableInstance *Add(Renderable *r,const Matrix4f &mat)
|
||||||
|
{
|
||||||
|
RenderableInstance *ri=db->CreateRenderableInstance(r,material_instance,pipeline);
|
||||||
|
|
||||||
|
render_root.CreateSubNode(mat,ri);
|
||||||
|
|
||||||
|
return ri;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateRenderObject()
|
||||||
|
{
|
||||||
|
struct PlaneGridCreateInfo pgci;
|
||||||
|
|
||||||
|
pgci.coord[0]=Vector3f(-100,-100,0);
|
||||||
|
pgci.coord[1]=Vector3f( 100,-100,0);
|
||||||
|
pgci.coord[2]=Vector3f( 100, 100,0);
|
||||||
|
pgci.coord[3]=Vector3f(-100, 100,0);
|
||||||
|
|
||||||
|
pgci.step.x=32;
|
||||||
|
pgci.step.y=32;
|
||||||
|
|
||||||
|
pgci.side_step.x=8;
|
||||||
|
pgci.side_step.y=8;
|
||||||
|
|
||||||
|
pgci.color.Set(0.75,0.75,0.75);
|
||||||
|
pgci.side_color.Set(1,0,0,1);
|
||||||
|
|
||||||
|
const VAB *vab=material_instance->GetVAB();
|
||||||
|
|
||||||
|
renderable=CreateRenderablePlaneGrid(db,vab,&pgci);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InitScene()
|
||||||
|
{
|
||||||
|
RenderableInstance *ri=db->CreateRenderableInstance(renderable,material_instance,pipeline);
|
||||||
|
|
||||||
|
render_root.CreateSubNode(ri);
|
||||||
|
|
||||||
|
camera->pos=Vector3f(200,200,200);
|
||||||
|
camera_control->SetTarget(Vector3f(0,0,0));
|
||||||
|
camera_control->Refresh();
|
||||||
|
|
||||||
|
render_root.RefreshMatrix();
|
||||||
|
render_list->Expend(camera->info,&render_root);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
~TestApp()
|
||||||
|
{
|
||||||
|
SAFE_CLEAR(render_list);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Init()
|
||||||
|
{
|
||||||
|
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
render_list=new RenderList(device);
|
||||||
|
|
||||||
|
if(!InitMDP())
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
CreateRenderObject();
|
||||||
|
|
||||||
|
if(!InitScene())
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BuildCommandBuffer(uint32 index)
|
||||||
|
{
|
||||||
|
render_root.RefreshMatrix();
|
||||||
|
render_list->Expend(GetCameraInfo(),&render_root);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user