Example #1
0
 protected void setupDefaultBlending() {
   // Default blending mode in PGraphicsOpenGL.
   blendMode = BLEND;
   gl.glBlendEquation(GL.GL_FUNC_ADD);
   gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
 }
Example #2
0
  protected void setupBlending(int mode) {
    blendMode = mode;

    if (blendMode == REPLACE) {
      gl.glBlendEquation(GL.GL_FUNC_ADD);
      gl.glBlendFunc(GL.GL_ONE, GL.GL_ZERO);
    } else if (blendMode == BLEND) {
      gl.glBlendEquation(GL.GL_FUNC_ADD);
      gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
    } else if (blendMode == ADD) {
      gl.glBlendEquation(GL.GL_FUNC_ADD);
      gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
    } else if (blendMode == SUBTRACT) {
      gl.glBlendEquation(GL.GL_FUNC_ADD);
      gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ZERO);
    } else if (blendMode == LIGHTEST) {
      gl.glBlendEquation(GL.GL_MAX);
      gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_DST_ALPHA);
    } else if (blendMode == DARKEST) {
      gl.glBlendEquation(GL.GL_MIN);
      gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_DST_ALPHA);
    } else if (blendMode == DIFFERENCE) {
      gl.glBlendEquation(GL.GL_FUNC_REVERSE_SUBTRACT);
      gl.glBlendFunc(GL.GL_ONE, GL.GL_ONE);
    } else if (blendMode == EXCLUSION) {
      gl.glBlendEquation(GL.GL_FUNC_ADD);
      gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE_MINUS_SRC_COLOR);
    } else if (blendMode == MULTIPLY) {
      gl.glBlendEquation(GL.GL_FUNC_ADD);
      gl.glBlendFunc(GL.GL_DST_COLOR, GL.GL_SRC_COLOR);
    } else if (blendMode == SCREEN) {
      gl.glBlendEquation(GL.GL_FUNC_ADD);
      gl.glBlendFunc(GL.GL_ONE_MINUS_DST_COLOR, GL.GL_ONE);
    } else if (blendMode == BACKGROUND_ALPHA) {
      gl.glBlendColor(0.0f, 0.0f, 0.0f, 1.0f);
      gl.glBlendFunc(GL.GL_ONE, GL.GL_CONSTANT_COLOR);
    }
    // HARD_LIGHT, SOFT_LIGHT, OVERLAY, DODGE, BURN modes cannot be implemented
    // in fixed-function pipeline because they require conditional blending and
    // non-linear blending equations.
  }