diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/BlendMode.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/BlendMode.java index 2ac8580b5..b600776cd 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/BlendMode.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/BlendMode.java @@ -29,30 +29,28 @@ package com.esotericsoftware.spine; -import com.badlogic.gdx.graphics.GL20; +import static com.badlogic.gdx.graphics.GL20.*; + +import com.badlogic.gdx.graphics.g2d.Batch; /** Determines how images are blended with existing pixels when drawn. */ public enum BlendMode { - normal(GL20.GL_SRC_ALPHA, GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA), // - additive(GL20.GL_SRC_ALPHA, GL20.GL_ONE, GL20.GL_ONE), // - multiply(GL20.GL_DST_COLOR, GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA), // - screen(GL20.GL_ONE, GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_COLOR), // - ; + normal(GL_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA, GL_ONE), // + additive(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE), // + multiply(GL_DST_COLOR, GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), // + screen(GL_ONE, GL_ONE, GL_ONE_MINUS_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR); - int source, sourcePMA, dest; + public final int source, sourcePMA, destColor, sourceAlpha; - BlendMode (int source, int sourcePremultipledAlpha, int dest) { + BlendMode (int source, int sourcePMA, int destColor, int sourceAlpha) { this.source = source; - this.sourcePMA = sourcePremultipledAlpha; - this.dest = dest; + this.sourcePMA = sourcePMA; + this.destColor = destColor; + this.sourceAlpha = sourceAlpha; } - public int getSource (boolean premultipliedAlpha) { - return premultipliedAlpha ? sourcePMA : source; - } - - public int getDest () { - return dest; + public void apply (Batch batch, boolean premultipliedAlpha) { + batch.setBlendFunctionSeparate(premultipliedAlpha ? sourcePMA : source, destColor, sourceAlpha, destColor); } static public final BlendMode[] values = values(); diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java index 80f8fb5f9..6c6ae2c5b 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java @@ -110,7 +110,7 @@ public class SkeletonRenderer { alpha = 0; } blendMode = slotBlendMode; - batch.setBlendFunction(blendMode.getSource(pmaBlendModes), blendMode.getDest()); + blendMode.apply(batch, pmaBlendModes); } float c = NumberUtils.intToFloatColor((int)alpha << 24 // @@ -222,7 +222,7 @@ public class SkeletonRenderer { alpha = 0; } blendMode = slotBlendMode; - batch.setBlendFunction(blendMode.getSource(pmaBlendModes), blendMode.getDest()); + blendMode.apply(batch, pmaBlendModes); } float c = NumberUtils.intToFloatColor((int)alpha << 24 // @@ -348,7 +348,7 @@ public class SkeletonRenderer { alpha = 0; } blendMode = slotBlendMode; - batch.setBlendFunction(blendMode.getSource(pmaBlendModes), blendMode.getDest()); + blendMode.apply(batch, pmaBlendModes); } float red = r * color.r * multiplier;