libdonut  2.3.2
Application framework for cross-platform game development in C++20
Classes | Public Member Functions | Static Public Attributes | List of all members
donut::AtlasPacker< InitialResolution, Padding > Class Template Reference

Axis-aligned rectangle packer for expandable square texture atlases. More...

#include <donut/AtlasPacker.hpp>

Classes

struct  InsertRectangleResult
 Result of the insertRectangle() function. More...
 

Public Member Functions

InsertRectangleResult insertRectangle (std::size_t width, std::size_t height)
 Find and reserve a suitable space for a new axis-aligned rectangle to be inserted into the atlas. More...
 
std::size_t getResolution () const noexcept
 Get the current required resolution of the atlas. More...
 

Static Public Attributes

static constexpr std::size_t INITIAL_RESOLUTION = InitialResolution
 The initial resolution that was passed to the InitialResolution template parameter. More...
 
static constexpr std::size_t GROWTH_FACTOR = 2
 The factor by which the resolution of the atlas will grow when it needs to make more space for a new rectangle. More...
 
static constexpr std::size_t PADDING = Padding
 The padding that was passed to the Padding template parameter. More...
 
static constexpr float MINIMUM_ROW_HEIGHT_RATIO = 0.7f
 The minimum ratio between the height of a new rectangle and the size of an existing row in the atlas for the new rectangle to be considered large enough to deserve a space in that row. More...
 

Detailed Description

template<std::size_t InitialResolution, std::size_t Padding>
class donut::AtlasPacker< InitialResolution, Padding >

Axis-aligned rectangle packer for expandable square texture atlases.

Template Parameters
InitialResolutioninitial width of the square atlas region, in pixels.
Paddingempty space to reserve between inserted rectangles, in pixels.

Member Function Documentation

◆ insertRectangle()

template<std::size_t InitialResolution, std::size_t Padding>
InsertRectangleResult donut::AtlasPacker< InitialResolution, Padding >::insertRectangle ( std::size_t  width,
std::size_t  height 
)
inline

Find and reserve a suitable space for a new axis-aligned rectangle to be inserted into the atlas.

Parameters
widthwidth of the new rectangle, in pixels.
heightheight of the new rectangle, in pixels.
Returns
see InsertRectangleResult.
Exceptions
std::bad_allocon allocation failure.

◆ getResolution()

template<std::size_t InitialResolution, std::size_t Padding>
std::size_t donut::AtlasPacker< InitialResolution, Padding >::getResolution ( ) const
inlinenoexcept

Get the current required resolution of the atlas.

Returns
the width of the square atlas region, in pixels.

Member Data Documentation

◆ INITIAL_RESOLUTION

template<std::size_t InitialResolution, std::size_t Padding>
constexpr std::size_t donut::AtlasPacker< InitialResolution, Padding >::INITIAL_RESOLUTION = InitialResolution
staticconstexpr

The initial resolution that was passed to the InitialResolution template parameter.

◆ GROWTH_FACTOR

template<std::size_t InitialResolution, std::size_t Padding>
constexpr std::size_t donut::AtlasPacker< InitialResolution, Padding >::GROWTH_FACTOR = 2
staticconstexpr

The factor by which the resolution of the atlas will grow when it needs to make more space for a new rectangle.

◆ PADDING

template<std::size_t InitialResolution, std::size_t Padding>
constexpr std::size_t donut::AtlasPacker< InitialResolution, Padding >::PADDING = Padding
staticconstexpr

The padding that was passed to the Padding template parameter.

◆ MINIMUM_ROW_HEIGHT_RATIO

template<std::size_t InitialResolution, std::size_t Padding>
constexpr float donut::AtlasPacker< InitialResolution, Padding >::MINIMUM_ROW_HEIGHT_RATIO = 0.7f
staticconstexpr

The minimum ratio between the height of a new rectangle and the size of an existing row in the atlas for the new rectangle to be considered large enough to deserve a space in that row.


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