Table of Contents

Class ScreenshotCapture

Namespace
Stride.CommunityToolkit.Engine
Assembly
Stride.CommunityToolkit.dll

Captures a screenshot of a running game after a set number of frames, then exits.

public static class ScreenshotCapture
Inheritance
ScreenshotCapture

Remarks

This exists so the documentation's example screenshots can be produced automatically. It is opt-in through environment variables and does nothing at all unless OutputPathVariable is set, so a game shipping against the toolkit carries one environment-variable read per Run and nothing else.

It is wired into GameExtensions.Run rather than into the scene helpers because running is the one thing every example does. All of them reach the loop through Run - including the F# and Visual Basic ports - whereas the scene helpers are each used by only a subset.

Capture is scheduled by frame, not by elapsed time. A fixed delay would photograph a different moment on every run, which matters because most examples are things falling, spinning or settling. Frame scheduling alone is still not enough: IsFixedTimeStep defaults to false, so frame N arrives after a different amount of simulated time on a fast machine than a slow one. Capture therefore forces a fixed timestep, which is what makes the output reproducible rather than merely consistent.

Fields

DefaultFrame

The frame captured when FrameVariable is not set.

public static readonly int DefaultFrame

Field Value

int

Remarks

Late enough for the first shaders to have compiled and for a scene to have settled into something worth looking at, short enough that capturing sixty examples is not an afternoon.

FrameVariable

Optional. Which frame to capture; defaults to DefaultFrame.

public const string FrameVariable = "STRIDE_TOOLKIT_CAPTURE_FRAME"

Field Value

string

OutputPathVariable

Set to a file path to enable capture. Nothing happens when it is unset.

public const string OutputPathVariable = "STRIDE_TOOLKIT_CAPTURE"

Field Value

string

Methods

TrySchedule(Game)

Schedules a capture if the environment asks for one.

public static bool TrySchedule(Game game)

Parameters

game Game

The game about to run.

Returns

bool

true if a capture was scheduled.