Viewport1.Items := Viewport2.Items;
It is possible to have multiple viewports visible at the same time.
As TCastleViewport
is a regular user interface control, you can add as many viewports
as you like on a particular TUIState
. And you can configure the size and position of each viewport.
These viewports may even display the same world (but from different cameras). This feature is very useful for split-screen games. Or if you want to show additional view of the world (e.g. from the camera attached to a missile, or from camera observing the world from the top).
To use this feature, just set the Items
property of one viewport to Items
from another viewport.
Like
Viewport1.Items := Viewport2.Items;
Note that you cannot (yet) do this from the CGE editor. In the editor you can set multiple viewports, and their cameras, but you cannot yet make them share the same items.
zombie_fighter example. The viewport setup there is described in the chapter about user interface.
multiple_viewports example. Shows a window split into 4 viewports, all showing the same scene, but with a bit different effects.
fps_game example. Shows using additional viewport for an "overview" camera looking at map from the top.
To improve this documentation just edit the source of this page in AsciiDoctor (simple wiki-like syntax) and create a pull request to Castle Game Engine WWW (cge-www) repository.
Copyright Michalis Kamburelis and Castle Game Engine Contributors.
This webpage is also open-source and we welcome pull requests to improve it.
We use cookies for analytics. See our privacy policy.