Organizing the loaded data into a C++ class
As we have now explored the glTF file format and an example glTF file, extending the shader code in preparation to draw a glTF model in previous sections of this chapter, we will use this new-found knowledge to create a new C++ model class. The new class will encapsulate all functionality and code to load a glTF file from the filesystem, drawing the model defined by the file on the screen.
Learning about the design and implementation of the C++ class
Our new model class will have two purposes:
- Loading a glTF model: To load the model, we need the filename for the model and the texture; plus, we will update the user interface to show the number of triangles that the glTF model is made of
- To draw a glTF model: Drawing the model needs to be split into the creation of the vertex and index buffer, the upload of the vertex and index data, and the call to draw the model itself
Finally, a cleanup method will be implemented...