VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Static Public Attributes | Protected Attributes
makVrv::DtTextureAtlas Class Reference

Packs bitmaps into a series of 2048×2048 RGBA atlas pages.

Slots are filled left-to-right, top-to-bottom within each page. When the current page is full a new AtlasPage is appended automatically.

Client code looks up an existing slot by key via find() and packs new bitmaps via pack(). The returned DtAtlasSlot contains a non-owning DtTextureInterface* into the atlas page plus UV coordinates for use with DtQuadProxyInterface::setTextureParameters().

Using an atlas amortises GPU texture binding cost – a batch of quads that all reference the same atlas page generates a single bind per page rather than one per symbol.

Note
All slots on a page share the same DtTextureInterface pointer. Callers must not delete that pointer.

Classes

struct  AtlasPage
 

Public Member Functions

 DtTextureAtlas (DtDe &de, int slotWidth, int slotHeight)
 
virtual ~DtTextureAtlas ()
 
DtAtlasSlot pack (const std::string &key, const uint8_t *rgba, int srcWidth=-1, int srcHeight=-1)
 
const DtAtlasSlot * find (const std::string &key) const
 
void overwrite (const std::string &key, const uint8_t *rgba, int srcWidth=-1, int srcHeight=-1)
 
bool readSlot (const DtAtlasSlot &slot, std::vector< uint8_t > &rgba, int &widthOut, int &heightOut) const
 
void clear ()
 
const std::unordered_map
< std::string, DtAtlasSlot > & 
slotIndex () const
 
int slotHeight () const
 
int slotWidth () const
 
 DtTextureAtlas (const DtTextureAtlas &)=delete
 
DtTextureAtlas & operator= (const DtTextureAtlas &)=delete
 
 DtTextureAtlas (DtTextureAtlas &&)=default
 
DtTextureAtlas & operator= (DtTextureAtlas &&)=default
 

Static Public Attributes

static constexpr int theAtlasSize = 2048
 

Protected Attributes

DtDe & myDe
 
int mySlotWidth
 
int mySlotHeight
 
std::vector< AtlasPage > myPages
 
std::unordered_map
< std::string, DtAtlasSlot > 
mySlotIndex
 

Constructor & Destructor Documentation

makVrv::DtTextureAtlas::DtTextureAtlas ( DtDe &  de,
int  slotWidth,
int  slotHeight 
)

Construct an atlas for symbols of the given slot dimensions.

Parameters
deEngine context; the atlas holds a non-owning reference.
slotWidthWidth of one symbol slot in pixels.
slotHeightHeight of one symbol slot in pixels.
makVrv::DtTextureAtlas::DtTextureAtlas ( const DtTextureAtlas &  )
delete

Not allowed – slot dimensions are required.

makVrv::DtTextureAtlas::DtTextureAtlas ( DtTextureAtlas &&  )
default

Not allowed – slot dimensions are required.

virtual makVrv::DtTextureAtlas::~DtTextureAtlas ( )
virtual

Member Function Documentation

DtTextureAtlas& makVrv::DtTextureAtlas::operator= ( const DtTextureAtlas &  )
delete

Not allowed – slot dimensions are required.

DtTextureAtlas& makVrv::DtTextureAtlas::operator= ( DtTextureAtlas &&  )
default

Not allowed – slot dimensions are required.

DtAtlasSlot makVrv::DtTextureAtlas::pack ( const std::string &  key,
const uint8_t *  rgba,
int  srcWidth = -1,
int  srcHeight = -1 
)

Pack a new symbol into the atlas and return its slot.

If key already exists the existing slot is returned without re-packing.

Parameters
keyUnique identifier for this symbol (SIDC virtual key).
rgbaPointer to srcWidth * srcHeight * 4 bytes of RGBA data (or slotWidth * slotHeight * 4 bytes when defaults are used).
srcWidthActual pixel width of the source buffer. Pass -1 (default) to use the atlas slot width. Values larger than the slot are clamped to the slot size. The UV coordinates returned address only the content region.
srcHeightActual pixel height of the source buffer. Pass -1 (default) to use the atlas slot height. Values larger than the slot are clamped to the slot size. The UV coordinates returned address only the content region.
Returns
A copy of the packed slot (non-owning texture pointer into the atlas).
const DtAtlasSlot* makVrv::DtTextureAtlas::find ( const std::string &  key) const

Look up an already-packed slot by key.

Parameters
keyUnique identifier previously passed to pack().
Returns
Non-owning pointer to the slot, or nullptr if the key is absent.
void makVrv::DtTextureAtlas::overwrite ( const std::string &  key,
const uint8_t *  rgba,
int  srcWidth = -1,
int  srcHeight = -1 
)

Overwrite an existing slot with new pixel data and re-upload the page texture.

The key must already exist in the atlas (i.e. pack() was called previously). The UV coordinates and texture pointer are unchanged – callers holding a DtAtlasSlot snapshot remain valid. No-op if the key does not exist.

Parameters
keyKey that was previously passed to pack().
rgbaPointer to srcWidth * srcHeight * 4 bytes of new RGBA data (or slotWidth * slotHeight * 4 bytes when defaults are used).
srcWidthActual pixel width of the source buffer. Pass -1 (default) to use the atlas slot width. Values larger than the slot are clamped to the slot size. UV coordinates are NOT updated.
srcHeightActual pixel height of the source buffer. Pass -1 (default) to use the atlas slot height. Values larger than the slot are clamped to the slot size. UV coordinates are NOT updated.
bool makVrv::DtTextureAtlas::readSlot ( const DtAtlasSlot &  slot,
std::vector< uint8_t > &  rgba,
int &  widthOut,
int &  heightOut 
) const

Copy the RGBA pixels for a slot into rgba out-buffer.

Locates the slot by matching texture pointer across all pages, then copies the sub-rect identified by the given UV coordinates.

Parameters
slotThe atlas slot whose pixels should be read.
rgbaFilled with slotWidth * slotHeight * 4 bytes of RGBA data.
widthOutSet to the per-slot width in pixels.
heightOutSet to the per-slot height in pixels.
Returns
true if the page was found and pixels were copied; false otherwise.
void makVrv::DtTextureAtlas::clear ( )

Clear all packed symbols and re-upload blank (zeroed) page textures.

After this call find() returns nullptr for every key and pack() starts fresh.

const std::unordered_map<std::string, DtAtlasSlot>& makVrv::DtTextureAtlas::slotIndex ( ) const

Read-only access to the full slot map for iteration.

Returns
Reference to the internal map from packing key to DtAtlasSlot.
int makVrv::DtTextureAtlas::slotHeight ( ) const
inline

Return the individual slot height in pixels.

int makVrv::DtTextureAtlas::slotWidth ( ) const
inline

Return the individual slot width in pixels.

Member Data Documentation

constexpr int makVrv::DtTextureAtlas::theAtlasSize = 2048
static

Width and height of each atlas page in pixels.

DtDe& makVrv::DtTextureAtlas::myDe
protected

Engine context; not owned.

int makVrv::DtTextureAtlas::mySlotWidth
protected

Width of each symbol slot in pixels.

int makVrv::DtTextureAtlas::mySlotHeight
protected

Height of each symbol slot in pixels.

std::vector<AtlasPage> makVrv::DtTextureAtlas::myPages
protected

All atlas pages, in allocation order.

std::unordered_map<std::string, DtAtlasSlot> makVrv::DtTextureAtlas::mySlotIndex
protected

Maps packing key to DtAtlasSlot for O(1) lookup.


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

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)