To start developing applications using the Vulkan API, we need to download a SDK and use some of its resources in our application.
Downloading Vulkan's SDK
Getting ready
Before we can execute any application that uses the Vulkan API, we also need to install a graphics drivers that supports the Vulkan API. These can be found on a graphics hardware vendor's site.
How to do it...
On the Windows operating system family:
- Go to https://vulkan.lunarg.com.
- Scroll to the bottom of the page and choose WINDOWS operating system.
- Download and save the SDK installer file.
- Run the installer and select the destination at which you want to install the SDK. By default, it is installed to a C:\VulkanSDK\<version>\ folder.
- When the installation is finished, open the folder in which the Vulkan SDK was installed and then open the RunTimeInstaller sub-folder. Execute VulkanRT-<version>-Installer file. This will install the latest version of the Vulkan Loader.
- Once again, go to the folder in which the SDK was installed and open the Include\vulkan sub-folder. Copy the vk_platform.h and vulkan.h header files to the project folder of the application you want to develop. We will call these two files Vulkan header files.
On the Linux operating system family:
- Update system packages by running the following commands:
sudo apt-get update sudo apt-get dist-upgrade
- To be able to build and execute Vulkan samples from the SDK, install additional development packages by running the following command:
sudo apt-get install libglm-dev graphviz libxcb-dri3-0 libxcb-present0 libpciaccess0 cmake libpng-dev libxcb-dri3- dev libx11-dev
- Go to https://vulkan.lunarg.com.
- Scroll to the bottom of the page and choose LINUX operating system.
- Download the Linux package for the SDK and save it in the desired folder.
- Open Terminal and change the current directory to the folder to which the SDK package was downloaded.
- Change the access permissions to the downloaded file by executing the following command:
chmod ugo+x vulkansdk-linux-x86_64-<version>.run
- Run the downloaded SDK package installer file with the following command:
./vulkansdk-linux-x86_64-<version>.run
- Change the current directory to the VulkanSDK/<version> folder that was created by the SDK package installer.
- Set up environment variables by executing the following command:
sudo su VULKAN_SDK=$PWD/x86_64 echo export PATH=$PATH:$VULKAN_SDK/bin >> /etc/environment echo export VK_LAYER_PATH=$VULKAN_SDK/etc/explicit_layer.d >> /etc/environment echo $VULKAN_SDK/lib >> /etc/ld.so.conf.d/vulkan.conf ldconfig
- Change the current directory to the x86_64/include/vulkan folder.
- Copy vk_platform.h and vulkan.h header files to the project folder of the application you want to develop. We will call these two files Vulkan header files.
- Restart the computer for the changes to take effect.
How it works...
The SDK contains resources needed to create applications using the Vulkan API. Vulkan header files (the vk_platform.h and vulkan.h files) need to be included in the source code of our application so we can use the Vulkan API functions, structures, enumerations, and so on, inside the code.
The Vulkan Loader (vulkan-1.dll file on Windows, libvulkan.so.1 file on Linux systems) is a dynamic library responsible for exposing Vulkan API functions and forwarding them to the graphics driver. We connect with it in our application and load Vulkan API functions from it.
See also
The following recipes in this chapter:
- Enabling validation layers
- Connecting with a Vulkan Loader library
- Releasing a Vulkan Loader library