44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#include "zlog.h"
|
|
#include "zworld.h"
|
|
#include "vkn/vulkan_window.h"
|
|
#include "vkn/vulkan_api.h"
|
|
#include "render/pass/demo_pass.h"
|
|
#include <iostream>
|
|
using namespace api;
|
|
RenderAPI* API;
|
|
void ZWorldModule::OnLoad(int argc, char** argv)
|
|
{
|
|
// 创建窗口
|
|
auto window = new vkn::VulkanWindow(&SDL_CreateWindow, { "zengine" , SDL_WINDOW_VULKAN }, 1080, 720);
|
|
API = new vkn::VulkanAPI();
|
|
auto args = vkn::VulkanWindowArgs::Default();
|
|
args.frames = 3;
|
|
if (!window->CreateRender(&SDL_Vulkan_CreateSurface, args)) {
|
|
zlog::errorf("SDL_Vulkan_CreateSurface failed {}", SDL_GetError());
|
|
}
|
|
API->Init();
|
|
API->context.views.push_back({});
|
|
}
|
|
|
|
void ZWorldModule::OnUnload()
|
|
{
|
|
}
|
|
|
|
void ZWorldModule::MainLoop()
|
|
{
|
|
bool running = true;
|
|
SDL_Event event_;
|
|
while (running) {
|
|
// 处理事件
|
|
while (SDL_PollEvent(&event_)) {
|
|
if (event_.type == SDL_QUIT) {
|
|
running = false;
|
|
}
|
|
}
|
|
API->graph.AddRenderPass<DemoPass>();
|
|
API->BeginFrame();
|
|
API->Render();
|
|
API->EndFrame();
|
|
}
|
|
}
|