Camera: setViewport

setViewport( left, bottom, right, top)
  • setViewport allows you to display more than one camera view in the game window at the same time.

left:
  • Position of the left edge of the viewport in the game window
  • Type:  integer
bottom:
  • Position of the bottom edge of the viewport in the game window
  • Type:  integer
right:
  • Position of the right edge of the viewport in the game window
  • Type:  integer
top:
  • Position of the top edge of the viewport in the game window
  • Type:  integer
Note:
  • Bottom left corner of the game window is (0,0)
     
  • Top right corner of the game window is (game window width, game window height)
Sample Code

################## set the size of the camera viewport
  
# import bge
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get a list of the cameras
camList = scene.cameras

# get 2nd camera named "RearView"
rearView_Cam = camList["RearView"]

# set the sides of the rear view mirror
left = bge.render.getWindowWidth() * 1/4
bottom = bge.render.getWindowHeight() * 3/4
right = bge.render.getWindowWidth() * 3/4
top = bge.render.getWindowHeight() * 95/100

# set viewport
rearView_Cam.setViewport( left, bottom, right, top)

# use rear view mirror
rearView_Cam.useViewport = True