Skip to content

Application control

Alessandro Febretti edited this page Jul 1, 2014 · 33 revisions

module omega

Last revision: ver. 5.3-alpha3 - 17 April 2014

These functions control execution and can be used to start stop and clean scripts, and to execute deferred code.

(v5.3) setClearColor(Color c)

Sets the color used to clear the frame buffer. See Color

(v5.3) clearColor(bool enabled)

Enables or disables color buffer clearing at the beginning of each frame

(v5.3) clearDepth(bool enabled)

Enables or disables depth buffer clearing at the beginning of each frame

oexit()

Exits the application

isMaster()

Returns True if the script is executing on the master node of a cluster display system.

queueCommand(script)

Queues a script command for execution. The command will be executed during the next update cycle.

broadcastCommand(script)

For cluster systems only. When executed on the master node, it tells all the slaves (and itself) to execute the specified command. Useful to implement event handlers after some code executed only on the master node (i.e. caching of remote data). A broadcastCommand call executed on a slave node does nothing. A call on a non-cluster environment behaves like queueCommand.

Example:

	import urllib
	# On the master node, fetch an image somewhere on the internet
	if(isMaster())
		urllib.urlretrieve("http://www.digimouth.com/news/media/2011/09/google-logo.jpg", "local-image.jpg")
		# Call this when you are done
		broadcastCommand('onImageLoaded()')
	
	# This will be called on all nodes once the image is loaded. You can open the image here.
	# (Assuming use of a shared filesystem in your cluster installation)
	def onImageLoaded():
		img = loadImage("local-image.jpg")

olaunch(string commands)

Spawns a new process which executed the specified command. The command can be the name of another executable or operating system command.

orun(string scriptPath)

Runs an external script. The script is executed immediately. The script path accepts two macros:

  • OMEGA_DATA_ROOT will be substituted with the default data directory for the omegalib installation
  • OMEGA_APP_ROOT will be substituted with the application directory for the installation (set throguh CMake at build configuration time)

oclean()

Stops the current script, cleans the engine and get everything back to its initial state.

ocleanrun(script)

Like orun, but performs a cleanup first. Useful for runtime switching to a different application.

String ogetexecpath()

(v5.1) Returns the path to the current omegalib executable.

MissionControlClient getMissionControlClient()

Returns a MissionControlClient instance if this application is running a mission control client. Returns None otherwise. Applications can start a mission control client when launched with the --mc client or --mc @host:port options specified. See the and CommandLine pages for more information.

string getHostname()

Gets the name of the host running the slave instance of omegalib

bool isHostInTileSection(string host, int x, int y, int w, int h)

Returns true if the specified host owns at least a tile in the specified tile rectangle. Example:

	# Prints TRUE on hosts that are within the tile rectangle [1,1 -> 2,1]
	if(isHostInTileSection(getHostname(), 1, 1, 2, 1) print('TRUE')

setTilesEnabled(int x, int y, int w, int h, bool enabled)

Enables or disables rendering for the specified tile region. Tiles need to be part of a tile grid to be controllable with this function.

bool isEventDispatchEnabled(), setEventDispatchEnabled(bool value)

TODO

(v6.0) Quick Commands

  • addQuickCommand(string cmd, string call, int args, string description)
  • removeQuickCommand(cmd)
Clone this wiki locally