
- get/set the starting position of the bottom left corner of the viewport that is displayed on the texture.
- ignored if whole is set to True (ie. viewport_texture.source.whole = True)
Type:
- integer list [ xPos, yPos ]
- x position (pixel width) of the bottom left corner of the viewport.
- Type: integer
- y position (pixel height) of the bottom left corner of the viewport
- Type: integer
- Viewport is the game window.
- Viewport whole set to True uses the whole game window.
- Viewport whole set to False uses only part of the game window.
- Viewport position sets the bottom left corner when the Viewport only uses part of the game window.

###################### get Viewport source position
# import bge module
import bge
# get current scene
scene = bge.logic.getCurrentScene()
# get list of objects in scene
objList = scene.objects
# get object to render to
# my object is named Security_Monitor
obj = objList["Security_Monitor"]
# get the Security_Monitor material ID
# Name of my render material is Screen
matID = bge.texture.materialID(obj, "MAScreen")
# set the texture
viewport_texture = bge.texture.Texture(obj, matID)
# get the texture image
viewport_texture.source = bge.texture.ImageViewport()
# get viewport position
pos = viewport_texture.source.position
# save as an object property
obj["image_viewport"] = viewport_texture
# update texture
viewport_texture.refresh(True)
###################### set viewport positon
# import bge module
import bge
# get current scene
scene = bge.logic.getCurrentScene()
# get list of objects in scene
objList = scene.objects
# get object to render to
# my object is named Security_Monitor
obj = objList["Security_Monitor"]
# get the Security_Monitor material ID
# Name of my render material is Screen
matID = bge.texture.materialID(obj, "MAScreen")
# set the texture
viewport_texture = bge.texture.Texture(obj, matID)
# get the texture image
viewport_texture.source = bge.texture.ImageViewport()
# set position of bottom left corner of viewport
viewport_texture.source.position = [ 200, 200 ]
# save as an object property
obj["image_viewport"] = viewport_texture
# update texture
viewport_texture.refresh(True)