HotFix: fix bug spine alpha blend error

This commit is contained in:
Huabing.Xu 2013-11-19 10:15:12 +08:00
parent 4039f5c188
commit d9681150fc
1 changed files with 16 additions and 1 deletions

View File

@ -118,7 +118,6 @@ void CCSkeleton::update (float deltaTime) {
void CCSkeleton::draw () { void CCSkeleton::draw () {
CC_NODE_DRAW_SETUP(); CC_NODE_DRAW_SETUP();
GL::blendFunc(blendFunc.src, blendFunc.dst); GL::blendFunc(blendFunc.src, blendFunc.dst);
Color3B color = getColor(); Color3B color = getColor();
skeleton->r = color.r / (float)255; skeleton->r = color.r / (float)255;
@ -144,6 +143,14 @@ void CCSkeleton::draw () {
TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment); TextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
if (regionTextureAtlas != textureAtlas) { if (regionTextureAtlas != textureAtlas) {
if (textureAtlas) { if (textureAtlas) {
if(textureAtlas->getTexture() && textureAtlas->getTexture()->hasPremultipliedAlpha())
{
GL::blendFunc(BlendFunc::ALPHA_PREMULTIPLIED.src, BlendFunc::ALPHA_PREMULTIPLIED.dst);
}
else
{
GL::blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED.src, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst);
}
textureAtlas->drawQuads(); textureAtlas->drawQuads();
textureAtlas->removeAllQuads(); textureAtlas->removeAllQuads();
} }
@ -155,6 +162,14 @@ void CCSkeleton::draw () {
textureAtlas->updateQuad(&quad, textureAtlas->getTotalQuads()); textureAtlas->updateQuad(&quad, textureAtlas->getTotalQuads());
} }
if (textureAtlas) { if (textureAtlas) {
if(textureAtlas->getTexture() && textureAtlas->getTexture()->hasPremultipliedAlpha())
{
GL::blendFunc(BlendFunc::ALPHA_PREMULTIPLIED.src, BlendFunc::ALPHA_PREMULTIPLIED.dst);
}
else
{
GL::blendFunc(BlendFunc::ALPHA_NON_PREMULTIPLIED.src, BlendFunc::ALPHA_NON_PREMULTIPLIED.dst);
}
textureAtlas->drawQuads(); textureAtlas->drawQuads();
textureAtlas->removeAllQuads(); textureAtlas->removeAllQuads();
} }