I've been playing around with someone else's code that implements the DXGI desktop duplication API and I've run into a strange issue. Here's the github link to the code I am using.
https://github.com/diederickh/screen_capture/blob/master/src/test/test_win_api_directx_research.cpp
All the code works fine up until I try to see what's in D3D11_MAPPED_SUBRESOURCE map.pData where all I get is a blank screen, specifically it's a repeating set of 0xFF000000, black at full alpha. Looking around for other solutions, I found that someone solved this problem using a while loop to check for when the frame successfully updates.
while (true)
{
hr = duplication->AcquireNextFrame(INFINITE, &frame_info, &desktop_resource);
if (hr && frame_info.LastPresentTime.QuadPart)
{
break;
}
}
However, when I run this code, the console never exits and continues to run forever. Apparently, according to frame_info.LastPresentTime.QuadPart, the frame is never updating. What could be causing this? Is there a known condition that can cause this?