gpt4 book ai didi

c++ - GLFW在MinGW中找不到VK_KHR_win32_surface

转载 作者:行者123 更新时间:2023-12-02 10:11:09 26 4
gpt4 key购买 nike

描述
目前,我的程序在MSVC上运行时没有任何问题,但在MinGW上glfwCreateWindowSurface(...)奇怪地抛出了一个错误,即缺少VK_KHR_win32_surface扩展名。
表面代码

void createSurface() {
if (glfwCreateWindowSurface(instance, window, nullptr, &surface) != VK_SUCCESS) {
throw std::runtime_error("failed to create window surface!");
}
}
附加信息
  • vkGetInstanceProcAddr(..., "vkCreateWin32SurfaceKHR")glfwGetInstanceProcAddress(..., "vkCreateWin32SurfaceKHR"):返回非空函数指针
  • glfwGetError(...):返回65542Win32: Vulkan instance missing VK_KHR_win32_surface extension
  • vkEnumerateInstanceExtensionProperties(...):列出VK_KHR_win32_surface扩展名
  • glfwCreateWindowSurface(...):返回VK_ERROR_EXTENSION_NOT_PRESENT
  • glfwVulkanSupported():返回1个
  • 应该与https://vulkan-tutorial.com/code/26_depth_buffering.cpp
  • 相同的代码

    最佳答案

    通过使用GLFW Native进行了修复,因为它可以工作:

    #define GLFW_EXPOSE_NATIVE_WIN32
    #include <GLFW/glfw3native.h>

    // ...

    VkWin32SurfaceCreateInfoKHR surfaceInfo {};
    surfaceInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR;
    surfaceInfo.hinstance = GetModuleHandle(nullptr);
    surfaceInfo.hwnd = glfwGetWin32Window(window);

    if (vkCreateWin32SurfaceKHR(instance, &surfaceInfo, nullptr, &surface) != VK_SUCCESS) {
    throw std::runtime_error("failed to create window surface!");
    }

    关于c++ - GLFW在MinGW中找不到VK_KHR_win32_surface,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63535891/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com