Spanning the render view across multiple monitors can greatly enhance player immersion. In a racing game, for example, it's great to not only be able to see out of the car's front window, but also have the side windows available in two extra monitors.
In this short recipe you will learn how to configure Panda3D to use multiple displays and render across two monitors. While the sample assumes two display devices to be used, you can easily follow the principles presented in the following section to use three, four, or even more display devices.
This recipe requires the base code from Setting up the game structure to be present before proceeding. Please revisit this article found in Chapter 1 if you haven't read it yet.
Naturally, you will need two monitors for this recipe, which have to use the same resolution to properly display the sample code's output.
Follow these steps to create an application that takes advantage of a multi-monitor setup:
Application.py
and copy the following code:from direct.showbase.ShowBase import ShowBase from direct.actor.Actor import Actor from pandac.PandaModules import loadPrcFileData loadPrcFileData("", "win-origin 0 0") loadPrcFileData("", "win-size 2880 900") loadPrcFileData("", "undecorated 1") class Application(ShowBase): def __init__(self): ShowBase.__init__(self) self.pandas = [] for i in range(8): panda = Actor("panda", {"walk": "panda-walk"}) panda.reparentTo(render) panda.loop("walk") panda.setX(-28 + i * 8) self.pandas.append(panda) self.cam.setPos(0, -40, 6)
The entire necessary configuration is done in the three highlighted lines of the previous source code. First, the window origin is set to the top left corner of the first display. Then we set the window size to 2880 by 900 pixels. This makes the window span across two monitors with a resolution of 1440 by 900 pixels. For displays with a different size, just multiply the horizontal resolution of your display by two and use the original vertical resolution. The last configuration option makes the window borderless and removes the controls for minimizing, maximizing, and closing the window. Panda3D provides no native fullscreen rendering mode for multiple displays. But using these settings, we are able to make the application window fill both screens and make it appear as if it were set to fullscreen mode.
The same effect can be achieved by adding the following lines shown to your Config.prc
file.
win-origin 0 0 win-size 2880 900 undecorated 1