Files
VulkanRenderer/main.cpp
2025-11-15 18:24:07 +00:00

54 lines
1.2 KiB
C++

#include "src/VulkanRenderer.h"
#include "src/managers/GLFWManager.h"
#include "src/managers/VulkanManager.h"
namespace PB::Renderer
{
void CleanupAllAndExit()
{
if (!GLFWManager::Cleanup())
std::exit(EXIT_FAILURE);
if (VulkanManager::Cleanup())
std::exit(EXIT_FAILURE);
std::exit(EXIT_SUCCESS);
}
}
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;
/* Creates the Vulkan instance and surface */
if (std::optional<VkInstance> instance = VulkanManager::Init(); !instance)
{
GLFWManager::Cleanup();
return -1;
}
if (std::optional<VkSurfaceKHR> surface = VulkanManager::CreateSurface(window); !surface)
{
CleanupAllAndExit();
return -1;
}
/* Polls window events whilst it is still open */
while (!glfwWindowShouldClose(window))
{
glfwPollEvents();
}
/* Cleans up GLFW and Vulkan */
CleanupAllAndExit();
}