OpenGL blending - alpha is added in all modes

OA = SA + DA for all modes
now matches Java2D
This commit is contained in:
Jakub Valtar
2014-11-01 18:20:56 +01:00
parent 2de4067933
commit e85f406f0f

View File

@@ -6012,55 +6012,73 @@ public class PGraphicsOpenGL extends PGraphics {
} else if (blendMode == BLEND) {
if (blendEqSupported) {
pgl.blendEquation(PGL.FUNC_ADD);
pgl.blendEquationSeparate(PGL.FUNC_ADD,
PGL.FUNC_ADD);
}
pgl.blendFunc(PGL.SRC_ALPHA, PGL.ONE_MINUS_SRC_ALPHA);
pgl.blendFuncSeparate(PGL.SRC_ALPHA, PGL.ONE_MINUS_SRC_ALPHA,
PGL.ONE, PGL.ONE);
} else if (blendMode == ADD) {
if (blendEqSupported) {
pgl.blendEquation(PGL.FUNC_ADD);
pgl.blendEquationSeparate(PGL.FUNC_ADD,
PGL.FUNC_ADD);
}
pgl.blendFunc(PGL.SRC_ALPHA, PGL.ONE);
pgl.blendFuncSeparate(PGL.SRC_ALPHA, PGL.ONE,
PGL.ONE, PGL.ONE);
} else if (blendMode == SUBTRACT) {
if (blendEqSupported) {
pgl.blendEquation(PGL.FUNC_REVERSE_SUBTRACT);
pgl.blendFunc(PGL.SRC_ALPHA, PGL.ONE);
pgl.blendEquationSeparate(PGL.FUNC_REVERSE_SUBTRACT,
PGL.FUNC_ADD);
pgl.blendFuncSeparate(PGL.SRC_ALPHA, PGL.ONE,
PGL.ONE, PGL.ONE);
} else {
PGraphics.showWarning(BLEND_DRIVER_ERROR, "SUBTRACT");
}
} else if (blendMode == LIGHTEST) {
if (blendEqSupported) {
pgl.blendEquation(PGL.FUNC_MAX);
pgl.blendEquationSeparate(PGL.FUNC_MAX,
PGL.FUNC_ADD);
pgl.blendFuncSeparate(PGL.ONE, PGL.ONE,
PGL.ONE, PGL.ONE);
} else {
PGraphics.showWarning(BLEND_DRIVER_ERROR, "LIGHTEST");
}
} else if (blendMode == DARKEST) {
if (blendEqSupported) {
pgl.blendEquation(PGL.FUNC_MIN);
pgl.blendEquationSeparate(PGL.FUNC_MIN,
PGL.FUNC_ADD);
pgl.blendFuncSeparate(PGL.ONE, PGL.ONE,
PGL.ONE, PGL.ONE);
} else {
PGraphics.showWarning(BLEND_DRIVER_ERROR, "DARKEST");
}
} else if (blendMode == EXCLUSION) {
if (blendEqSupported) {
pgl.blendEquation(PGL.FUNC_ADD);
pgl.blendEquationSeparate(PGL.FUNC_ADD,
PGL.FUNC_ADD);
}
pgl.blendFunc(PGL.ONE_MINUS_DST_COLOR, PGL.ONE_MINUS_SRC_COLOR);
pgl.blendFuncSeparate(PGL.ONE_MINUS_DST_COLOR, PGL.ONE_MINUS_SRC_COLOR,
PGL.ONE, PGL.ONE);
} else if (blendMode == MULTIPLY) {
if (blendEqSupported) {
pgl.blendEquation(PGL.FUNC_ADD);
pgl.blendEquationSeparate(PGL.FUNC_ADD,
PGL.FUNC_ADD);
}
pgl.blendFunc(PGL.ZERO, PGL.SRC_COLOR);
pgl.blendFuncSeparate(PGL.ZERO, PGL.SRC_COLOR,
PGL.ONE, PGL.ONE);
} else if (blendMode == SCREEN) {
if (blendEqSupported) {
pgl.blendEquation(PGL.FUNC_ADD);
pgl.blendEquationSeparate(PGL.FUNC_ADD,
PGL.FUNC_ADD);
}
pgl.blendFunc(PGL.ONE_MINUS_DST_COLOR, PGL.ONE);
pgl.blendFuncSeparate(PGL.ONE_MINUS_DST_COLOR, PGL.ONE,
PGL.ONE, PGL.ONE);
} else if (blendMode == DIFFERENCE) {
PGraphics.showWarning(BLEND_RENDERER_ERROR, "DIFFERENCE");