Architecturally, Im generally ignorant to the broader windows c++ ecosystem. Documentationaly, the docs skew c# so its hard for me to bridge the gap sometimes.
I want to use the winrt graphics capture. OBS has a nice implementation, but it feels like a struggle to manage dependencies with cmake and they lose me on a key element.
The graphics capture item. They pipe this in somehow and I couldn't find it. It's all like c exports though. I can see it, but it's hard to follow.
This is another example and it was nice for a while, but I can't compile it on windows 11 for some reason now. I've used and modified this, but I wanted a fresh start. He's got various libraries he relies on though that he made and suddenly the compiler complains about co_await. I've tried past git hashes I know to work etc. I think there's a header that got removed from some core header but I wouldn't know how to find that.
I've never seen an example that can just return the graphics capture item. Without the picker. I wish I could just say monitor 0.
So that's fine, it's a pain, I switch to UWP. Well that sucks because it's all c# geared docs and the default app drops you in to an app with a simple button. Now I don't want or need buttons. WinRT capture is just the smoothest and most efficient and as someone who struggles with the broader ecosystem I'm just trying to make this easier on myself.
I can't call winrt::GraphicsCapturePicker(); because I think I need a dispatch queue? Either that or "I'm on the ui thread" But idk if that's correct I might be confusing another frame work. It fails with the following:
inline void check_sta_blocking_wait() noexcept
{
// Note: A blocking wait on the UI thread for an asynchronous operation can cause a deadlock.
// See https://docs.microsoft.com/windows/uwp/cpp-and-winrt-apis/concurrency#block-the-calling-thread
WINRT_ASSERT(!is_sta_thread());
}
There's not enough examples for me (and maybe just me) to string together these concepts. C# examples for file picker and the sort. I think there's one for winui3 in c++, but that just straight up didn't work. I could create windows, get the handle, but could never get the picker to open, exiting 0.
The TLDR is I need an example of how to open a picker, preferably a capturePicker, from a uwp c++ app or a desktop app, or even most preferred a console but that feels impossible.
I've made a very simple C++/WinRT UWP app which shows how to open the GraphicsCapturePicker which is used for screen caputre and get the GraphicsCaptureItem that you want.
It's a blank C++/WinRT UWP project. Most code are the auto generated when you choose the template. Here is the code.
MainPage.Xaml
MainPage.h
MainPage.cpp
Please remember to enable the Graphics Capture the capability in the manifest file.
For more information about screen capture, please refer to this document -Screen capture