UrhoSharp needs to render the scene to a viewport. A game can have multiple viewports, based on multiple cameras. Think of a game where you drive a car. The main viewport will be the game from the perspective of the driver. Another viewport might be the rear-view mirrors, which would actually be cameras themselves that render what they see onto the main viewport. Let's set this up by going through the following steps:
- In the WhackABox project, open the Game.cs file.
- Add the viewport property to the class, as shown in the following code snippet. A good practice is to place it right after the declaration of the class itself, but placing it anywhere within the class will work.
- Add the InitializeRenderer() method anywhere in the class, as shown in the following code snippet:
private Viewport viewport;...
private void InitializeRenderer()
{
viewport = new Viewport(Context, scene, camera, null);
Renderer.SetViewport(0, viewport);
}