Engine design problem.

I’m creating a small 3D engine and I’m having a few problems with something I forgot to think about when I was writing it. I forgot I had to support more that one shader per object. Right now every object is put in a VBO and before rendering I enable the shader applied to that object and disable it after finishing with that object. The problem now is that I have to enable more than one shader per object (one shader per face of an object). Now I was thinking as a solution to make several VBOs per object, one VBO per shader in the object in such way that I avoid changing shaders again and again. Is that a good solution? If not, what’s a better solution?

I would recommend using index lists sorted by material, in order to avoid state switches.

If you want a more detailed explanation, let me know.

Baggio, you have to split your mesh into subparts depending on their shader ID. You use one big VBO for the whole mesh, but you use different index arrays. You change your shader between each draw call.


Ok, I will do that. Thanks for helping me with this problem.