Instancing allows one to render in a single draw call several instance of a single VAO
It is accomplished by calling glDrawElementsInstanced instead of a regular glDrawElements.
int instance_number = 50;
glDrawElementsInstanced(GL_TRIANGLES, [...], instance_number);
<aside> ⚠️ The issue here is that all of the instances will end up being drawn at the exact same place. We need a way to difference them in the shader.
</aside>
From there, one can access the id of the current instance being drawn in the shader by using the constant gl_InstanceID.
To provide the transform matrices, a VBO can be used.
In order to specify that every element of the VBO need to be used accross a whole instance before going to the next element for the next instance, we use:
gl_InstanceID(location, nb_instance);