How it works...

Assume we have created a Vulkan Instance and a logical device with enabled WSI extensions. We also created a swapchain object (the full source code for these operations can be found in the accompanying code samples).

To render any geometry, we need to first load a 3D model. Its data needs to be copied to a vertex buffer, so we also need to create a vertex buffer, allocate and bind a memory to it, and we need to copy the model data using a staging buffer:

 if( !Load3DModelFromObjFile( "Data/Models/knot.obj", true, false, false, true, Model ) ) { return false; } InitVkDestroyer( LogicalDevice, VertexBuffer ); if( !CreateBuffer( *LogicalDevice, sizeof( Model.Data[0] ) * Model.Data.size(), VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, ...

Get Vulkan Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.