preparing LerpLine example.
This commit is contained in:
parent
412ed6f3f2
commit
28fcdb6216
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit 1a61053e33ba573fb80a3775200e3db83dafd6bd
|
||||
Subproject commit 9fdefa18fa2d7ce86ac48668110ed75c65d226ef
|
2
CMUtil
2
CMUtil
@ -1 +1 @@
|
||||
Subproject commit 259f0ef40c46c7cb6fadc4f9402e100c352df9d9
|
||||
Subproject commit 1e121c1b3ebfbc46ce310335e2fb3b4c8ecdf8e0
|
@ -10,4 +10,6 @@
|
||||
endmacro()
|
||||
|
||||
CreateProject(00.line line.cpp)
|
||||
CreateProject(01.roundbox roundbox.cpp)
|
||||
CreateProject(01.LerpLine LerpLine.cpp)
|
||||
|
||||
CreateProject(02.roundbox roundbox.cpp)
|
||||
|
121
example/2dVector/LerpLine.cpp
Normal file
121
example/2dVector/LerpLine.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
// 主要用于测试几种2D插值算法
|
||||
|
||||
#include"VulkanAppFramework.h"
|
||||
#include<hgl/math/Math.h>
|
||||
#include<hgl/math/HalfFloat.h>
|
||||
#include<hgl/filesystem/FileSystem.h>
|
||||
#include<hgl/graph/SceneInfo.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[VERTEX_COUNT*2]=
|
||||
{
|
||||
-1.0, 0.0,
|
||||
1.0, 0.0,
|
||||
};
|
||||
|
||||
constexpr VkFormat PositionFormat=VF_V2F;
|
||||
|
||||
constexpr float color_data[VERTEX_COUNT*4]=
|
||||
{ 1,0,0,1,
|
||||
0,1,0,1,
|
||||
0,0,1,1
|
||||
};
|
||||
|
||||
constexpr VkFormat ColorFormat=VF_V4F;
|
||||
|
||||
class TestApp:public VulkanApplicationFramework
|
||||
{
|
||||
private:
|
||||
|
||||
MaterialInstance * material_instance =nullptr;
|
||||
Renderable * render_obj =nullptr;
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
bool InitAutoMaterial()
|
||||
{
|
||||
mtl::Material2DCreateConfig cfg(device->GetDeviceAttribute(),"VertexColor2D",Prim::Lines);
|
||||
|
||||
cfg.coordinate_system=CoordinateSystem2D::NDC;
|
||||
cfg.local_to_world=false;
|
||||
|
||||
AutoDelete<mtl::MaterialCreateInfo> mci=mtl::CreateVertexColor2D(&cfg);
|
||||
|
||||
material_instance=db->CreateMaterialInstance(mci);
|
||||
|
||||
return material_instance;
|
||||
}
|
||||
|
||||
bool InitPipeline()
|
||||
{
|
||||
pipeline=CreatePipeline(material_instance,InlinePipeline::Solid2D,Prim::Lines);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
bool InitVBO()
|
||||
{
|
||||
PrimitiveCreater rpc(device,material_instance->GetVIL());
|
||||
|
||||
rpc.Init("Triangle",VERTEX_COUNT);
|
||||
|
||||
if(!rpc.WriteVAB(VAN::Position, PositionFormat, position_data))return(false);
|
||||
if(!rpc.WriteVAB(VAN::Color, ColorFormat, color_data ))return(false);
|
||||
|
||||
render_obj=db->CreateRenderable(&rpc,material_instance,pipeline);
|
||||
return(render_obj);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
bool Init()
|
||||
{
|
||||
if(!VulkanApplicationFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||
return(false);
|
||||
|
||||
if(!InitAutoMaterial())
|
||||
return(false);
|
||||
|
||||
if(!InitPipeline())
|
||||
return(false);
|
||||
|
||||
if(!InitVBO())
|
||||
return(false);
|
||||
|
||||
if(!BuildCommandBuffer(render_obj))
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(uint w,uint 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;
|
||||
}
|
@ -54,6 +54,15 @@ public:
|
||||
|
||||
MaterialCreateInfo *CreateVertexColor2D(const Material2DCreateConfig *);
|
||||
MaterialCreateInfo *CreatePureColor2D(const Material2DCreateConfig *);
|
||||
|
||||
|
||||
struct MaterialLerpLineConfig
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
MaterialCreateInfo *CreateLerpLine2D(const Material2DCreateConfig *);
|
||||
|
||||
MaterialCreateInfo *CreatePureTexture2D(const Material2DCreateConfig *);
|
||||
MaterialCreateInfo *CreateRectTexture2D(Material2DCreateConfig *);
|
||||
MaterialCreateInfo *CreateRectTexture2DArray(Material2DCreateConfig *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user