mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
Fixed blending when using two color tinting.
This commit is contained in:
parent
77099330ad
commit
10b5318921
@ -30,9 +30,7 @@
|
||||
|
||||
package com.esotericsoftware.spine;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch;
|
||||
@ -273,8 +271,7 @@ public class SkeletonRenderer {
|
||||
BlendMode slotBlendMode = slot.data.getBlendMode();
|
||||
if (slotBlendMode != blendMode) {
|
||||
blendMode = slotBlendMode;
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
Gdx.gl.glBlendFunc(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
|
||||
batch.setBlendFunction(blendMode.getSource(premultipliedAlpha), blendMode.getDest());
|
||||
}
|
||||
batch.draw(texture, vertices, 0, verticesLength, triangles, 0, triangles.length);
|
||||
}
|
||||
|
||||
@ -52,6 +52,8 @@ public class TwoColorPolygonBatch {
|
||||
private int vertexIndex, triangleIndex;
|
||||
private Texture lastTexture;
|
||||
private boolean drawing;
|
||||
private int blendSrcFunc = GL20.GL_SRC_ALPHA;
|
||||
private int blendDstFunc = GL20.GL_ONE_MINUS_SRC_ALPHA;
|
||||
|
||||
public TwoColorPolygonBatch (int size) {
|
||||
this(size, size * 2);
|
||||
@ -128,7 +130,7 @@ public class TwoColorPolygonBatch {
|
||||
mesh.setVertices(vertices, 0, vertexIndex);
|
||||
mesh.setIndices(triangles, 0, triangleIndex);
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||
|
||||
Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc);
|
||||
mesh.render(shader, GL20.GL_TRIANGLES, 0, triangleIndex);
|
||||
|
||||
vertexIndex = 0;
|
||||
@ -178,6 +180,13 @@ public class TwoColorPolygonBatch {
|
||||
}
|
||||
}
|
||||
|
||||
public void setBlendFunction (int srcFunc, int dstFunc) {
|
||||
if (blendSrcFunc == srcFunc && blendDstFunc == dstFunc) return;
|
||||
flush();
|
||||
blendSrcFunc = srcFunc;
|
||||
blendDstFunc = dstFunc;
|
||||
}
|
||||
|
||||
private ShaderProgram createDefaultShader () {
|
||||
String vertexShader = "attribute vec4 a_position;\n" //
|
||||
+ "attribute vec4 a_light;\n" //
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user