65 lines
1.2 KiB
C++
65 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#define GLFW_INCLUDE_VULKAN
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include <vector>
|
|
|
|
#ifdef NDEBUG
|
|
const bool enableValidationLayers = false;
|
|
#else
|
|
const bool enableValidationLayers = true;
|
|
#endif
|
|
|
|
class VkSetup
|
|
{
|
|
GLFWwindow* window;
|
|
|
|
VkInstance instance;
|
|
|
|
std::vector<const char*> GetRequiredExtensions()
|
|
{
|
|
uint32_t glfwExtensionCount = 0;
|
|
const char** glfwExtensions;
|
|
glfwExtensions = glfwGetRequiredInstanceExtensions(&glfwExtensionCount);
|
|
|
|
std::vector<const char*> extensions(glfwExtensions, glfwExtensions + glfwExtensionCount);
|
|
|
|
if (enableValidationLayers)
|
|
{
|
|
extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
|
}
|
|
|
|
return extensions;
|
|
}
|
|
|
|
bool CheckValidationLayerSupport()
|
|
{
|
|
uint32_t layerCount;
|
|
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
|
|
|
std::vector<VkLayerProperties> availableLayers(layerCount);
|
|
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
|
|
|
|
for (const char* layerName : validationLayers)
|
|
{
|
|
bool layerFound = false;
|
|
|
|
for (const auto& layerProperties : availableLayers)
|
|
{
|
|
if (strcmp(layerName, layerProperties.layerName) == 0)
|
|
{
|
|
layerFound = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!layerFound)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}; |