ImageViewport: refresh

refresh(update)
  • update the image.

update:

  • Type: boolean
  • True = update the image
  • False = don't update the image.
Sample Code

###################### update the image

# 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")

# get the texture
viewport_texture = bge.texture.Texture(obj, matID)

# get the texture image
viewport_texture.source = bge.texture.ImageViewport()

# save as an object property
obj["image_viewport"] = viewport_texture

# update texture
viewport_texture.refresh(True)