UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FTextureLayout Class Reference

#include <TextureLayout.h>

Public Member Functions

 FTextureLayout (uint32 InMinSizeX, uint32 InMinSizeY, uint32 MaxSizeX, uint32 MaxSizeY, bool bInPowerOfTwoSize=false, ETextureLayoutAspectRatio InAspect=ETextureLayoutAspectRatio::None, bool bInAlignByFour=true)
 
bool AddElement (uint32 &OutBaseX, uint32 &OutBaseY, uint32 ElementSizeX, uint32 ElementSizeY)
 
bool RemoveElement (uint32 ElementBaseX, uint32 ElementBaseY, uint32 ElementSizeX, uint32 ElementSizeY)
 
uint32 GetSizeX () const
 
uint32 GetSizeY () const
 

Detailed Description

An incremental texture space allocator. For best results, add the elements ordered descending in size.

Constructor & Destructor Documentation

◆ FTextureLayout()

FTextureLayout::FTextureLayout ( uint32  InMinSizeX,
uint32  InMinSizeY,
uint32  MaxSizeX,
uint32  MaxSizeY,
bool  bInPowerOfTwoSize = false,
ETextureLayoutAspectRatio  InAspect = ETextureLayoutAspectRatio::None,
bool  bInAlignByFour = true 
)
inline

Minimal initialization constructor.

Parameters
MinSizeX- The minimum width of the texture.
MinSizeY- The minimum height of the texture.
MaxSizeX- The maximum width of the texture.
MaxSizeY- The maximum height of the texture.
InPowerOfTwoSize- True if the texture size must be a power of two.
bInForce2To1Aspect- True if the texture size must have a 2:1 aspect.
bInAlignByFour- True if the texture size must be a multiple of 4..

Member Function Documentation

◆ AddElement()

bool FTextureLayout::AddElement ( uint32 OutBaseX,
uint32 OutBaseY,
uint32  ElementSizeX,
uint32  ElementSizeY 
)
inline

Finds a free area in the texture large enough to contain a surface with the given size. If a large enough area is found, it is marked as in use, the output parameters OutBaseX and OutBaseY are set to the coordinates of the upper left corner of the free area and the function return true. Otherwise, the function returns false and OutBaseX and OutBaseY remain uninitialized.

Parameters
OutBaseX- If the function succeeds, contains the X coordinate of the upper left corner of the free area on return.
OutBaseY- If the function succeeds, contains the Y coordinate of the upper left corner of the free area on return.
ElementSizeX- The size of the surface to allocate in horizontal pixels.
ElementSizeY- The size of the surface to allocate in vertical pixels.
Returns
True if succeeded, false otherwise.

◆ GetSizeX()

uint32 FTextureLayout::GetSizeX ( ) const
inline

Returns the minimum texture width which will contain the allocated surfaces.

◆ GetSizeY()

uint32 FTextureLayout::GetSizeY ( ) const
inline

Returns the minimum texture height which will contain the allocated surfaces.

◆ RemoveElement()

bool FTextureLayout::RemoveElement ( uint32  ElementBaseX,
uint32  ElementBaseY,
uint32  ElementSizeX,
uint32  ElementSizeY 
)
inline

Removes a previously allocated element from the layout and collapses the tree as much as possible, In order to create the largest free block possible and return the tree to its state before the element was added.

Returns
True if the element specified by the input parameters existed in the layout.

The documentation for this class was generated from the following file: