Sending the level data to the GPU
With every addition of new features, it becomes simpler to reuse code in the application. In the case of level data, mesh data is encapsulated in the AssimpLevel
class, and drawing the level’s triangles can be done in a small loop over all loaded levels.
As the first step, we create a new shader to draw the level data.
Creating a new shader
Since we need to draw the level triangles only once, using a separate shader for the level data is a clever idea. Add the private
shader named mAssimpLevelShader
to the header file of the renderer class:
Shader mAssimpLevelShader{};
The shader will use the two new files, assimp_level.vert
for the vertex shader and assimp_level.frag
for the fragment shader. We load the files along with the other shaders in the init()
method of the renderer:
if (!mAssimpLevelShader.loadShaders(
"shader/assimp_level.vert",
"shader/assimp_level.frag")) {
return...