Organizing mesh rendering in Vulkan
In Chapter 3, Getting Started with OpenGL and Vulkan, we learned how to render a textured 3D model on the screen using Vulkan in a direct and pretty ad hoc way. Now we will show how to move one step closer to creating a more scalable 3D model renderer with Vulkan. In the subsequent chapters, we will further generalize the rendering approach so that we can build a minimalistic Vulkan rendering engine from scratch, step by step.
Getting ready
Revisit the Organizing Vulkan frame rendering code recipe and recall how the RendererBase
interface works. The code we will discuss in this recipe can be found in shared/vkRenderers/VulkanModelRenderer.cpp
and the corresponding header file.
How to do it...
Let's declare the ModelRenderer
class, which contains a texture and combined vertex and index buffers:
- The declaration looks as follows:
class ModelRenderer: public RendererBase { public: ModelRenderer(VulkanRenderDevice...