Using texture data in Vulkan
Before we can create meaningful 3D rendering applications with Vulkan, we need to understand how to work with textures. This recipe shows how to implement several functions for creating, destroying, and modifying texture objects, as well as managing the corresponding VkImage
and VkImageView
objects using the Vulkan API.
Getting ready
Uploading texture data to the GPU requires a staging buffer. Be sure to read the previous recipe, Implementing staging buffers, before continuing.
The source code for this recipe can be found in Chapter03/02_STB
.
How to do it...
A Vulkan image is a type of object backed by memory, designed to store 1D, 2D, or 3D images, or arrays of these images. Readers familiar with OpenGL might wonder about cube maps. Cube maps are represented as an array of six 2D images and can be created by setting the VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
flag in the VkImageCreateInfo
structure. We’ll revisit that later. For...