Original Post
This is the method I was told to use to render all objects in a frame: 1) Create a list of things that need to be drawn. 2) Sort the list so that the pipeline is well-optimized. 3) Draw all the objects from the list. On step (2), the list would first be sorted by which vertex shader is used to transform the vertices. This is because swapping to a different vertex shader takes longer than any other call to SetRenderState, SetFVF, SetStreamSource, etc. Objects that use the same vertex shader are then sorted secondarily by pixel shader because it is the next slowest render option to change. The list is then sorted to reduce the number times the following are render options are changed: vertex buffer, index buffer, texture, all the different render states, etc. Another important thing is to render transparent items last, which is fairly simple. Questions / Comments on that? So if you understand all that, I have a question. I think I can do all this fairly easy, its just a matter of what data the list contains. I'm assuming the list must contain ALL the data needed to render each object. This means that each entry in the list will need the following items to draw each object (these are the render options that the list will be sorted by, in no particular order): vertex shader pixel shader vertex buffer index buffer parameters to call DrawIndexPrimitive (vertex/index offsets, # of polys) texture (lets not multitexture for now) which lights to turn on for the object which render states to set for the object (transparency, zbuffer, projection matrix, etc) *World Matrix (each objects position/rotation) Anything else? (this is just a list off the top of my head) So, does this technique sound reasonable? *A little optimization I noticed while writing this: Lets say your game draws 20 cubes to the screen. Instead of putting 20 entries into the list, just put 20 world matrices in one entry and draw all 20 cubes with the same render states, etc.