Original Post
Hello all. I'm busy making a small simple OO 3d rendering engine using OGL and D3D. I use a singeton class called 'Renderer' that can be either the D3D renderer of the OGL renderer, so my other classes don't have to worry about that. I'd like to make this Renderer as high level as possible, but still flexible enough to do lots of different things. I've started giving the Renderer class some high level functions. Two of them are: 'bindMaterial' that binds textures and lightning parameters (maybe vertex and fragment programs later. ...and 'drawMesh' that draws a mesh defined by faces (with indexed verts and a material per face). My problem is that all faces can have different materials which would cause a lot of state changes and burn up CPU in drawMesh when it has to check every face for the material and then change it all te time for different materials. It sounds like a good idear to sort all the faces to be redered by material, but that would break up my Mesh structure. Has anyone got some good suggestions? Thanx a lot! Marty