-
Notifications
You must be signed in to change notification settings - Fork 53
Screen and Video Captures
omar edited this page Sep 6, 2022
·
1 revision
- Tips: try screenshots before video (simpler as video depend on FFMPEG).
- Application MUST set
test_io.ScreenCaptureFunc
to a function to capture framebuffer. Our helpers inshared/imgui_app.cpp
have capture functions implemented for OpenGL and DirectX11. - Application MUST call
ImGuiTestEngine_PostSwap(engine)
after swapping all its framebuffers. The TestEngine will then calltest_io.ScreenCaptureFunc()
as required by active capturing. - For video: Application MUST set
test_io.VideoCaptureEncoderPath
to a FFMPEG executable andtest_io.VideoCaptureEncoderParams
/test_io.GifCaptureEncoderParams
for params. - The UI (
ImGuiTestEngine_ShowTestEngineWindows()
exposes those fields as well as default templates underOptions->Screen/Video Capture
:
Two mode of operation:
- Interactive: call
ImGuiCaptureToolUI::ShowCaptureToolWindow()
or access via TestEngine UI underTools -> Capture Tool
. - Programmatic: generally via
ImGuiTestContext::CaptureXXX
functions
t = IM_REGISTER_TEST(e, "demo_tests", "capture_screenshot");
t->TestFunc = [](ImGuiTestContext* ctx)
{
ctx->SetRef("Dear ImGui Demo");
ctx->ItemOpen("Widgets"); // Open collapsing header
ctx->ItemOpenAll("Basic"); // Open tree node and all its descendant
ctx->CaptureScreenshotWindow("Dear ImGui Demo", ImGuiCaptureFlags_StitchAll | ImGuiCaptureFlags_HideMouseCursor);
};
t = IM_REGISTER_TEST(e, "demo_tests", "capture_video");
t->TestFunc = [](ImGuiTestContext* ctx)
{
ctx->SetRef("Dear ImGui Demo");
ctx->ItemCloseAll("");
ctx->MouseTeleportToPos(ctx->GetWindowByRef("")->Pos);
ImGuiCaptureArgs args;
ctx->CaptureAddWindow(&args, "Dear ImGui Demo"); // Optional: Capture single window
ctx->CaptureBeginVideo(&args);
ctx->ItemOpen("Widgets");
ctx->ItemInputValue("Basic/input text", "My first video!");
ctx->CaptureEndVideo(&args);
};