SDL_vulkan.h File Reference
`#include "SDL_video.h"`
`#include "begin_code.h"`
`#include "close_code.h"`
Include dependency graph for SDL_vulkan.h:

Go to the source code of this file.

## Macros

#define | VK_DEFINE_HANDLE(object)
#define | VK_DEFINE_NON_DISPATCHABLE_HANDLE(object)

## Typedefs

typedef VkInstance | SDL_vulkanInstance
typedef VkSurfaceKHR | SDL_vulkanSurface

## Functions

Vulkan support functions

Note
  SDL_Vulkan_GetInstanceExtensions & SDL_Vulkan_CreateSurface API is compatable with Tizen's implementation of Vulkan in SDL.

int | SDL_Vulkan_LoadLibrary (const char *path)
void * | SDL_Vulkan_GetVkGetInstanceProcAddr (void)
void | SDL_Vulkan_UnloadLibrary (void)
SDL_bool | SDL_Vulkan_GetInstanceExtensions (SDL_Window *window, unsigned int *pCount, const char **pNames)
SDL_bool | SDL_Vulkan_CreateSurface (SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
void | SDL_Vulkan_GetDrawableSize (SDL_Window *window, int *w, int *h)

## Macro Definition Documentation

## VK_DEFINE_HANDLE

#define VK_DEFINE_HANDLE | ( |  | object | ) |

Value:
typedef struct object##_T* object;

# CategoryVulkan

Header file for functions to creating Vulkan surfaces on SDL windows.

Definition at line 44 of file SDL_vulkan.h.

## VK_DEFINE_NON_DISPATCHABLE_HANDLE

#define VK_DEFINE_NON_DISPATCHABLE_HANDLE | ( |  | object | ) |

Value:
typedef uint64_t object;
uint64_t
unsigned long long uint64_t
Definition SDL_config_ngage.h:35

Definition at line 49 of file SDL_vulkan.h.

## Typedef Documentation

## SDL_vulkanInstance

typedef VkInstance SDL_vulkanInstance

Definition at line 61 of file SDL_vulkan.h.

## SDL_vulkanSurface

typedef VkSurfaceKHR SDL_vulkanSurface

Definition at line 62 of file SDL_vulkan.h.

## Function Documentation

## SDL_Vulkan_CreateSurface()

SDL_bool SDL_Vulkan_CreateSurface | ( | SDL_Window * | window,
|  | VkInstance | instance,
|  | VkSurfaceKHR * | surface )

extern

Create a Vulkan rendering surface for a window.

The window must have been created with the SDL_WINDOW_VULKAN flag and instance must have been created with extensions returned by SDL_Vulkan_GetInstanceExtensions() enabled.

Parameters

  window | The window to which to attach the Vulkan surface.
  instance | The Vulkan instance handle.
  surface | A pointer to a VkSurfaceKHR handle to output the newly created surface.

Returns
  SDL_TRUE on success, SDL_FALSE on error.

Since
  This function is available since SDL 2.0.6.

See also
  SDL_Vulkan_GetInstanceExtensions
  SDL_Vulkan_GetDrawableSize

## SDL_Vulkan_GetDrawableSize()

void SDL_Vulkan_GetDrawableSize | ( | SDL_Window * | window,
|  | int * | w,
|  | int * | h )

extern

Get the size of the window's underlying drawable dimensions in pixels.

This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with high-DPI support (Apple calls this "Retina"), and not disabled by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint.

Parameters

  window | an SDL_Window for which the size is to be queried.
  w | Pointer to the variable to write the width to or NULL.
  h | Pointer to the variable to write the height to or NULL.

Since
  This function is available since SDL 2.0.6.

See also
  SDL_GetWindowSize
  SDL_CreateWindow
  SDL_Vulkan_CreateSurface

## SDL_Vulkan_GetInstanceExtensions()

SDL_bool SDL_Vulkan_GetInstanceExtensions | ( | SDL_Window * | window,
|  | unsigned int * | pCount,
|  | const char ** | pNames )

extern

Get the names of the Vulkan instance extensions needed to create a surface with SDL_Vulkan_CreateSurface.

If pNames is NULL, then the number of required Vulkan instance extensions is returned in pCount. Otherwise, pCount must point to a variable set to the number of elements in the pNames array, and on return the variable is overwritten with the number of names actually written to pNames. If pCount is less than the number of required extensions, at most pCount structures will be written. If pCount is smaller than the number of required extensions, SDL_FALSE will be returned instead of SDL_TRUE, to indicate that not all the required extensions were returned.

The window parameter is currently needed to be valid as of SDL 2.0.8, however, this parameter will likely be removed in future releases

Parameters

  window | A window for which the required Vulkan instance extensions should be retrieved (will be deprecated in a future release).
  pCount | A pointer to an unsigned int corresponding to the number of extensions to be returned.
  pNames | NULL or a pointer to an array to be filled with required Vulkan instance extensions.

Returns
  SDL_TRUE on success, SDL_FALSE on error.

Since
  This function is available since SDL 2.0.6.

See also
  SDL_Vulkan_CreateSurface

## SDL_Vulkan_GetVkGetInstanceProcAddr()

void * SDL_Vulkan_GetVkGetInstanceProcAddr | ( | void |  | ) |

extern

Get the address of the vkGetInstanceProcAddr function.

This should be called after either calling SDL_Vulkan_LoadLibrary() or creating an SDL_Window with the SDL_WINDOW_VULKAN flag.

Returns
  the function pointer for vkGetInstanceProcAddr or NULL on error.

Since
  This function is available since SDL 2.0.6.

## SDL_Vulkan_LoadLibrary()

int SDL_Vulkan_LoadLibrary | ( | const char * | path | ) |

extern

Dynamically load the Vulkan loader library.

This should be called after initializing the video driver, but before creating any Vulkan windows. If no Vulkan loader library is loaded, the default library will be loaded upon creation of the first Vulkan window.

It is fairly common for Vulkan applications to link with libvulkan instead of explicitly loading it at run time. This will work with SDL provided the application links to a dynamic library and both it and SDL use the same search path.

If you specify a non-NULL path, an application should retrieve all of the Vulkan functions it uses from the dynamic library using SDL_Vulkan_GetVkGetInstanceProcAddr unless you can guarantee path points to the same vulkan loader library the application linked to.

On Apple devices, if path is NULL, SDL will attempt to find the vkGetInstanceProcAddr address within all the Mach-O images of the current process. This is because it is fairly common for Vulkan applications to link with libvulkan (and historically MoltenVK was provided as a static library). If it is not found, on macOS, SDL will attempt to load vulkan.framework/vulkan, libvulkan.1.dylib, MoltenVK.framework/MoltenVK, and libMoltenVK.dylib, in that order. On iOS, SDL will attempt to load libMoltenVK.dylib. Applications using a dynamic framework or .dylib must ensure it is included in its application bundle.

On non-Apple devices, application linking with a static libvulkan is not supported. Either do not link to the Vulkan loader or link to a dynamic library version.

Parameters

  path | The platform dependent Vulkan loader library name or NULL.

Returns
  0 on success or -1 if the library couldn't be loaded; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.6.

See also
  SDL_Vulkan_GetVkGetInstanceProcAddr
  SDL_Vulkan_UnloadLibrary

## SDL_Vulkan_UnloadLibrary()

void SDL_Vulkan_UnloadLibrary | ( | void |  | ) |

extern

Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary()

Since
  This function is available since SDL 2.0.6.

See also
  SDL_Vulkan_LoadLibrary