From 4c23a2576f6033372c54ddeeb5539d3c30e8c0d7 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 25 Jun 2012 18:55:29 +0000 Subject: [PATCH] blit multiFBO into colorFBO in bindPrimaryColorFBO(), can use smooth hack in any version of OSX, as it also solves screen flickering when calling glReadPixels --- .../opengl/src/processing/opengl/PGL.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/java/libraries/opengl/src/processing/opengl/PGL.java b/java/libraries/opengl/src/processing/opengl/PGL.java index d66b21e01..a2bf867be 100644 --- a/java/libraries/opengl/src/processing/opengl/PGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGL.java @@ -359,7 +359,8 @@ public class PGL { // FBO for anti-aliased rendering - public static final boolean ENABLE_SMOOTH_LION_HACK = true; + public static final boolean ENABLE_SMOOTH_OSX_HACK = true; + public static final int MIN_OSX_VER_FOR_SMOOTH_HACK = 6; protected boolean needScreenFBO = false; protected int fboWidth, fboHeight; protected int numSamples; @@ -498,7 +499,7 @@ public class PGL { public void initPrimarySurface(int antialias) { - if (ENABLE_SMOOTH_LION_HACK) { + if (ENABLE_SMOOTH_OSX_HACK) { needScreenFBO = false; if (colorFBO[0] != 0) { releaseScreenFBO(); @@ -510,7 +511,7 @@ public class PGL { String[] parts = version.split("\\."); if (2 <= parts.length) { int num = Integer.parseInt(parts[1]); - if (7 <= num && 1 < pg.quality) { + if (MIN_OSX_VER_FOR_SMOOTH_HACK <= num && 1 < pg.quality) { // We are on OSX Lion or newer, where JOGL doesn't properly // support multisampling. As a temporary hack, we handle our // own multisampled FBO for onscreen rendering with anti-aliasing. @@ -695,6 +696,14 @@ public class PGL { public void bindPrimaryColorFBO() { + // Blit the contents of the multisampled FBO into the color FBO, + // so the later is up to date. + gl.glBindFramebuffer(GL2.GL_READ_FRAMEBUFFER, multiFBO[0]); + gl.glBindFramebuffer(GL2.GL_DRAW_FRAMEBUFFER, colorFBO[0]); + gl2x.glBlitFramebuffer(0, 0, fboWidth, fboHeight, + 0, 0, fboWidth, fboHeight, + GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST); + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, colorFBO[0]); PGraphicsOpenGL.screenFramebuffer.glFboID = colorFBO[0]; }