I’m trying to get a screen capture from an external window to show up in the game as a texture on an object. I’m coming from a Unity background where the runtime had problems with a memory buffer, so I’m trying it out on here and I’m kind of clueless. I have the code to get a capture from a window based on the process name, but I can’t figure out how to move this capture onto an object in Unreal. Here’s my code I currently have (that does anything)
void UGetWindow::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction )
{
Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
RECT rc;
HWND hwnd = FindWindow(TEXT("Notepad"), NULL); //the window can't be min
GetClientRect(hwnd, &rc);
//create
HDC hdcScreen = GetDC(NULL);
HDC hdc = CreateCompatibleDC(hdcScreen);
HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen,
rc.right - rc.left, rc.bottom - rc.top);
SelectObject(hdc, hbmp);
//Print to memory hdc
PrintWindow(hwnd, hdc, PW_CLIENTONLY);
//release
DeleteDC(hdc);
DeleteObject(hbmp);
ReleaseDC(NULL, hdcScreen);
// ...
}
You can see I’m getting the output in PrintWindow and could copy it to, say, the clipboard, but I want to instead move it to be a texture for an object. Any ideas?