2019-04-10 21:54:39 +08:00
|
|
|
|
#include"Window.h"
|
2019-04-09 02:02:43 +08:00
|
|
|
|
#include"VKInstance.h"
|
2019-04-11 02:29:21 +08:00
|
|
|
|
#include"RenderSurface.h"
|
2019-04-10 01:13:31 +08:00
|
|
|
|
|
|
|
|
|
using namespace hgl;
|
|
|
|
|
using namespace hgl::graph;
|
2019-04-09 00:22:26 +08:00
|
|
|
|
|
|
|
|
|
int main(int,char **)
|
|
|
|
|
{
|
2019-04-10 01:13:31 +08:00
|
|
|
|
Window *win=CreateRenderWindow(OS_TEXT("VulkanTest"));
|
2019-04-09 00:22:26 +08:00
|
|
|
|
|
2019-04-10 10:26:25 +08:00
|
|
|
|
win->Create(1280,720);
|
2019-04-10 01:37:37 +08:00
|
|
|
|
|
2019-04-11 02:29:21 +08:00
|
|
|
|
vulkan::Instance *inst=vulkan::CreateInstance(U8_TEXT("VulkanTest"));
|
2019-04-09 00:22:26 +08:00
|
|
|
|
|
2019-04-11 02:29:21 +08:00
|
|
|
|
if(!inst)
|
2019-04-10 01:13:31 +08:00
|
|
|
|
{
|
|
|
|
|
delete win;
|
2019-04-09 02:02:43 +08:00
|
|
|
|
return(-1);
|
2019-04-10 01:13:31 +08:00
|
|
|
|
}
|
2019-04-09 02:02:43 +08:00
|
|
|
|
|
2019-04-11 02:29:21 +08:00
|
|
|
|
vulkan::RenderSurface *render=inst->CreateSurface(win);
|
2019-04-12 16:39:22 +08:00
|
|
|
|
|
|
|
|
|
if(!render)
|
|
|
|
|
{
|
|
|
|
|
delete inst;
|
|
|
|
|
delete win;
|
|
|
|
|
return(-2);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-13 21:44:26 +08:00
|
|
|
|
{
|
|
|
|
|
const vulkan::PhysicalDevice *render_device=render->GetPhysicalDevice();
|
|
|
|
|
|
|
|
|
|
std::cout<<"auto select physical device: "<<render_device->GetDeviceName()<<std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-10 21:54:39 +08:00
|
|
|
|
vulkan::CommandBuffer *cmd_buf=render->CreateCommandBuffer();
|
2019-04-10 14:00:06 +08:00
|
|
|
|
|
2019-04-11 22:40:13 +08:00
|
|
|
|
vulkan::Buffer *ubo=render->CreateUBO(1024);
|
|
|
|
|
|
|
|
|
|
uint8_t *p=ubo->Map();
|
|
|
|
|
|
|
|
|
|
if(p)
|
|
|
|
|
{
|
|
|
|
|
memset(p,0,1024);
|
|
|
|
|
ubo->Unmap();
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-12 16:39:22 +08:00
|
|
|
|
vulkan::RenderPass *rp=render->CreateRenderPass();
|
|
|
|
|
|
|
|
|
|
delete rp;
|
|
|
|
|
|
2019-04-11 22:40:13 +08:00
|
|
|
|
delete ubo;
|
2019-04-09 02:02:43 +08:00
|
|
|
|
|
|
|
|
|
delete cmd_buf;
|
2019-04-10 21:54:39 +08:00
|
|
|
|
delete render;
|
2019-04-12 22:14:40 +08:00
|
|
|
|
delete inst;
|
2019-04-10 01:13:31 +08:00
|
|
|
|
delete win;
|
2019-04-09 00:22:26 +08:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|