Open pthom opened 9 months ago
I tested it and it seems to be working for me (Windows 11, x64).
I have however now confirmed that it breaks with io.ConfigWindowsMoveFromTitleBarOnly = true
in the same way as your repeated capture. Seems fixable.
(Initially we designed/created the capture tool to work completely outside of Test Engine, which required some hoops and design choices which i think may be irrelevant today. It may be a good idea to rewrite it and embrace using test engine.)
As for one failing under Windows: which backend you are using? You my add breakpoint in imgui_app.cpp's ImGuiApp_ScreenCaptureFunc() to investigate further.
I have however now confirmed that it breaks with io.ConfigWindowsMoveFromTitleBarOnly = true in the same way as your repeated capture. Seems fixable.
Good catch! I if set io.ConfigWindowsMoveFromTitleBarOnly = false, then it works
I was getting this issue from inside HelloImGui, where io.ConfigWindowsMoveFromTitleBarOnly is false by default. I'll soon post an issue inside HelloImGui and give some details about how it is going. If you want to give me some output it would be appreciable!
Now, getting on to debug under windows
Under windows, I have found the issue: I'm using the docking branch, and this code inside app_minimal_main.cpp is the reason it fails:
#ifdef IMGUI_HAS_VIEWPORT
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
#endif
If I comment out this line, then it works! I think your implementation mentions somewhere that viewports are not handled for screen capture.
I fixed the issue with io.ConfigWindowsMoveFromTitleBarOnly
and stitching.
ImGuiCaptureFlags_StitchAll doesn't currently work with multi-viewport because the way we move the window makes it move to its own viewport whereas we try to capture from the main viewport. I however pushed changes to support capturing from secondary viewport in imgui_app (the API was already there but not supported by imgui_app), but it requires further changes in capture tool too.
I fixed the issue with io.ConfigWindowsMoveFromTitleBarOnly and stitching
I confirm that your fix works
I put a little more effort on trying to fix various things with the capture tool, but I believe the codebase is too flawed, it may be simpler to rewrite with specialized/separate function for single capture, stitched capture, video capture etc. and test support for viewport and DPI shenanigans.
It happens to all of us :-)
May be adding simple structs to store a capture and its coords such as below could help to make the API a bit simpler.
struct ImageBufferRgba
{
int Width = 0, Height = 0;
ImVector<uint8_t> Buffer;
};
struct CaptureCoords
{
ImGuiID ViewportId;
int x, int y, int w, int h; // Or maybe ImRect
};
with the added benefits that:
And the callback signature could then become:
typedef bool (ImGuiScreenCaptureFunc)(CaptureCoords coords, ImageBufferRgba* buffer, void* user_data);
However, this would probably change too much user code for those who already implemented a callback.
... and there are probably lots of other reasons for which this would not work ;-)
Sorry if my suggestion was inappropriate, esp given that ImGuiCaptureImageBuf
already exists.
FYI, I started to work on integrating imgui_test_engine into hello_imgui (which is a preliminary, before integrating into Dear ImGui Bundle).
If you are interested, I made a quick demo on how easy it can be to setup a test app here: https://github.com/pthom/hello_imgui_test_engine_demo
At the moment, the integration of imgui_test_engine is not in the main branch of HelloImGui, but in the with_imgui_test_engine branch.
I'll make sure to add some doc about its license when I release it in the main branch.
The code for integratings the test engine was quite simple to add, and is grouped in this folder.
Re-Bonjour Omar,
Sorry if I'm flooding the issues a bit today.
I'm trying the code of app_minimal, and I have an issue with screen capture and the flag ImGuiCaptureFlags_StitchAll.
Basically,
i.e. the size is correct, but it seems like the content is repeated (as if the scroll did not work). Based on the
usleep(1000)
for linux, I tried to add a sleep(1 second) during the capture, and I could see that effectively the scroll does not work.