diff --git a/CMakeLists.txt b/CMakeLists.txt index b297780..19fe767 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ if (POLICY CMP0141) set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>,$<$:ProgramDatabase>>") endif() - +set(CMAKE_CXX_STANDARD 17) project ("VulkanTutorial") @@ -22,6 +22,7 @@ set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # glm +include_directories(libs/glm-1.0.0) SET(GLM_TEST_ENABLE OFF CACHE BOOL "GLM Build unit tests") add_subdirectory(libs/glm-1.0.0 EXCLUDE_FROM_ALL) diff --git a/VulkanTutorial.cpp b/VulkanTutorial.cpp index 8e90ffb..1708080 100644 --- a/VulkanTutorial.cpp +++ b/VulkanTutorial.cpp @@ -15,6 +15,10 @@ const std::vector swapchainExtensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME }; +const std::vector instanceExtensions = { + "VK_EXT_headless_surface" +}; + #ifdef NDEBUG const bool enableValidationLayers = false; #else @@ -213,9 +217,10 @@ std::vector HelloTriangleApplication::getRequiredExtensions() { if (enableValidationLayers) { extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); - + extensions.push_back("VK_EXT_headless_surface"); } + return extensions; } @@ -280,9 +285,19 @@ void HelloTriangleApplication::populateDebugMessengerCreateInfo(VkDebugUtilsMess void HelloTriangleApplication::createSurface() { + /* if (glfwCreateWindowSurface(instance,window,nullptr,&surface) != VK_SUCCESS) { throw std::runtime_error("failed to create window surface in createSurface()"); + }*/ + VkHeadlessSurfaceCreateInfoEXT headlessSurfaceCreateInfo = {}; + headlessSurfaceCreateInfo.sType = VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT; + headlessSurfaceCreateInfo.pNext = NULL; + headlessSurfaceCreateInfo.flags = 0; + + if (vkCreateHeadlessSurfaceEXT(instance, &headlessSurfaceCreateInfo, nullptr, &surface) != VK_SUCCESS) + { + throw std::runtime_error("failed to create window surface in createheadlessSurface"); } } @@ -659,7 +674,7 @@ std::vector HelloTriangleApplication::readFile(const std::string& filename throw std::runtime_error("failed to open file!"); } - rsize_t fileSize = (rsize_t)file.tellg(); + ssize_t fileSize = (ssize_t)file.tellg(); std::vector buffer(fileSize); file.seekg(0); diff --git a/VulkanTutorial.h b/VulkanTutorial.h index f0050c5..1c4eab5 100644 --- a/VulkanTutorial.h +++ b/VulkanTutorial.h @@ -4,21 +4,23 @@ #pragma once #define GLM_FORCE_RADIANS -#include -#include + +#include #define GLFW_INCLUDE_VULKAN #include #include -#include +#include +#include +#include #include #include #include #include #include #include - +#include #include #include #include