This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Core Library
Containers
Engine Classes
Node-Related Classes
Rendering-Related Classes
Physics-Related Classes
Bounds-Related Classes
GUI-Related Classes
Controls-Related Classes
Pathfinding-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Current Viewport Grabbing with AppGrabber Plugin

The AppGrabber plugin takes a snapshot of the current viewport each frame. Each snapshot is put in the internal Image and can be obtained via the engine.grabber.getImage() function. Then you can use this snapshot for any purpose: for recording a video, for streaming data to broadcasting applications and so on.

The AppGrabber enables to specify a resolution of the grabbed snapshot (up to 4K), independently on the current window resolution. To set the required output resolution, you should specify additional options on the application start-up. Also the plugin enables grabbing the current viewport with or without the main GUI of the application.

Usage Example

To get a snapshot of the viewport in the current frame and then save it to a file, call the engine.grabber.getImage() function in the world script update() function:

Source code(UnigineScript)
#ifdef HAS_APP_GRABBER
int update() {
	
	// grab the viewport in the current frame
	Image image = engine.grabber.getImage();
	// save the grabbed image to a file
	if(image != NULL) image.save("grabber.png");
	
	return 1;
}

int init() {
	
	// add nodes to the scene here
	
	return 1;
}
#endif
When you quit the world, the grabber.dds file will contain the snapshot of the viewport in the last frame.

See Also

  • engine.grabber Functions
  • A data/samples/plugins/app_grabber_00 sample that demonstrates how to get snapshots of the viewport and save them asynchronously.

Launching AppGrabber

To use this plugin, specify the extern_plugin command-line option together with the required start-up options on the application start-up, for example:

Shell commands
main_x86d -data_path "../" -extern_plugin AppGrabber

AppGrabber Options

The following CLI options can be specified on the application start-up:

  • grabber_width - width of the grabbed snapshot.
  • grabber_height - height of the grabbed snapshot.
  • grabber_gui - value indicating whether the main GUI should be grabbed or not:
    • 1 - the main GUI of the application will be grabbed.
    • 0 - the main GUI won't be grabbed (default).

For example, to grab the current viewport together with the main GUI, you should specify the following in the command-line:

Shell commands
main_x86d -data_path "../" -extern_plugin AppGrabber -grabber_gui 1
The following image will be grabbed in the result:

Streaming Data with AppGrabber

The AppGrabber plugin can be used for streaming data to a broadcasting application.

The broadcasting application is usually implemented by using interfaces (APIs) that are provided by a developer SDK of a capture and playback card (DeckLink, for example). This application receives a video stream and processes it. For example, it can receive different video streams from different sources and mix them.

To send a video stream from the engine to such application, you can use one of the following ways:

  • Export all the required functions from the broadcasting application to UnigineScript and send an image grabbed by AppGrabber to this functions each frame.
  • Directly modify the source code of the AppGrabber plugin in order to use it as a base for the broadcasting application.
Last update: 2017-07-03
Build: ()