删除废弃不要的范例
This commit is contained in:
parent
15da48eede
commit
d1a1437e6f
@ -11,10 +11,8 @@
|
||||
set_property(TARGET ${name} PROPERTY FOLDER "ULRE/Example/Basic")
|
||||
endmacro()
|
||||
|
||||
CreateProject(00_RenderFrameworkTest rf_test.cpp)
|
||||
CreateProject(01_draw_triangle_in_NDC draw_triangle_in_NDC.cpp)
|
||||
CreateProject(02_draw_triangle_use_UBO draw_triangle_use_UBO.cpp)
|
||||
CreateProject(03_auto_instance auto_instance.cpp)
|
||||
CreateProject(04_auto_merge_material_instance auto_merge_material_instance.cpp)
|
||||
CreateProject(01_draw_triangle draw_triangle_use_UBO.cpp)
|
||||
CreateProject(02_auto_instance auto_instance.cpp)
|
||||
CreateProject(03_auto_merge_material_instance auto_merge_material_instance.cpp)
|
||||
|
||||
CreateProject(05_Billboard BillboardTest.cpp)
|
||||
CreateProject(04_Billboard BillboardTest.cpp)
|
||||
|
@ -1,158 +0,0 @@
|
||||
// 该范例主要演示使用NDC坐标系直接绘制一个渐变色的三角形
|
||||
|
||||
#include<hgl/WorkManager.h>
|
||||
#include<hgl/math/HalfFloat.h>
|
||||
#include<hgl/graph/VKVertexInputConfig.h>
|
||||
#include<hgl/graph/PrimitiveCreater.h>
|
||||
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||
constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=3;
|
||||
|
||||
constexpr float position_data_float[VERTEX_COUNT*2]=
|
||||
{
|
||||
0.0, -0.5,
|
||||
-0.5, 0.5,
|
||||
0.5, 0.5
|
||||
};
|
||||
|
||||
#define USE_HALF_FLOAT_POSITION
|
||||
|
||||
#ifdef USE_HALF_FLOAT_POSITION
|
||||
constexpr VkFormat PositionFormat=VF_V2HF;
|
||||
|
||||
half_float position_data_hf[VERTEX_COUNT*2];
|
||||
|
||||
#define position_data position_data_hf
|
||||
#else
|
||||
constexpr VkFormat PositionFormat=VF_V2F;
|
||||
|
||||
#define position_data position_data_float
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
|
||||
#define USE_UNORM8_COLOR
|
||||
|
||||
#ifdef USE_UNORM8_COLOR
|
||||
constexpr uint8 color_data[VERTEX_COUNT*4]=
|
||||
{
|
||||
255,0,0,255,
|
||||
0,255,0,255,
|
||||
0,0,255,255
|
||||
};
|
||||
|
||||
constexpr VkFormat ColorFormat=VF_V4UN8;
|
||||
#else
|
||||
constexpr float color_data[VERTEX_COUNT*4]=
|
||||
{
|
||||
1,0,0,1,
|
||||
0,1,0,1,
|
||||
0,0,1,1
|
||||
};
|
||||
|
||||
constexpr VkFormat ColorFormat=VF_V4F;
|
||||
#endif//USE_UNORM8_COLOR
|
||||
|
||||
class TestApp:public WorkObject
|
||||
{
|
||||
private:
|
||||
|
||||
Color4f clear_color=Color4f(0.2f,0.2f,0.2f,1.0f);
|
||||
|
||||
#if defined(USE_HALF_FLOAT_POSITION)||defined(USE_UNORM8_COLOR)
|
||||
VILConfig vil_config;
|
||||
#endif
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
void InitVIL()
|
||||
{
|
||||
#ifdef USE_HALF_FLOAT_POSITION
|
||||
vil_config.Add(VAN::Position,PositionFormat);
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
|
||||
#ifdef USE_UNORM8_COLOR
|
||||
vil_config.Add(VAN::Color,ColorFormat);
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
}
|
||||
|
||||
bool InitAutoMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(PrimitiveType::Triangles,
|
||||
CoordinateSystem2D::NDC,
|
||||
mtl::WithLocalToWorld::Without);
|
||||
|
||||
material_instance=CreateMaterialInstance(mtl::inline_material::VertexColor2D,&cfg,&vil_config);
|
||||
|
||||
return material_instance;
|
||||
}
|
||||
|
||||
bool InitPipeline()
|
||||
{
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
#ifdef USE_HALF_FLOAT_POSITION
|
||||
Float32toFloat16(position_data_hf,position_data_float,VERTEX_COUNT*2);
|
||||
#endif//USE_HALF_FLOAT_POSITION
|
||||
|
||||
render_obj=CreateMesh("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
{
|
||||
{VAN::Position,PositionFormat,position_data},
|
||||
{VAN::Color, ColorFormat, color_data}
|
||||
});
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
InitVIL();
|
||||
|
||||
if(!InitAutoMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitPipeline())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Tick(double)override{}
|
||||
|
||||
由于新架构全部要走SceneNode,所以此范例已不可用
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)
|
||||
{
|
||||
cmd->SetClearColor(0,clear_color);
|
||||
|
||||
cmd->BeginRenderPass();
|
||||
cmd->Render(render_obj);
|
||||
cmd->EndRenderPass();
|
||||
}
|
||||
};//class TestApp:public WorkObject
|
||||
|
||||
int os_main(int,os_char **)
|
||||
{
|
||||
return RunFramework<TestApp>(OS_TEXT("Draw triangle in NDC space"));
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
#include<hgl/WorkManager.h>
|
||||
#include<hgl/graph/VKVertexInputConfig.h>
|
||||
#include<hgl/graph/VKRenderResource.h>
|
||||
#include<hgl/graph/mtl/Material2DCreateConfig.h>
|
||||
#include<hgl/graph/VKMaterialInstance.h>
|
||||
#include<hgl/graph/mtl/MaterialLibrary.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||
constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=3;
|
||||
|
||||
constexpr float position_data[VERTEX_COUNT*2]=
|
||||
{
|
||||
0.0, -0.5,
|
||||
-0.5, 0.5,
|
||||
0.5, 0.5
|
||||
};
|
||||
|
||||
constexpr float color_data[VERTEX_COUNT*4]=
|
||||
{
|
||||
1,0,0,1,
|
||||
0,1,0,1,
|
||||
0,0,1,1
|
||||
};
|
||||
|
||||
class TestApp:public WorkObject
|
||||
{
|
||||
private:
|
||||
|
||||
Color4f clear_color =Color4f(0.2f,0.2f,0.2f,1.0f);
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Mesh * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitAutoMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(PrimitiveType::Triangles,
|
||||
CoordinateSystem2D::NDC,
|
||||
mtl::WithLocalToWorld::Without);
|
||||
|
||||
material_instance=CreateMaterialInstance(mtl::inline_material::VertexColor2D,&cfg); //这个是使用名称创建
|
||||
|
||||
return material_instance;
|
||||
}
|
||||
|
||||
bool InitPipeline()
|
||||
{
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
render_obj=CreateMesh("Triangle",VERTEX_COUNT,material_instance,pipeline,
|
||||
{
|
||||
{VAN::Position,VF_V2F,position_data},
|
||||
{VAN::Color, VF_V4F,color_data}
|
||||
});
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
using WorkObject::WorkObject;
|
||||
|
||||
bool Init() override
|
||||
{
|
||||
if(!InitAutoMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitPipeline())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
由于新架构全部要走SceneNode,所以此范例已不可用
|
||||
|
||||
void Tick(double)override{}
|
||||
|
||||
void Render(double delta_time,graph::RenderCmdBuffer *cmd)
|
||||
{
|
||||
cmd->SetClearColor(0,clear_color);
|
||||
|
||||
cmd->BeginRenderPass();
|
||||
cmd->Render(render_obj);
|
||||
cmd->EndRenderPass();
|
||||
}
|
||||
};//class TestApp:public WorkObject
|
||||
|
||||
int os_main(int,os_char **)
|
||||
{
|
||||
return RunFramework<TestApp>(OS_TEXT("RenderFramework Test"));
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user