Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VK_KHR_WIN32_SURFACE_EXTENSION_NAME undefined, in Vulkan code

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?

like image 612
Ian Young Avatar asked Mar 23 '16 20:03

Ian Young


2 Answers

As it turns out, I was missing some preprocessor directives in the project settings:

VK_PROTOTYPES
VK_USE_PLATFORM_WIN32_KHR

I hope this info helps out anyone who has the same problem.

like image 55
Ian Young Avatar answered Oct 22 '22 17:10

Ian Young


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
like image 1
Ulises Avatar answered Oct 22 '22 15:10

Ulises