Made Vulkan Surface
This commit is contained in:
27
main.cpp
27
main.cpp
@@ -1,6 +1,22 @@
|
||||
#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
|
||||
@@ -13,13 +29,19 @@ int main()
|
||||
if (!window)
|
||||
return -1;
|
||||
|
||||
/* Creates the Vulkan instance */
|
||||
/* 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))
|
||||
{
|
||||
@@ -27,6 +49,5 @@ int main()
|
||||
}
|
||||
|
||||
/* Cleans up GLFW and Vulkan */
|
||||
if (!GLFWManager::Cleanup() || !VulkanManager::Cleanup())
|
||||
return -1;
|
||||
CleanupAllAndExit();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user