Classes
The main classes for a modularized rendering engine would be, from the bottom up
- Primitive
- Base objects to be drawn. Triangles, QuadStrip, Point, etc.
- Transform
- Pretty much resolving to a 4×4 matrix. Translate, Rotate, Scale, etc.
- Scene
- A graph representing the entire scene (eg. a scene graph). Ignoring material states and other more complicated state problems, the graph, or tree, will be Transforms as interior elements and Primitives as leaves.
- Camera
- Describes how we view the scene. Sets up the View and Projection matrices. MonoCamera, StereoCamera, PerspectiveCamera, OrthographicCamera, etc.
- CameraManipulator
- The Camera tells us how to view the scene, but the CameraManilpulator tells us how the can must most with respect to keyboard and mouse events. Has a Camera as a member.
- Renderer
- Takes a CameraManipulator and Scene and tells us how to combine the two using a drawing library like OpenGL or DirectX. This sets up the View and Projection matrices based on the Camera, then sets up the Model matrix while drawing Primitives using the scene. It also sends messages about keyboard and mouse events from the WindowManager to the CameraManipulator and possibly the Scene.
- WindowManager
- Displays the window and creates the necessary buffers for the renderer. Comminucates with the operating system to recieve keyboard and mouse events, then sends them to the renderer. Lets the renderer know when things like a screen resize or key press happens. This would be made from GLUT, MFC, Win32, etc.
Hypothetically, we can set this up to be very flexible in terms of what it can do. We can have an OpenGL Renderer or DirectX renderer, but not change the camera, scene or window manager. Different parts should be able to swap out with no problems as long as each class does it’s job properly.