Last Updated
This page explains how to get the image being displayed on the Spatial Reality Display. For an example of how to use the captured image, please refer to the Second Window sample.
Prerequisites
- Have the Spatial Reality Display Settings application installed on your computer (see Setup Spatial Reality Display Settings)
- Have the Epic Games Launcher, Unreal Engine, and Visual Studio installed.
- Have C++ with Unreal Engine set up.
How to get the composite image
By binding a function to the 'OnSpatial Reality DisplayRenderTextureCompletedDelegate' multi-cast delegate defined in the SRDisplayPlugin, you can obtain the composite image being rendered on the Spatial Reality Display.
-
Prepare the function to bind to 'OnSpatial Reality DisplayRenderTextureCompletedDelegate'. Define a function with 'FRHICommandListImmediate&' as its first argument and 'FTextureRHIRef' as its second argument.
Note
If you are using Unreal Engine 4.27, use 'FTexture2DRHIRef' for the second argument.
void RenderingSRDisplay2DWindow(FRHICommandListImmediate& RHICmdList, FTextureRHIRef SrcTexture);
- Get 'OnSpatial Reality DisplayRenderTextureCompletedDelegate' from 'FSRDisplaySystem' and bind the function defined in the previous step to it. For more information on how to bind a function to a delegate, see Multicast Delegate. In this example, we use 'AddRaw()'.
srdisplay_module::FSRDisplaySystem* SRDisplaySystem = USRDisplayFunctionLibrary::GetSRDisplaySystem(); FOnSpatial Reality DisplayRenderTextureCompletedDelegate& OnSpatial Reality DisplayRenderTextureCompletedDelegate = SRDisplaySystem->GetSpatial Reality DisplayRenderTextureCompletedDelegate(); OnSpatial Reality DisplayRenderTextureCompletedDelegate.AddRaw(FSample2DWindow::GetPlayWindow(), &FSample2DWindow::RenderingSRDisplay2DWindow);
- When an image is rendered on the Spatial Reality Display, the function(s) bound to 'OnSpatial Reality DisplayRenderTextureCompletedDelegate' will be called. The second argument of the function holds the texture of the composite image being rendered.