Create Mesh From Scratch - c++ 3D

Vertices and Indices

Vertices are a list of 3D triangles in the 3D space.

Indices are a list of vertices orders about how the triangles are composed together.

First, a mesh must have vertices and indices, it should be an empty mesh in 3D space.

Mesh Buffers

Create a mesh buffer class object, then add vertices and indices to the mesh buffer.

And also, the material can be created and bound the the mesh buffer too.

A Mesh

A mesh can be pushed with many mesh buffers, every mesh buffer is a drawing call.

Composed Mesh

Many meshes can compose to a composed mesh.


auto * mesh = new my_3d_mesh;
mesh->add_mesh_buffer(mesh_buffer);
delete mesh_buffer;
mesh_buffer = nullptr;
auto * comp_mesh = new comp_mesh;
comp_mesh->add_mesh(mesh);
delete mesh;
mesh = nullptr;
delete comp_mesh;
com_mesh = nullptr;

Mon Aug 11 11:37:27 PM UTC 2025