Я нашел этот код на inte rnet, но получаю такую ошибку: VK_ERROR_EXTENSION_NOT_PRESENT
(- 7) на glfwCreateWindowSurface
result = glfwCreateWindowSurface(instance, window, nullptr, &surface);
std::cout << result; // -7
Код:
#include <iostream>
#define VK_USE_PLATFORM_WIN32_KHR
#define GLFW_INCLUDE_VULKAN
#include <GLFW\glfw3.h>
//#include <vulkan\vulkan.h>
#include <vector>
#define ASSERT_VULKAN(val)\
if (val != VK_SUCCESS) {\
__debugbreak();\
}
VkInstance instance;
VkSurfaceKHR surface;
GLFWwindow *window;
void startGlfw() {
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
window = glfwCreateWindow(400, 300, "A", nullptr, nullptr);
}
void startVulkan() {
VkApplicationInfo appInfo;
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
appInfo.pNext = nullptr;
appInfo.pApplicationName = "Vulkan";
appInfo.applicationVersion = VK_MAKE_VERSION(0, 0, 0);
appInfo.pEngineName = "enginetest";
appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
appInfo.apiVersion = VK_API_VERSION_1_0;
uint32_t amountOfLayers = 0;
vkEnumerateInstanceLayerProperties(&amountOfLayers, nullptr);
VkLayerProperties *layers = new VkLayerProperties[amountOfLayers];
vkEnumerateInstanceLayerProperties(&amountOfLayers, layers);
std::cout << "Amount of Instance Layers: " << amountOfLayers << std::endl;
uint32_t amountOfExtensions = 0;
vkEnumerateInstanceExtensionProperties(nullptr, &amountOfExtensions, nullptr);
VkExtensionProperties *extensions = new VkExtensionProperties[amountOfExtensions];
vkEnumerateInstanceExtensionProperties(nullptr, &amountOfExtensions, extensions);
const std::vector<const char*> validationLayers = {
"VK_LAYER_LUNARG_standard_validation"
};
uint32_t amountOfGlfwExtensions = 0;
auto glfwExtensions = glfwGetRequiredInstanceExtensions(&amountOfExtensions);
VkInstanceCreateInfo instanceInfo;
instanceInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instanceInfo.pNext = nullptr;
instanceInfo.flags = 0;
instanceInfo.pApplicationInfo = &appInfo;
instanceInfo.enabledLayerCount = validationLayers.size();
instanceInfo.ppEnabledLayerNames = validationLayers.data();
instanceInfo.enabledExtensionCount = amountOfGlfwExtensions;
instanceInfo.ppEnabledExtensionNames = glfwExtensions;
VkResult result = vkCreateInstance(&instanceInfo, nullptr, &instance);
ASSERT_VULKAN(result);
result = glfwCreateWindowSurface(instance, window, nullptr, &surface);
std::cout << result; // -7
ASSERT_VULKAN(result);
}
int main() {
startGlfw();
startVulkan();
}
кто-нибудь может мне помочь? спасибо