Rendering multiple meshes with OpenGL
In the previous recipes, we learned how to build a mesh preprocessing pipeline and convert 3D meshes from data exchange formats, such as .obj
or .gltf2
, into our runtime mesh data format and render it via the Vulkan API. Let's switch gears and examine how to render this converted data using OpenGL.
Getting ready
The full source code for this recipe is located in Chapter5/GL03_MeshRenderer
. It is recommended that you revisit the Implementing a geometry conversion tool recipe before continuing further.
How to do it…
Let's implement a simple GLMesh
helper class to render our mesh using OpenGL:
- The constructor accepts pointers to the indices and vertices data buffers. The data buffers are used as-is, and they are uploaded directly into the respective OpenGL buffers. The number of indices is inferred from the indices buffer size, assuming the indices are stored as 32-bit unsigned integers:
class GLMesh final { public...