From 67ebcebd21747e6feb53c089f7d693ae2c782209 Mon Sep 17 00:00:00 2001 From: Jeremie Roy Date: Wed, 8 May 2013 19:45:58 +0200 Subject: [PATCH] add inner outline in order to avoid texture bleeding --- examples/common/cube_atlas.cpp | 12 +++++++++--- examples/common/cube_atlas.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/common/cube_atlas.cpp b/examples/common/cube_atlas.cpp index 8b0b7946a..f1ee20810 100644 --- a/examples/common/cube_atlas.cpp +++ b/examples/common/cube_atlas.cpp @@ -306,7 +306,7 @@ Atlas::~Atlas() 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) { @@ -350,13 +350,19 @@ uint16_t Atlas::addRegion(uint16_t _width, uint16_t _height, const uint8_t* _bit } AtlasRegion& region = m_regions[m_regionCount]; - region.m_x = x; - region.m_y = y; + region.m_x = x ; + region.m_y = y ; region.m_width = _width; region.m_height = _height; region.m_mask = m_layers[idx].faceRegion.m_mask; updateRegion(region, _bitmapBuffer); + + region.m_x += outline; + region.m_y += outline; + region.m_width -= (outline*2); + region.m_height -= (outline*2); + return m_regionCount++; } diff --git a/examples/common/cube_atlas.h b/examples/common/cube_atlas.h index 15734e02a..3f9812275 100644 --- a/examples/common/cube_atlas.h +++ b/examples/common/cube_atlas.h @@ -50,7 +50,7 @@ public: ~Atlas(); /// 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 void updateRegion(const AtlasRegion& _region, const uint8_t* _bitmapBuffer);