A good and flexible rendering pipeline is essential for me as I often like to tweak it. I tried to make one that was relatively decoupled so that if I move the stages around it still work. The solution I had (not a very complicated one) was to simply have a stack of polymorphic render stages.
From this 2 class derive : render_stage2D and render_stage3D.
The 2D render stage is for post processing effects as they simply need a 2D textured quad rendered of the scene.
The 3D render stage is for stages that require the entire scene to be rendered again. For example the shadow mapping stage which would be at the beginning of the pipeline.
Creating a stage requires a struct render_stage_create_info structure passed into the init function.
It needs the dimensions of the texture target and the target textures or renderbuffers.
This is how the shadow mapping stage gets created:
For a post processing stage it looks like this:
The 2D stage most likely needs dependencies of the previous stages.
This one needs "texture.motion_blur" and "texture.hblur1". One could simply specify to use the previous stage’s output as the input by passing TEXTURE2D_BINDING_PREVIOUS_OUTPUT into the add_texture2D_bind function.