#include "src/VulkanRenderer.h" #include "src/managers/GLFWManager.h" #include "src/managers/vulkan/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 a window */ GLFWwindow* window = GLFWManager::Init(800, 600, "Vulkan window"); if (window == nullptr) return -1; /* Runs Vulkan initialisation functions */ if (!VulkanManager::Init(window)) CleanupAllAndExit(EXIT_FAILURE); /* Adds runtime objects */ const std::vector vertices = { 0.0f, -0.5f, 0.5f, 0.9f, -0.5f, 0.5f }; const std::vector indices = {0, 1, 2}; VulkanManager::CreateNewRenderObject({1.0f, 0.0f, 0.0f, 1.0f}, vertices, indices); const std::vector otherVertices = { -0.9f, 0.0f, -0.9f, -0.9f, 0.0f, -0.9f }; VulkanManager::CreateNewRenderObject({1.0f, 1.0f, 0.0f, 1.0f}, otherVertices, indices); /* Polls window events whilst it is still open */ while (!glfwWindowShouldClose(window)) { glfwPollEvents(); GLFWManager::UpdateWindowTitleFPSInfo(); if (VulkanManager::RenderPass(window) == false) CleanupAllAndExit(EXIT_FAILURE); } /* Cleans up GLFW and Vulkan */ CleanupAllAndExit(EXIT_SUCCESS); }