Graphics::CaptureScreenshot Function

Captures a screenshot of the game.

Syntax

array<uint8>@ Graphics::CaptureScreenshot(
vec2&inout size
)

Parameters

vec2&inout size
The size of the screenshot. If the size is equal to (0, 0), the size of the game window will be used. After calling, the parameter will contain the final size of the captured screenshot.

Return value

array<uint8>@
The pixel data of the screenshot. The data is in BGRA format, with 8 bits per channel (0 - 255). Pixels go from top to bottom, left to right. This means that the first pixel in the array is the top-left pixel of the screenshot. The size of the array will be equal to size.x * size.y * 4 if the call was successful.

Remarks

Screenshots can be captured exclusively in the Render() function callback. Calling the function outside of the callback will throw an exception. Because Angelscript execution happens before rendering ImGui UI provided by TMInterface and other plugins, the screenshot will not contain any UI elements.

If a size is specified, the texture will be scaled to the specified size, even if the aspect ratio is different.