mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
Additive blending for cocos2d and cocos2dx.
This commit is contained in:
parent
e4358cf904
commit
37035c4a0f
@ -147,6 +147,7 @@
|
|||||||
_skeleton->b *= _skeleton->a;
|
_skeleton->b *= _skeleton->a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int additive = 0;
|
||||||
CCTextureAtlas* textureAtlas = 0;
|
CCTextureAtlas* textureAtlas = 0;
|
||||||
ccV3F_C4B_T2F_Quad quad;
|
ccV3F_C4B_T2F_Quad quad;
|
||||||
quad.tl.vertices.z = 0;
|
quad.tl.vertices.z = 0;
|
||||||
@ -158,15 +159,26 @@
|
|||||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
||||||
CCTextureAtlas* regionTextureAtlas = [self getTextureAtlas:attachment];
|
CCTextureAtlas* regionTextureAtlas = [self getTextureAtlas:attachment];
|
||||||
if (regionTextureAtlas != textureAtlas) {
|
|
||||||
|
if (slot->data->additiveBlending != additive) {
|
||||||
if (textureAtlas) {
|
if (textureAtlas) {
|
||||||
[textureAtlas drawQuads];
|
[textureAtlas drawQuads];
|
||||||
[textureAtlas removeAllQuads];
|
[textureAtlas removeAllQuads];
|
||||||
}
|
}
|
||||||
|
additive = !additive;
|
||||||
|
ccGLBlendFunc(_blendFunc.src, additive ? GL_ONE : _blendFunc.dst);
|
||||||
|
} else if (regionTextureAtlas != textureAtlas && textureAtlas) {
|
||||||
|
[textureAtlas drawQuads];
|
||||||
|
[textureAtlas removeAllQuads];
|
||||||
}
|
}
|
||||||
textureAtlas = regionTextureAtlas;
|
textureAtlas = regionTextureAtlas;
|
||||||
if (textureAtlas.capacity == textureAtlas.totalQuads &&
|
|
||||||
![textureAtlas resizeCapacity:textureAtlas.capacity * 2]) return;
|
if (textureAtlas.capacity == textureAtlas.totalQuads) {
|
||||||
|
[textureAtlas drawQuads];
|
||||||
|
[textureAtlas removeAllQuads];
|
||||||
|
if (![textureAtlas resizeCapacity:textureAtlas.capacity * 2]) return;
|
||||||
|
}
|
||||||
|
|
||||||
RegionAttachment_updateQuad(attachment, slot, &quad, _premultipliedAlpha);
|
RegionAttachment_updateQuad(attachment, slot, &quad, _premultipliedAlpha);
|
||||||
[textureAtlas updateQuad:&quad atIndex:textureAtlas.totalQuads];
|
[textureAtlas updateQuad:&quad atIndex:textureAtlas.totalQuads];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,6 +140,7 @@ void CCSkeleton::draw () {
|
|||||||
skeleton->b *= skeleton->a;
|
skeleton->b *= skeleton->a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int additive = 0;
|
||||||
CCTextureAtlas* textureAtlas = 0;
|
CCTextureAtlas* textureAtlas = 0;
|
||||||
ccV3F_C4B_T2F_Quad quad;
|
ccV3F_C4B_T2F_Quad quad;
|
||||||
quad.tl.vertices.z = 0;
|
quad.tl.vertices.z = 0;
|
||||||
@ -150,13 +151,18 @@ void CCSkeleton::draw () {
|
|||||||
Slot* slot = skeleton->drawOrder[i];
|
Slot* slot = skeleton->drawOrder[i];
|
||||||
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
if (!slot->attachment || slot->attachment->type != ATTACHMENT_REGION) continue;
|
||||||
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
RegionAttachment* attachment = (RegionAttachment*)slot->attachment;
|
||||||
|
|
||||||
CCTextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
|
CCTextureAtlas* regionTextureAtlas = getTextureAtlas(attachment);
|
||||||
if (regionTextureAtlas != textureAtlas) {
|
|
||||||
|
if (slot->data->additiveBlending != additive) {
|
||||||
if (textureAtlas) {
|
if (textureAtlas) {
|
||||||
textureAtlas->drawQuads();
|
textureAtlas->drawQuads();
|
||||||
textureAtlas->removeAllQuads();
|
textureAtlas->removeAllQuads();
|
||||||
}
|
}
|
||||||
|
additive = !additive;
|
||||||
|
ccGLBlendFunc(blendFunc.src, additive ? GL_ONE : blendFunc.dst);
|
||||||
|
} else if (regionTextureAtlas != textureAtlas && textureAtlas) {
|
||||||
|
textureAtlas->drawQuads();
|
||||||
|
textureAtlas->removeAllQuads();
|
||||||
}
|
}
|
||||||
textureAtlas = regionTextureAtlas;
|
textureAtlas = regionTextureAtlas;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user