added FullScreenRect example.
This commit is contained in:
parent
4dff46c5c5
commit
1a18fdd77c
@ -0,0 +1,89 @@
|
|||||||
|
// 全屏矩形
|
||||||
|
// 该范例用于演示使用索引画一个矩形,但是不传递顶点信息。
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
static Vector4f color(1,1,1,1);
|
||||||
|
|
||||||
|
class TestApp:public VulkanApplicationFramework
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
MaterialInstance * material_instance =nullptr;
|
||||||
|
RenderableInstance *renderable_instance =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::Fan);
|
||||||
|
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InitVBO()
|
||||||
|
{
|
||||||
|
auto render_obj=db->CreateRenderable(4);
|
||||||
|
if(!render_obj)return(false);
|
||||||
|
|
||||||
|
renderable_instance=db->CreateRenderableInstance(render_obj,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_instance);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Resize(int w,int h)override
|
||||||
|
{
|
||||||
|
VulkanApplicationFramework::Resize(w,h);
|
||||||
|
|
||||||
|
BuildCommandBuffer(renderable_instance);
|
||||||
|
}
|
||||||
|
};//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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user