- std::stringstream materialLabel;
- materialLabel << "Atlas Material - ";
- materialLabel << mAtlasList.size();
- atlasDescriptor.mMaterial = Material::New( materialLabel.str() );
- atlasDescriptor.mMaterial.SetDiffuseTexture( atlas );
- atlasDescriptor.mNextFreeBlock = 1u; // indicate next free block will be the first ( +1 )
-
- // What size do we need for this atlas' strip buffer ( assume 32bit pixel format )?
- uint32_t neededStripSize =( blockWidth > blockHeight - DOUBLE_PIXEL_PADDING ? blockWidth : blockHeight - DOUBLE_PIXEL_PADDING ) << 2;
- atlasDescriptor.mStripBuffer = new PixelBuffer[ neededStripSize ];
- memset( atlasDescriptor.mStripBuffer, 0, neededStripSize );
-
- atlasDescriptor.mHorizontalStrip = BufferImage::New( atlasDescriptor.mStripBuffer,
- blockWidth,
- SINGLE_PIXEL_PADDING,
- pixelformat );
-
- atlasDescriptor.mVerticalStrip = BufferImage::New( atlasDescriptor.mStripBuffer,
- SINGLE_PIXEL_PADDING,
- blockHeight - DOUBLE_PIXEL_PADDING,
- pixelformat );
- atlasDescriptor.mFilledPixelImage = BufferImage::New( reinterpret_cast< PixelBuffer* >( &mFilledPixel ), 1, 1, pixelformat );
- atlas.Upload( atlasDescriptor.mFilledPixelImage, 0, 0 );
+ atlasDescriptor.mTotalBlocks = ( width / blockWidth ) * ( height / blockHeight );
+ atlasDescriptor.mAvailableBlocks = atlasDescriptor.mTotalBlocks - 1u;
+
+ atlasDescriptor.mHorizontalStrip = BufferImage::New( blockWidth, SINGLE_PIXEL_PADDING, pixelformat );
+ atlasDescriptor.mVerticalStrip = BufferImage::New( SINGLE_PIXEL_PADDING, blockHeight - DOUBLE_PIXEL_PADDING, pixelformat );
+
+ memset( atlasDescriptor.mHorizontalStrip.GetBuffer(), 0, atlasDescriptor.mHorizontalStrip.GetBufferSize() );
+ memset( atlasDescriptor.mVerticalStrip.GetBuffer(), 0, atlasDescriptor.mHorizontalStrip.GetBufferSize() );
+
+ BufferImage filledPixelImage = BufferImage::New( 1u, 1u, pixelformat );
+ memset( filledPixelImage.GetBuffer(), 0xFF, filledPixelImage.GetBufferSize() );
+ atlas.Upload( filledPixelImage, 0, 0 );
+
+ Sampler sampler = Sampler::New( atlas, "sTexture" );
+ sampler.SetProperty( Sampler::Property::AFFECTS_TRANSPARENCY, true );
+ atlasDescriptor.mMaterial = Material::New( pixelformat == Pixel::L8 ? mShaderL8 : mShaderRgba );
+ atlasDescriptor.mMaterial.AddSampler( sampler );
+ atlasDescriptor.mSampler = sampler;
+ atlasDescriptor.mMaterial.SetBlendMode( BlendingMode::ON );