removed old examples.
This commit is contained in:
parent
d456c2bf92
commit
a87a35b5f8
@ -16,9 +16,6 @@ CreateProject("Basic" 03_auto_instance third_triangle.cpp)
|
||||
CreateProject("Basic" 04_auto_merge_material_instance fourth_triangle.cpp)
|
||||
|
||||
#CreateProject("Basic" FragCoord FragCoordTest.cpp)
|
||||
#CreateProject("Basic" indices_rect indices_rect.cpp)
|
||||
#CreateProject("Basic" FullScreenTriangle FullScreenTriangle.cpp)
|
||||
#CreateProject("Basic" InstanceTriangle InstanceTriangle.cpp)
|
||||
|
||||
CreateProject("Texture" 05_texture_format TextureFormat.cpp)
|
||||
CreateProject("Texture" 06_texture_quad texture_quad.cpp)
|
||||
@ -26,7 +23,6 @@ CreateProject("Texture" 07_texture_rect texture_rect.cpp)
|
||||
#CreateProject("Texture" HQFilterTexture HQFilterTexture.cpp)
|
||||
#CreateProject(06.Geometry2D Geometry2D.cpp)
|
||||
|
||||
#CreateProject("Geometry2D" RectanglePrimitive RectanglePrimitive.cpp)
|
||||
#CreateProject("Tile" DrawTile DrawTile.cpp)
|
||||
#CreateProject("Tile" DrawText DrawText.cpp)
|
||||
|
||||
|
@ -1,87 +0,0 @@
|
||||
// 全屏三角形
|
||||
// 该范例用于演示使用索引画一个覆盖全屏的三角形,但是不传递任何顶点信息,顶点坐标在vertex shader中通过gl_VertexIndex计算出来。
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/math/Math.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=256;
|
||||
constexpr uint32_t SCREEN_HEIGHT=256;
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
{
|
||||
private:
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable *renderable =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/fullscreen"));
|
||||
if(!material_instance)return(false);
|
||||
|
||||
BindCameraUBO(material_instance);
|
||||
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
auto primitive=db->CreatePrimitive(3);
|
||||
if(!primitive)return(false);
|
||||
|
||||
renderable=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if(!VulkanApplicationFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
BuildCommandBuffer(renderable);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
{
|
||||
VulkanApplicationFramework::Resize(w,h);
|
||||
|
||||
BuildCommandBuffer(renderable);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(!CheckStrideBytesByFormat())
|
||||
return 0xff;
|
||||
#endif//
|
||||
|
||||
TestApp app;
|
||||
|
||||
if(!app.Init())
|
||||
return(-1);
|
||||
|
||||
while(app.Run());
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
// Instance Triangle
|
||||
|
||||
// 基本的Instance绘制测试用例,不使用场景树
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/SceneInfo.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_SIZE=512;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=3;
|
||||
|
||||
constexpr float position_data[VERTEX_COUNT][2]=
|
||||
{
|
||||
{0,0},
|
||||
{0.25,-0.75},
|
||||
{0,-1}
|
||||
};
|
||||
|
||||
constexpr float color_data[VERTEX_COUNT][4]=
|
||||
{ {1,0,0,1},
|
||||
{0,1,0,1},
|
||||
{0,0,1,1}
|
||||
};
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
{
|
||||
private:
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/VertexColor2DNDC"));
|
||||
|
||||
if(!material_instance)
|
||||
return(false);
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
Primitive *primitive=db->CreatePrimitive(VERTEX_COUNT);
|
||||
if(!primitive)return(false);
|
||||
|
||||
if(!primitive->Set(VAN::Position, db->CreateVBO(VF_V2F,VERTEX_COUNT,position_data )))return(false);
|
||||
if(!primitive->Set(VAN::Color, db->CreateVBO(VF_V4F,VERTEX_COUNT,color_data )))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
return(true);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if(!VulkanApplicationFramework::Init(SCREEN_SIZE,SCREEN_SIZE))
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
if(!BuildCommandBuffer(render_obj))
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
{
|
||||
VulkanApplicationFramework::Resize(w,h);
|
||||
|
||||
BuildCommandBuffer(render_obj);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
{
|
||||
TestApp app;
|
||||
|
||||
if(!app.Init())
|
||||
return(-1);
|
||||
|
||||
while(app.Run());
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
// 2.RectanglePrimivate
|
||||
// 该示例是texture_rect的进化,演示使用GeometryShader画矩形
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/graph/VKTexture.h>
|
||||
#include<hgl/graph/VKSampler.h>
|
||||
#include<hgl/math/Math.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
VK_NAMESPACE_BEGIN
|
||||
Texture2D *CreateTexture2DFromFile(GPUDevice *device,const OSString &filename);
|
||||
VK_NAMESPACE_END
|
||||
|
||||
constexpr uint32_t SCREEN_SIZE=512;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=1;
|
||||
|
||||
constexpr float BORDER=0.1f;
|
||||
|
||||
constexpr float position_data[4]=
|
||||
{
|
||||
SCREEN_SIZE*BORDER, SCREEN_SIZE*BORDER,
|
||||
SCREEN_SIZE*(1.0-BORDER), SCREEN_SIZE*(1.0-BORDER)
|
||||
};
|
||||
|
||||
constexpr float tex_coord_data[4]=
|
||||
{
|
||||
0,0,1,1
|
||||
};
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
{
|
||||
private:
|
||||
|
||||
Texture2D * texture =nullptr;
|
||||
Sampler * sampler =nullptr;
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Primitive * primitive =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/TextureRect2D"));
|
||||
if(!material_instance)return(false);
|
||||
|
||||
BindCameraUBO(material_instance);
|
||||
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::SolidRectangles);
|
||||
if(!pipeline)return(false);
|
||||
|
||||
texture=db->LoadTexture2D(OS_TEXT("res/image/lena.Tex2D"));
|
||||
if(!texture)return(false);
|
||||
|
||||
sampler=db->CreateSampler();
|
||||
|
||||
if(!material_instance->BindImageSampler(DescriptorSetType::Value,"tex",texture,sampler))return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
primitive=db->CreatePrimitive(VERTEX_COUNT);
|
||||
|
||||
if(!primitive)return(false);
|
||||
|
||||
primitive->Set(VAN::Position,db->CreateVBO(VF_V4F,VERTEX_COUNT,position_data));
|
||||
primitive->Set(VAN::TexCoord,db->CreateVBO(VF_V4F,VERTEX_COUNT,tex_coord_data));
|
||||
|
||||
render_obj=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if(!VulkanApplicationFramework::Init(SCREEN_SIZE,SCREEN_SIZE))
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
BuildCommandBuffer(render_obj);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
{
|
||||
VulkanApplicationFramework::Resize(w,h);
|
||||
|
||||
BuildCommandBuffer(render_obj);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
{
|
||||
TestApp app;
|
||||
|
||||
if(!app.Init())
|
||||
return(-1);
|
||||
|
||||
while(app.Run());
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
// indices_rect
|
||||
// 该示例演示使用索引数据画一个矩形,并使用了颜色材质
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/math/Math.h>
|
||||
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=256;
|
||||
constexpr uint32_t SCREEN_HEIGHT=256;
|
||||
|
||||
constexpr uint32_t VERTEX_COUNT=4;
|
||||
|
||||
static Vector4f color(1,1,1,1);
|
||||
|
||||
constexpr float position_data[VERTEX_COUNT][2]=
|
||||
{
|
||||
{0,0},
|
||||
{SCREEN_WIDTH,0},
|
||||
{0,SCREEN_HEIGHT},
|
||||
{SCREEN_WIDTH,SCREEN_HEIGHT}
|
||||
};
|
||||
|
||||
constexpr uint32_t INDEX_COUNT=6;
|
||||
|
||||
constexpr uint16 index_data[INDEX_COUNT]=
|
||||
{
|
||||
0,1,3,
|
||||
0,3,2
|
||||
};
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
{
|
||||
private:
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable *renderable =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material_instance=db->CreateMaterialInstance(OS_TEXT("res/material/FragColor"));
|
||||
if(!material_instance)return(false);
|
||||
|
||||
BindCameraUBO(material_instance);
|
||||
|
||||
// pipeline=db->CreatePipeline(material_instance,sc_render_target,OS_TEXT("res/pipeline/solid2d"));
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Triangles); //等同上一行,为Framework重载,默认使用swapchain的render target
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
auto primitive=db->CreatePrimitive(VERTEX_COUNT);
|
||||
if(!primitive)return(false);
|
||||
|
||||
if(!primitive->Set(VAN::Position,db->CreateVBO(VF_V2F,VERTEX_COUNT,position_data)))return(false);
|
||||
if(!primitive->Set(db->CreateIBO16(INDEX_COUNT,index_data)))return(false);
|
||||
|
||||
renderable=db->CreateRenderable(primitive,material_instance,pipeline);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if(!VulkanApplicationFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||
return(false);
|
||||
|
||||
if(!InitMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
BuildCommandBuffer(renderable);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
{
|
||||
VulkanApplicationFramework::Resize(w,h);
|
||||
|
||||
BuildCommandBuffer(renderable);
|
||||
}
|
||||
};//class TestApp:public VulkanApplicationFramework
|
||||
|
||||
int main(int,char **)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
if(!CheckStrideBytesByFormat())
|
||||
return 0xff;
|
||||
#endif//
|
||||
|
||||
TestApp app;
|
||||
|
||||
if(!app.Init())
|
||||
return(-1);
|
||||
|
||||
while(app.Run());
|
||||
|
||||
return 0;
|
||||
}
|
@ -23,8 +23,8 @@ constexpr float position_data[4]=
|
||||
{
|
||||
0, //left
|
||||
0, //top
|
||||
1, //right
|
||||
1 //bottom
|
||||
1, //right
|
||||
1 //bottom
|
||||
};
|
||||
|
||||
constexpr float tex_coord_data[4]=
|
||||
|
Loading…
x
Reference in New Issue
Block a user