Creating a layered 2D image with a CUBEMAP view
A quite common example of images used in 3D applications or games are CUBEMAPs, used for simulating an object reflecting its environment. For this purpose, we don't create a CUBEMAP image. We need to create a layered image and through image view, we tell the hardware that it should interpret its layers as six CUBEMAP faces.
How to do it...
- Take a handle of a logical device. Store it in a variable of type
VkDevice
namedlogical_device
. - Choose the size of an image and remember it must be square. Save the image's dimensions in a variable of type
uint32_t
namedsize
. - Select the number of the image's mipmap levels. Initialize a variable of type
uint32_t
namednum_mipmaps
with the chosen number. - Think about all different scenarios in which the image will be used. Store the logical sum (OR) of all these usages in a variable of type
VkImageUsageFlags
namedusage
. - Create an image of a
VK_IMAGE_TYPE_2D
type, aVK_FORMAT_R8G8B8A8_UNORM
format, six layers, and...