From c1762fbaeea3b2db3088343f1f14b60c5b6956da Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 12 Dec 2011 01:50:02 +0000 Subject: [PATCH] Fixed blend setting --- .../processing/opengl/PGraphicsOpenGL.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index cf19e9f64..e2308d5ce 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -1304,7 +1304,10 @@ public class PGraphicsOpenGL extends PGraphics { super.noTexture(); // Screen blend is needed for alpha (i.e. fonts) to work. - blendMode(BLEND); + // Using setDefaultBlend() instead of blendMode() because + // the latter will set the blend mode only if it is different + // from current. + setDefaultBlend(); // this is necessary for 3D drawing if (hints[DISABLE_DEPTH_TEST]) { @@ -5652,7 +5655,14 @@ public class PGraphicsOpenGL extends PGraphics { } } - + protected void setDefaultBlend() { + blendMode = BLEND; + gl.glEnable(GL.GL_BLEND); + if (blendEqSupported) gl.glBlendEquation(GL.GL_FUNC_ADD); + gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); + } + + ////////////////////////////////////////////////////////////// // SAVE @@ -5991,8 +6001,8 @@ public class PGraphicsOpenGL extends PGraphics { profile = null; - //profile = GLProfile.getDefault(); - profile = GLProfile.get(GLProfile.GL2ES1); + profile = GLProfile.getDefault(); + //profile = GLProfile.get(GLProfile.GL2ES1); //profile = GLProfile.get(GLProfile.GL4bc); //profile = GLProfile.getMaxProgrammable(); pipeline = FIXED; @@ -6035,7 +6045,6 @@ public class PGraphicsOpenGL extends PGraphics { if (1 < antialias) { capabilities.setSampleBuffers(true); capabilities.setNumSamples(antialias); -// PApplet.println("Requested multisample level: " + capabilities.getNumSamples()); } else { capabilities.setSampleBuffers(false); }