6#ifndef CUBE_ATLAS_H_HEADER_GUARD
7#define CUBE_ATLAS_H_HEADER_GUARD
36 return (
Type)((
mask >> 0) & 0x0000000F);
41 return (
mask >> 4) & 0x0000000F;
46 return (
mask >> 8) & 0x0000000F;
49 void setMask(
Type _type, uint32_t _faceIndex, uint32_t _componentIndex)
51 mask = (_componentIndex << 8) + (_faceIndex << 4) + (uint32_t)_type;
62 Atlas(uint16_t _textureSize, uint16_t _maxRegionsCount = 4096);
71 Atlas(uint16_t _textureSize,
72 const uint8_t* _textureBuffer,
73 uint16_t _regionCount,
74 const uint8_t* _regionBuffer,
75 uint16_t _maxRegionsCount = 4096);
81 const uint8_t* _bitmapBuffer,
83 uint16_t outline = 0);
99 void packUV(uint16_t _regionHandle, uint8_t* _vertexBuffer, uint32_t _offset, uint32_t _stride)
const;
100 void packUV(
const AtlasRegion& _region, uint8_t* _vertexBuffer, uint32_t _offset, uint32_t _stride)
const;
103 void packFaceLayerUV(uint32_t _idx, uint8_t* _vertexBuffer, uint32_t _offset, uint32_t _stride)
const;
108 return m_textureHandle;
114 return m_regions[_handle];
120 return m_textureSize;
129 return m_regionCount;
141 return 6 * m_textureSize * m_textureSize * 4;
147 return m_textureBuffer;
152 PackedLayer* m_layers;
154 uint8_t* m_textureBuffer;
156 uint32_t m_usedLayers;
157 uint32_t m_usedFaces;
159 bgfx::TextureHandle m_textureHandle;
160 uint16_t m_textureSize;
163 uint16_t m_regionCount;
164 uint16_t m_maxRegionCount;
void updateRegion(const AtlasRegion &_region, const uint8_t *_bitmapBuffer)
update a preallocated region
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
const AtlasRegion & getRegion(uint16_t _handle) const
uint32_t getTextureBufferSize() const
retrieve the byte size of the texture
uint16_t getRegionCount() const
retrieve the usage ratio of the atlas
const AtlasRegion * getRegionBuffer() const
retrieve a pointer to the region buffer (in order to serialize it)
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 atl...
void packUV(uint16_t _regionHandle, uint8_t *_vertexBuffer, uint32_t _offset, uint32_t _stride) const
uint16_t getTextureSize() const
retrieve the size of side of a texture in pixels
Atlas(uint16_t _textureSize, uint16_t _maxRegionsCount=4096)
bgfx::TextureHandle getTextureHandle() const
return the TextureHandle (cube) of the atlas
const uint8_t * getTextureBuffer() const
retrieve the mirrored texture buffer (to serialize it)
void setMask(Type _type, uint32_t _faceIndex, uint32_t _componentIndex)
uint32_t getFaceIndex() const
uint32_t getComponentIndex() const