VK_KHR_WIN32_SURFACE_EXTENSION_NAME undefined, in Vulkan code

Viewed 6473

I'm attempting to write a simple vulkan based application, but when trying to add the surface extension to the list of enabled extensions, like so:

    enabledExtensions.push_back( VK_KHR_SURFACE_EXTENSION_NAME );
#if defined (_WIN32)
    enabledExtensions.push_back( VK_KHR_WIN32_SURFACE_EXTENSION_NAME );
#else
    enabledExtensions.push_back( VK_KHR_XCB_SURFACE_EXTENSION_NAME );
#endif

Visual studio complains that VK_KHR_WIN32_SURFACE_EXTENSION_NAMEis undefined.

When I right click it and go to definition, it opens vulkan.h. Upon inspection of VK_USE_PLATFORM_WIN32_KHR I find this to be also undefined, which prevents the definition of VK_KHR_WIN32_SURFACE_EXTENSION_NAME. Could someone explain how to fix this?

2 Answers

This seems to be a common problem, currently you can fix this by adding the specific header

#if defined (_WIN32)
    #include <vulkan/vulkan_win32.h>
#elif defined(__linux__)
    #include <vulkan/vulkan_xcb.h>
#elif defined(__ANDROID__)
    #include <vulkan/vulkan_android.h>
#endif
Related