Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gfx::Atlas Class Reference

#include <cube_atlas.h>

Classes

struct  PackedLayer
 

Public Member Functions

 Atlas (uint16_t _textureSize, uint16_t _maxRegionsCount=4096)
 
 Atlas (uint16_t _textureSize, const uint8_t *_textureBuffer, uint16_t _regionCount, const uint8_t *_regionBuffer, uint16_t _maxRegionsCount=4096)
 
 ~Atlas ()
 
uint16_t addRegion (uint16_t _width, uint16_t _height, const uint8_t *_bitmapBuffer, AtlasRegion::Type _type=AtlasRegion::TYPE_BGRA8, uint16_t outline=0)
 add a region to the atlas, and copy the content of mem to the underlying texture
 
void updateRegion (const AtlasRegion &_region, const uint8_t *_bitmapBuffer)
 update a preallocated region
 
void packUV (uint16_t _regionHandle, uint8_t *_vertexBuffer, uint32_t _offset, uint32_t _stride) const
 
void packUV (const AtlasRegion &_region, uint8_t *_vertexBuffer, uint32_t _offset, uint32_t _stride) const
 
void packFaceLayerUV (uint32_t _idx, uint8_t *_vertexBuffer, uint32_t _offset, uint32_t _stride) const
 Same as packUV but pack a whole face of the atlas cube, mostly used for debugging and visualizing atlas.
 
bgfx::TextureHandle getTextureHandle () const
 return the TextureHandle (cube) of the atlas
 
const AtlasRegiongetRegion (uint16_t _handle) const
 
uint16_t getTextureSize () const
 retrieve the size of side of a texture in pixels
 
uint16_t getRegionCount () const
 retrieve the usage ratio of the atlas
 
const AtlasRegiongetRegionBuffer () const
 retrieve a pointer to the region buffer (in order to serialize it)
 
uint32_t getTextureBufferSize () const
 retrieve the byte size of the texture
 
const uint8_t * getTextureBuffer () const
 retrieve the mirrored texture buffer (to serialize it)
 

Detailed Description

Definition at line 55 of file cube_atlas.h.

Constructor & Destructor Documentation

◆ Atlas() [1/2]

gfx::Atlas::Atlas ( uint16_t _textureSize,
uint16_t _maxRegionsCount = 4096 )

create an empty dynamic atlas (region can be updated and added)

Parameters
textureSizean atlas creates a texture cube of 6 faces with size equal to (textureSize*textureSize * sizeof(RGBA) )
maxRegionCountmaximum number of region allowed in the atlas

Definition at line 246 of file cube_atlas.cpp.

◆ Atlas() [2/2]

gfx::Atlas::Atlas ( uint16_t _textureSize,
const uint8_t * _textureBuffer,
uint16_t _regionCount,
const uint8_t * _regionBuffer,
uint16_t _maxRegionsCount = 4096 )

initialize a static atlas with serialized data (region can be updated but not added)

Parameters
textureSizean atlas creates a texture cube of 6 faces with size equal to (textureSize*textureSize * sizeof(RGBA) )
textureBufferbuffer of size 6*textureSize*textureSize*sizeof(uint32_t) (will be copied)
regionCountnumber of region in the Atlas
regionBufferbuffer containing the region (will be copied)
maxRegionCountmaximum number of region allowed in the atlas

Definition at line 271 of file cube_atlas.cpp.

◆ ~Atlas()

gfx::Atlas::~Atlas ( )

Definition at line 303 of file cube_atlas.cpp.

Member Function Documentation

◆ addRegion()

uint16_t gfx::Atlas::addRegion ( uint16_t _width,
uint16_t _height,
const uint8_t * _bitmapBuffer,
AtlasRegion::Type _type = AtlasRegion::TYPE_BGRA8,
uint16_t outline = 0 )

add a region to the atlas, and copy the content of mem to the underlying texture

Definition at line 312 of file cube_atlas.cpp.

◆ getRegion()

const AtlasRegion & gfx::Atlas::getRegion ( uint16_t _handle) const
inline

Definition at line 112 of file cube_atlas.h.

◆ getRegionBuffer()

const AtlasRegion * gfx::Atlas::getRegionBuffer ( ) const
inline

retrieve a pointer to the region buffer (in order to serialize it)

Definition at line 133 of file cube_atlas.h.

◆ getRegionCount()

uint16_t gfx::Atlas::getRegionCount ( ) const
inline

retrieve the usage ratio of the atlas

retrieve the numbers of region in the atlas

Definition at line 127 of file cube_atlas.h.

◆ getTextureBuffer()

const uint8_t * gfx::Atlas::getTextureBuffer ( ) const
inline

retrieve the mirrored texture buffer (to serialize it)

Definition at line 145 of file cube_atlas.h.

◆ getTextureBufferSize()

uint32_t gfx::Atlas::getTextureBufferSize ( ) const
inline

retrieve the byte size of the texture

Definition at line 139 of file cube_atlas.h.

◆ getTextureHandle()

bgfx::TextureHandle gfx::Atlas::getTextureHandle ( ) const
inline

return the TextureHandle (cube) of the atlas

Definition at line 106 of file cube_atlas.h.

◆ getTextureSize()

uint16_t gfx::Atlas::getTextureSize ( ) const
inline

retrieve the size of side of a texture in pixels

Definition at line 118 of file cube_atlas.h.

◆ packFaceLayerUV()

void gfx::Atlas::packFaceLayerUV ( uint32_t _idx,
uint8_t * _vertexBuffer,
uint32_t _offset,
uint32_t _stride ) const

Same as packUV but pack a whole face of the atlas cube, mostly used for debugging and visualizing atlas.

Definition at line 435 of file cube_atlas.cpp.

◆ packUV() [1/2]

void gfx::Atlas::packUV ( const AtlasRegion & _region,
uint8_t * _vertexBuffer,
uint32_t _offset,
uint32_t _stride ) const

Definition at line 455 of file cube_atlas.cpp.

◆ packUV() [2/2]

void gfx::Atlas::packUV ( uint16_t _regionHandle,
uint8_t * _vertexBuffer,
uint32_t _offset,
uint32_t _stride ) const

Pack the UV coordinates of the four corners of a region to a vertex buffer using the supplied vertex format. v0 – v3 | | encoded in that order: v0,v1,v2,v3 v1 – v2

Remarks
the UV are four signed short normalized components.
the x,y,z components encode cube uv coordinates. The w component encode the color channel if any.
Parameters
handlehandle to the region we are interested in
vertexBufferaddress of the first vertex we want to update. Must be valid up to vertexBuffer + offset + 3*stride + 4*sizeof(int16_t), which means the buffer must contains at least 4 vertex includind the first.
offsetbyte offset to the first uv coordinate of the vertex in the buffer
stridestride between tho UV coordinates, usually size of a Vertex.

Definition at line 440 of file cube_atlas.cpp.

◆ updateRegion()

void gfx::Atlas::updateRegion ( const AtlasRegion & _region,
const uint8_t * _bitmapBuffer )

update a preallocated region

Definition at line 381 of file cube_atlas.cpp.


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