190191
我用一片内存重新创建texture,颜色值全填成0x000000FF(GL_RGBA),alpha为0,理论上应该整张纹理
全透明才对,为什么看到的效果还带有一定的alpha效果呢?请看下图的代码和效果图!
void test_glTexSubImage2D(CCSprite * lpSpriteNode)
{
do
{
CCTexture2D * thisTexture = lpSpriteNode->getTexture();
CC_BREAK_IF(thisTexture->getPixelFormat() != kCCTexture2DPixelFormat_RGBA8888);
CCSize tagSize = CCSizeMake(thisTexture->getPixelsWide(), thisTexture->getPixelsHigh());
int dwColorMax = tagSize.width * tagSize.height;
ccColor4B * lpTmpBuffer = new ccColor4B;
CC_BREAK_IF(lpTmpBuffer == NULL);
ccColor4B * thisColor = lpTmpBuffer;
for(int i = 0; i < dwColorMax; ++i, ++thisColor)
{
thisColor->r = 0xFF;
thisColor->g = 0x0;
thisColor->b = 0x0;
thisColor->a = 0x0;
}
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
glBindTexture(GL_TEXTURE_2D, thisTexture->getName());
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, tagSize.width, tagSize.height, GL_RGBA, GL_UNSIGNED_BYTE, lpTmpBuffer);
CC_SAFE_DELETE(lpTmpBuffer);
}while(0);
}