48 lines
1.1 KiB
C++
48 lines
1.1 KiB
C++
#include "src/VulkanRenderer.h"
|
|
|
|
#include "src/managers/GLFWManager.h"
|
|
#include "src/managers/VulkanManager.h"
|
|
|
|
namespace PB::Renderer
|
|
{
|
|
void CleanupAllAndExit(const int code)
|
|
{
|
|
if (!GLFWManager::Cleanup())
|
|
std::exit(EXIT_FAILURE);
|
|
|
|
if (!VulkanManager::Cleanup())
|
|
std::exit(EXIT_FAILURE);
|
|
|
|
std::exit(code);
|
|
}
|
|
}
|
|
|
|
int main()
|
|
{
|
|
using namespace PB::Renderer; // Project namespace
|
|
|
|
/* Initializes GLFW and creates window */
|
|
if (!GLFWManager::Init())
|
|
return -1;
|
|
|
|
GLFWwindow* window = GLFWManager::CreateWindow(800, 600, "Vulkan window");
|
|
if (!window)
|
|
return -1;
|
|
|
|
/* Runs Vulkan initialisation functions */
|
|
if (!VulkanManager::InitAll(window))
|
|
CleanupAllAndExit(EXIT_FAILURE);
|
|
|
|
/* Polls window events whilst it is still open */
|
|
while (!glfwWindowShouldClose(window))
|
|
{
|
|
glfwPollEvents();
|
|
|
|
if (!VulkanManager::RenderPass())
|
|
CleanupAllAndExit(EXIT_FAILURE);
|
|
}
|
|
|
|
/* Cleans up GLFW and Vulkan */
|
|
CleanupAllAndExit(EXIT_SUCCESS);
|
|
}
|