fit for linux

master
ink-soul 2024-04-01 14:49:44 +08:00
parent 84763881f9
commit f640e25b33
3 changed files with 25 additions and 7 deletions

View File

@ -9,7 +9,7 @@ if (POLICY CMP0141)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>: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)

View File

@ -15,6 +15,10 @@ const std::vector<const char*> swapchainExtensions = {
VK_KHR_SWAPCHAIN_EXTENSION_NAME
};
const std::vector<const char*> instanceExtensions = {
"VK_EXT_headless_surface"
};
#ifdef NDEBUG
const bool enableValidationLayers = false;
#else
@ -213,9 +217,10 @@ std::vector<const char*> 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<char> 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<char> buffer(fileSize);
file.seekg(0);

View File

@ -4,21 +4,23 @@
#pragma once
#define GLM_FORCE_RADIANS
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <gtc/matrix_transform.hpp>
#define GLFW_INCLUDE_VULKAN
#include<GLFW/glfw3.h>
#include<vulkan/vulkan.h>
#include<glm/glm.hpp>
#include <cstdlib>
#include <stdlib.h>
#include <glm.hpp>
#include <iostream>
#include <optional>
#include <stdexcept>
#include <functional>
#include <cstdlib>
#include <set>
#include <cstring>
#include <cstdint>
#include <limits>
#include <algorithm>