From d5085d3254aca72a9ebd07f4b327ba8fdae9cf76 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sun, 2 Jun 2013 15:03:06 -0400 Subject: [PATCH] better detection of number of samples --- core/src/processing/opengl/PGL.java | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index 52385b50e..824afb652 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -698,7 +698,7 @@ public class PGL { protected boolean isMultisampled() { - return 1 < numSamples || 0 < capabilities.getNumSamples(); + return 1 < numSamples; } @@ -850,7 +850,7 @@ public class PGL { protected void syncBackTexture() { if (usingFrontTex) needSepFrontTex = true; if (USE_JOGL_FBOLAYER) { - if (0 < capabilities.getNumSamples()) { + if (1 < numSamples) { backFBO.syncSamplingSink(gl); backFBO.bind(gl); } @@ -887,10 +887,9 @@ public class PGL { fboHeight = nextPowerOfTwo(pg.height); } - getIntegerv(MAX_SAMPLES, intBuffer); - if (-1 < ext.indexOf("_framebuffer_multisample") && - 1 < intBuffer.get(0)) { - numSamples = reqNumSamples; + int maxs = maxSamples(); + if (-1 < ext.indexOf("_framebuffer_multisample") && 1 < maxs) { + numSamples = PApplet.min(reqNumSamples, maxs); } else { numSamples = 1; } @@ -1126,7 +1125,7 @@ public class PGL { fcount = 0; lastm = m; } - if (currentFps < 0.5f * targetFps) { + if (currentFps < 0.25f * targetFps) { finish(); } } @@ -2181,6 +2180,12 @@ public class PGL { } + protected int maxSamples() { + getIntegerv(MAX_SAMPLES, intBuffer); + return intBuffer.get(0); + } + + protected int getMaxTexUnits() { getIntegerv(MAX_TEXTURE_IMAGE_UNITS, intBuffer); return intBuffer.get(0); @@ -2580,7 +2585,7 @@ public class PGL { } if (fboDrawable != null) { backFBO = fboDrawable.getFBObject(GL.GL_BACK); - if (0 < capabilities.getNumSamples()) { + if (1 < numSamples) { if (needSepFrontTex) { // When using multisampled FBO, the back buffer is the MSAA // surface so it cannot be read from. The sink buffer contains @@ -2651,6 +2656,10 @@ public class PGL { if (!hasShaders()) { throw new RuntimeException(MISSING_GLSL_ERROR); } + if (USE_JOGL_FBOLAYER && capabilities.isFBO()) { + int maxs = maxSamples(); + numSamples = PApplet.min(capabilities.getNumSamples(), maxs); + } } @Override