Skip to content

Capture ImGui in screenshots#7236

Open
MjnMixael wants to merge 4 commits intoscp-fs2open:masterfrom
MjnMixael:fix_imgui_lab_screenshots
Open

Capture ImGui in screenshots#7236
MjnMixael wants to merge 4 commits intoscp-fs2open:masterfrom
MjnMixael:fix_imgui_lab_screenshots

Conversation

@MjnMixael
Copy link
Contributor

@MjnMixael MjnMixael commented Feb 17, 2026

Fixes #7102

I'm not a graphics coder by any stretch so this one took some research. My reasoning is in the code comments. Open to feedback, of course.

I tested and got successful screenshots from the following scenarios in both Windowed and Full-Screen modes:

Retail UI states
ImGui states
Mainhall states
Mission states
Librocket states

@wookieejedi wookieejedi added the enhancement A new feature or upgrade of an existing feature to add additional functionality. label Feb 25, 2026
@wookieejedi
Copy link
Member

Only a handful of new code lines, nice! Alas I'm once again going to tag @BMagnu :D

Copy link
Member

@BMagnu BMagnu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the reasoning here is correct, this is nevertheless a problem.
The reason we switched this in the first place is twofold:
When rendering to window_res, you potentially lose a lot of resolution from window-res to backbuffer in some situations like VR, so screenshots really should read from our custom backbuffer.
Furthermore, and more critically, in newer versions of SDL, reading from GL_FRONT on framebuffer 0 outright does not work.
This'll cause all screenshots to go black on affected platforms, drivers, SDL versions, whatever, which is the reason we've been default-enabling window-res on all platforms these days.

As such, the proper fix would be to, on screenshot input, queue an event that triggers the screenshot logic at the end of a frame rather than at that specific moment.

@MjnMixael
Copy link
Contributor Author

While the reasoning here is correct, this is nevertheless a problem. The reason we switched this in the first place is twofold: When rendering to window_res, you potentially lose a lot of resolution from window-res to backbuffer in some situations like VR, so screenshots really should read from our custom backbuffer. Furthermore, and more critically, in newer versions of SDL, reading from GL_FRONT on framebuffer 0 outright does not work. This'll cause all screenshots to go black on affected platforms, drivers, SDL versions, whatever, which is the reason we've been default-enabling window-res on all platforms these days.

As such, the proper fix would be to, on screenshot input, queue an event that triggers the screenshot logic at the end of a frame rather than at that specific moment.

Ah that makes a lot of sense actually. Ok then this is even more simple. I have reverted the previous changes and reworked the screenshot system to a request -> fulfill setup. Instead of dumping the frame immediately when the key is detected, the request is stored and processed at the end of the frame. This also works in the same set of tests I did before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A new feature or upgrade of an existing feature to add additional functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImgUi elements are not saved to screenshots

3 participants