the renderer unit:
I've tried to make this as generic as possible, i will give concrete examples as well.
renderer unit API:
i use a data structure (a scene graph ?) that i call a "drawlist" to store a list of all the meshes to be drawn, sorted on texture. the API consists basically of: clear, add, and draw. it draws all meshes in the list in texture order, using a state manager.
render environment to drawlist
render objects to drawlist
at this point, things start getting game specific.
this will depend on the type of environment to be rendered. for an outdoor scene, it might consist of drawing the sky, the ground, rocks, vegetation, etc, and any man made objects like buildings. for an indoor scene its would consist of drawing the current level / cell / area based on camera location. caveman actually renders three types of environments: indoors, outdoors, and underground. rendering an outdoors environment in caveman consists of rendering a skybox or clearing the screen, then rendering the sun or moon, clouds, rain or snow, and the terrain (ground mesh, vegetation, rocks, etc ). generally speaking, render environment will use the "world map" or "level map" and related data structure(s). caveman has a world map, four pattern maps for rocks and plants, and a database of caves, rock shelters, and huts. these are used to generate terrain chunks on the fly as needed for drawing (with LRU caching of course <g>).
games tend to have lists of things. lists of entities, lists of static objects, lists pf projectiles, particle lists, etc, etc. so render objects is basically:
where of course list.renderall is simply: for each item in list, item.render.
rather game specific. i'll give an example from caveman.
1. get basic drawing information (meshID, texureID, modelID, scale, primitive type [mesh / model / 2d billboard / 3d billboard ] ) from appropriate data structure (entities list, enemy type definitions, or object type definitions). entities, enemy definitions and object definitions all have basic drawing information in them.
2. set any additional variables necessary such as current position and rotation.
3. for human models: set skintone texture set used by the model
4. for animated models: set current animation frame for the model
5. add drawing info to the drawlist.
still, generally, speaking, a game will have basic "how to draw it" info for all objects in the game. it will then apply instance specific data such as location, orientation, animation frame, etc. then it will use all this info to actually draw something, using meshes, textures, models, and animations stored in data structures.