
We will use the code that we used before and once again create a new empty method:
- Remove the
setShadowTechnique()
function call from thecreateCamera()
function. We don't want our scene in wireframe mode. - Create an empty
createViewports()
method:void createViewports() { }
- Create a viewport:
Ogre::Viewport* vp = mWindow->addViewport(mCamera);
- Set the background color and the aspect ratio:
vp->setBackgroundColour(ColourValue(0.0f,0.0f,1.0f)); mCamera->setAspectRatio(Real(vp->getActualWidth()) / Real(vp->getActualHeight()));
- Compile and run the application.
We created a viewport. To do this, we needed to pass a camera to the function. Each viewport can only render the view of one camera, so Ogre 3D enforces that one camera is given during creation. Of course, the camera can be changed later using the appropriate getter and setter functions. The most noticeable change is that the background color changed from black to blue. The reason should be obvious: the new viewport has the background color blue; we set it in step 3. Also in step 3, we set the aspect ratio the aspect ratio describes the ratio between the width and height of a rendered image; in math terms: aspect ratio = width of window divided by height of window.