基于UDP 组播,实时传输UE4 图像
UE4 图像获取方式:
1.通过OnBackBufferReadyToPresent广播获取,具体实现原理可查看PixelStreamingPlugin官方插件源码,关键代码如下:
void ACaptureGameMode::beginCapture()
{
if (FSlateApplication::IsInitialized())
{
m_OnBackBufferReadyToPresent.Reset();
m_OnBackBufferReadyToPresent = FSlateApplication::Get().GetRenderer()->OnBackBufferReadyToPresent().AddUObject(this, &ACaptureGameMode::OnBackBufferReady_RenderThread);
}
}
void ACaptureGameMode::OnBackBufferReady_RenderThread(SWindow& SlateWindow, const FTexture2DRHIRef& BackBuffer)
{
check(IsInRenderingThread());
m_mutex.Lock();
m_begin = false;
FTexture2DRHIRef GameBuffer = BackBuffer;
FRHICommandListImmediate& RHICmdList =
FRHICommandListExecutor::GetImmediateCommandList();
FIntRect Rect(0, 0, GameBuffer->GetSizeX(), GameBuffer->GetSizeY());
TArray<FColor&
|