Why are you checking the validity of the object and uploading data almost everywhere in the code?
The validity check comes from:
- In the old days, resizing a window was emptying the video memory. (Not a valid argument anymore)
- I'm using a mixture of SFML and QT and for some reason, it does prevent me from creating buffer at initialization of my API as there is a switch GL context or some funny stuff similar to this. (I will start by investigate this.)
- I have the option of resetting programs at run time. (I'll make re-initialization on reset() instead.)
The uploading data is rather tricky, as my approach supports multi-materials, I have 2 different techniques that I would like to debate:
- Geometries hold vertex attributes and meshes.
- Meshes hold face ids.
For each geometry:
1 - One VBO for the vertex attributes and one VBO for each mesh(i).
2 - One VBO for the vertex attributes and one VBO for all mesh(i) using buffer offset.
Surprisingly, number 2 is giving better performance even if it has to call subData every draw.
To resume, You are right, I'm in the process of redesign and I'd love some insights.