mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-27 04:01:24 +08:00
Support premultiplied alpha.
This commit is contained in:
parent
0784725106
commit
1200d549bb
@ -12,6 +12,7 @@ public class SkeletonRenderer {
|
|||||||
public void draw (SpriteBatch batch, Skeleton skeleton) {
|
public void draw (SpriteBatch batch, Skeleton skeleton) {
|
||||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||||
boolean additive = false;
|
boolean additive = false;
|
||||||
|
int srcFunc = batch.getBlendSrcFunc();
|
||||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||||
Slot slot = drawOrder.get(i);
|
Slot slot = drawOrder.get(i);
|
||||||
Attachment attachment = slot.attachment;
|
Attachment attachment = slot.attachment;
|
||||||
@ -22,13 +23,13 @@ public class SkeletonRenderer {
|
|||||||
if (slot.data.getAdditiveBlending() != additive) {
|
if (slot.data.getAdditiveBlending() != additive) {
|
||||||
additive = !additive;
|
additive = !additive;
|
||||||
if (additive)
|
if (additive)
|
||||||
batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
batch.setBlendFunction(srcFunc, GL11.GL_ONE);
|
||||||
else
|
else
|
||||||
batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
batch.setBlendFunction(srcFunc, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, vertices.length);
|
batch.draw(regionAttachment.getRegion().getTexture(), vertices, 0, vertices.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (additive) batch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
if (additive) batch.setBlendFunction(srcFunc, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user