add inner outline in order to avoid texture bleeding

This commit is contained in:
Jeremie Roy 2013-05-08 19:45:58 +02:00
parent 88e6ce0a33
commit 67ebcebd21
2 changed files with 10 additions and 4 deletions

View File

@ -306,7 +306,7 @@ Atlas::~Atlas()
delete[] m_textureBuffer; delete[] m_textureBuffer;
} }
uint16_t Atlas::addRegion(uint16_t _width, uint16_t _height, const uint8_t* _bitmapBuffer, AtlasRegion::Type _type) uint16_t Atlas::addRegion(uint16_t _width, uint16_t _height, const uint8_t* _bitmapBuffer, AtlasRegion::Type _type, uint16_t outline)
{ {
if (m_regionCount >= m_maxRegionCount) if (m_regionCount >= m_maxRegionCount)
{ {
@ -350,13 +350,19 @@ uint16_t Atlas::addRegion(uint16_t _width, uint16_t _height, const uint8_t* _bit
} }
AtlasRegion& region = m_regions[m_regionCount]; AtlasRegion& region = m_regions[m_regionCount];
region.m_x = x; region.m_x = x ;
region.m_y = y; region.m_y = y ;
region.m_width = _width; region.m_width = _width;
region.m_height = _height; region.m_height = _height;
region.m_mask = m_layers[idx].faceRegion.m_mask; region.m_mask = m_layers[idx].faceRegion.m_mask;
updateRegion(region, _bitmapBuffer); updateRegion(region, _bitmapBuffer);
region.m_x += outline;
region.m_y += outline;
region.m_width -= (outline*2);
region.m_height -= (outline*2);
return m_regionCount++; return m_regionCount++;
} }

View File

@ -50,7 +50,7 @@ public:
~Atlas(); ~Atlas();
/// add a region to the atlas, and copy the content of mem to the underlying texture /// add a region to the atlas, and copy the content of mem to the underlying texture
uint16_t addRegion(uint16_t _width, uint16_t _height, const uint8_t* _bitmapBuffer, AtlasRegion::Type _type = AtlasRegion::TYPE_BGRA8); uint16_t addRegion(uint16_t _width, uint16_t _height, const uint8_t* _bitmapBuffer, AtlasRegion::Type _type = AtlasRegion::TYPE_BGRA8, uint16_t outline = 0);
/// update a preallocated region /// update a preallocated region
void updateRegion(const AtlasRegion& _region, const uint8_t* _bitmapBuffer); void updateRegion(const AtlasRegion& _region, const uint8_t* _bitmapBuffer);