blit multiFBO into colorFBO in bindPrimaryColorFBO(), can use smooth hack in any version of OSX, as it also solves screen flickering when calling glReadPixels

This commit is contained in:
codeanticode
2012-06-25 18:55:29 +00:00
parent 016047d337
commit 4c23a2576f
@@ -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];
}