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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.