One of the most common requirements for real time 3D applications is to render a scene to multiple view windows simultaneously. For example, a CAD/CAM-based application renders a scene to four types of views: perspective, orthographic front, side, and top view. In the scene graph architecture, multiple views are achieved with the help of rendering a scene to two or more cameras.
This recipe extends the last recipe to supporting multiple cameras, where each camera has different viewport region (which could be overlapped) and can have separate clear colors (depending on the requirement).
Here are the steps to implement this recipe:
Now on, the screen clear color and buffer clearing will be applied within the Camera view itself. Remove the clear code from
Renderer::render()
. Define avec4
type variable calledclearColor
to store the clear color information:void Camera::SetClearColor(glm::vec4 color){ clearColor = color; }
Apply the clear...