Creating an image view
Images are rarely used directly in Vulkan commands. Framebuffers and shaders (via descriptor sets) access images through image views. Image views define a selected part of an image's memory and specify additional information needed to properly read an image's data. That's why we need to know how to create an image view.
How to do it...
- Take the handle of a logical device and use it to initialize a variable of type
VkDevice
namedlogical_device
. - Use the handle of a created image to initialize a variable of type
VkImage
namedimage
. - Create a variable of type
VkImageViewCreateInfo
namedimage_view_create_info
. Use the following values for its members:VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
value forsType
nullptr
value forpNext
0
value forflags
image
variable forimage
- Type of image view for
viewType
- Format of an image or other compatible format (if you want to reinterpret it inside the view) for
format
VK_COMPONENT_SWIZZLE_IDENTITY
value for all members of acomponents
member...