initImagesAndViews

Initialises the images of a previously created swapchain and creates an associated image view for each image

Image objects are used to hold the swapchain images. When the swapchain was created, the images were automatically created alongside it. This function creates an image view for each swapchain image.

This vector is used as a temporary vector to hold the retrieved images.

 	uint32_t swapchainImageCount;
 	std::vector<VkImage> images;
 

Get the number of the images which are held by the swapchain. This is set in InitSwapchain function and is the minimum number of images supported.

 	vkGetSwapchainImagesKHR(appManager.device, appManager.swapchain, &swapchainImageCount, nullptr)
 

Resize the temporary images vector to hold the number of images.

 	images.resize(swapchainImageCount);
 

Resize the application's permanent swapchain images vector to be able to hold the number of images.

 	appManager.swapChainImages.resize(swapchainImageCount);
 

Get all of the images from the swapchain and save them in a temporary vector.

 	vkGetSwapchainImagesKHR(appManager.device, appManager.swapchain, &swapchainImageCount, images.data())
 

Iterate over each image in order to create an image view for each one.

 	for (uint32_t i = 0; i < swapchainImageCount; ++i)
 	{

Copy over the images to the permenant vector.

 		appManager.swapChainImages[i].image = images[i];
 

Create the image view object itself, referencing one of the retrieved swapchain images.

 		VkImageViewCreateInfo image_view_info = {};
 		image_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
 		image_view_info.pNext = nullptr;
 		image_view_info.flags = 0;
 		image_view_info.image = appManager.swapChainImages[i].image;
 		image_view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
 		image_view_info.format = appManager.surfaceFormat.format;
 
 		image_view_info.components.r = VK_COMPONENT_SWIZZLE_R;
 		image_view_info.components.g = VK_COMPONENT_SWIZZLE_G;
 		image_view_info.components.b = VK_COMPONENT_SWIZZLE_B;
 		image_view_info.components.a = VK_COMPONENT_SWIZZLE_A;
 
 		image_view_info.subresourceRange.layerCount = 1;
 		image_view_info.subresourceRange.levelCount = 1;
 		image_view_info.subresourceRange.baseArrayLayer = 0;
 		image_view_info.subresourceRange.baseMipLevel = 0;
 		image_view_info.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
 
 		vkCreateImageView(appManager.device, &image_view_info, nullptr, &appManager.swapChainImages[i].view)
 	}