   a good rendering loop
  I started rewriting my renderer in hopes of making it substantially faster.  I have found that I may be looping through the vertices and triangles of each mesh too many times. In my old loop, I went through the mesh once per light for lighting, 3-4 times per light for stencil shadow volumes, once per light for bump map coords, and another time to finally render it.  That's obviously enough looping to kill any performance I might have had.  So, I came up with this psuedo code loop, and was wondering if some of you guys could critique it, or what-not (For clarity: My renderer will render batches of meshes per material by using its own pre-allocated vertex array): for( each draw_pack) //a draw_pack contains info like depth testing and blending functions{SetupDrawPack();for( each material )//a material contains texture info{SetupMaterial(); //binds current texturesfor( each visible mesh ){for(each visible triangle){for(each light){light.AddLightingToTriangle(curTri);light.AdjustEmbossMapTexCoords(curTri);light.shadowVolume[curVolume].AddData(curTri);AddTriIndicesToGlobalIndiceList(curTri);}}for(each vertice){AddVertDataToGlobalVertList(curVert);}}}SubmitGlobalVertList();ClearLists();//doesn't iterate through list, just sets # used to 0}DrawShadowVolumesEtc();Anyway, i may have forgotten some things, but i was just hoping some of you could critique the basic loop.  Thankyou for any help!   -----------------------------I never chew my cabbage twice[edited by - odiousangel on February 6, 2004 4:04:07 PM][edited by - odiousangel on February 6, 2004 4:05:47 PM]