| IStereoLayers
|
Module |
|
Header |
/Engine/Source/Runtime/HeadMountedDisplay/Public/StereoLayerManager.h |
Include |
#include "StereoLayerManager.h" |
template<typename LayerType>
class TStereoLayerManager : public IStereoLayers
Partial implementation of the Layer management code for the IStereoLayers interface. Implements adding, deleting and updating layers regardless of how they are rendered.
A class that wishes to implement the IStereoLayer interface can extend this class instead. The template argument should be a type for storing layer data. It should have a constructor matching the following: LayerType(const FLayerDesc& InLayerDesc); ... and implement the following function overloads: void SetLayerId(uint32 InId), uint32 GetLayerId() const, bool GetLayerDescMember(LayerType& Layer, FLayerDesc& OutLayerDesc), void SetLayerDescMember(LayerType& Layer, const FLayerDesc& Desc), and void MarkLayerTextureForUpdate(LayerType& Layer)
To perform additional bookkeeping each time individual layers are changed, you can override the following protected method: UpdateLayer(LayerType& Layer, uint32 LayerId, bool bIsValid) It is called whenever CreateLayer, DestroyLayer, SetLayerDesc and MarkTextureForUpdate are called.
Simple implementations that do not to track additional data per layer may use FLayerDesc directly. The FSimpleLayerManager subclass can be used in that case and it implements all the required glue functions listed above.
To access the layer data from your subclass, you have the following protected interface: bool GetStereoLayersDirty() Returns true if layer data have changed since the status was last cleared ForEachLayer(...) pass in a lambda to iterate through each existing layer. CopyLayers(TArray<LayerType>& OutArray, bool bMarkClean = true) Copies the layers into OutArray. WithLayer(uint32 LayerId, TFunction<void(LayerType*)> Func) Finds the layer by Id and passes it to Func or nullptr if not found. The last two methods will clear the layer dirty flag unless you pass in false as the optional final argument.
Thread safety: Updates and the two protected access methods use a critical section to ensure atomic access to the layer structures. Therefore, it is probably better to copy layers before performing time consuming operations using CopyLayers and reserve ForEachLayer for simple processing or operations where you need to know the user-facing layer id. The WithLayer method is useful if you already know the id of a layer you need to access in a thread safe manner.
Name | Description | |
---|---|---|
|
TStereoLayerManager() |
Name | Description | |
---|---|---|
|
~TStereoLayerManager() |
Name | Description | ||
---|---|---|---|
|
CopyLayers |
||
|
ForEachLayer |
||
|
GetStereoLayersDirty() |
||
|
UpdateLayer |
||
|
WithLayer |
Name | Description | ||
---|---|---|---|
|
CreateLayer ( |
Creates a new layer from a given texture resource, which is projected on top of the world as a quad. |
|
|
DestroyLayer ( |
Destroys the specified layer, stopping it from rendering over the world. |
|
|
GetAllocatedTexture ( |
Get texture reference to HMD swapchain to avoid the copy path, useful for continuous update layers |
|
|
GetLayerDesc ( |
Get the currently set layer description |
|
|
HideBackgroundLayer() |
Optional method to hide the 3D scene and only render the stereo overlays. |
|
|
IsBackgroundLayerVisible() |
Tell if the background layer is visible. |
|
|
MarkTextureForUpdate ( |
Marks this layers texture for update |
|
|
PopLayerState() |
Restores the stereo layer state from the last save state. |
|
|
PushLayerState ( |
Saves the current stereo layer state on a stack to later restore them. |
|
|
SetLayerDesc ( |
Set the a new layer description |
|
|
ShowBackgroundLayer() |
Optional method to undo the effect of hiding the 3D scene. No-op if not supported by the platform. |
|
|
SupportsLayerState() |
Returns true if the StereoLayers implementation supports saving and restoring state using Push/PopLayerState() |
|
|
UpdateSplashScreen() |
Update splash screens from current state |