@@ -153,7 +153,9 @@ The parameters for an image are specified in a `VkImageCreateInfo` struct:
153153
154154[,c++]
155155----
156- vk::ImageCreateInfo imageInfo( {}, vk::ImageType::e2D, format, {width, height, 1}, 1, 1, vk::SampleCountFlagBits::e1, tiling, usage, vk::SharingMode::eExclusive, 0);
156+ vk::ImageCreateInfo imageInfo{ .imageType = vk::ImageType::e2D, .format = format,
157+ .extent = {width, height, 1}, .mipLevels = 1, .arrayLayers = 1, .samples = vk::SampleCountFlagBits::e1,
158+ .tiling = tiling, .usage = usage, .sharingMode = vk::SharingMode::eExclusive};
157159----
158160
159161The image type, specified in the `imageType` field, tells Vulkan with what kind of coordinate system the texels in the image are going to be addressed.
@@ -227,12 +229,16 @@ Create the function and move the image object creation and memory allocation to
227229[,c++]
228230----
229231void createImage(uint32_t width, uint32_t height, vk::Format format, vk::ImageTiling tiling, vk::ImageUsageFlags usage, vk::MemoryPropertyFlags properties, vk::raii::Image& image, vk::raii::DeviceMemory& imageMemory) {
230- vk::ImageCreateInfo imageInfo( {}, vk::ImageType::e2D, format, {width, height, 1}, 1, 1, vk::SampleCountFlagBits::e1, tiling, usage, vk::SharingMode::eExclusive, 0);
232+ vk::ImageCreateInfo imageInfo{ .imageType = vk::ImageType::e2D, .format = format,
233+ .extent = {width, height, 1}, .mipLevels = 1, .arrayLayers = 1,
234+ .samples = vk::SampleCountFlagBits::e1, .tiling = tiling,
235+ .usage = usage, .sharingMode = vk::SharingMode::eExclusive };
231236
232237 image = vk::raii::Image( device, imageInfo );
233238
234239 vk::MemoryRequirements memRequirements = image.getMemoryRequirements();
235- vk::MemoryAllocateInfo allocInfo( memRequirements.size, findMemoryType(memRequirements.memoryTypeBits, properties) );
240+ vk::MemoryAllocateInfo allocInfo{ .allocationSize = memRequirements.size,
241+ .memoryTypeIndex = findMemoryType(memRequirements.memoryTypeBits, properties) };
236242 imageMemory = vk::raii::DeviceMemory( device, allocInfo );
237243 image.bindMemory(imageMemory, 0);
238244}
0 commit comments