incorporate https://github.com/processing/processing/pull/5881 for FBO fix on Intel HD Graphics 3000 devices

This commit is contained in:
Ben Fry
2019-10-07 18:27:24 -04:00
parent 8f994389c4
commit 269f626f98
4 changed files with 37 additions and 6 deletions
+11
View File
@@ -165,6 +165,17 @@ public abstract class PGL {
protected boolean usingFrontTex = false;
protected boolean needSepFrontTex = false;
/**
* Defines if FBO Layer is allowed in the given environment.
* Using FBO can cause a fatal error during runtime for
* Intel HD Graphics 3000 chipsets (commonly used on older MacBooks)
* <a href="https://github.com/processing/processing/issues/4104">#4104</a>
* The value remains as 'true' unless set false during init.
* TODO There's already code in here to enable/disable the FBO properly,
* this should be making use of that mechanism instead. [fry 191007]
*/
protected boolean fboAllowed = true;
// ........................................................
// Texture rendering
@@ -36,6 +36,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
@@ -178,6 +179,22 @@ public class PSurfaceJOGL implements PSurface {
GraphicsConfiguration config = awtDisplayDevice.getDefaultConfiguration();
displayRect = config.getBounds();
/** See explanation at {@link PGL#fboAllowed} in PGL */
if (PApplet.platform == PConstants.MACOS) {
try {
Class<?> cglClass = Class.forName("sun.java2d.opengl.CGLGraphicsConfig");
Method cglMethod = cglClass.getMethod("getContextCapabilities");
Class<?> ctcClass = Class.forName("sun.java2d.pipe.hw.ContextCapabilities");
Method ctcMethod = ctcClass.getMethod("getAdapterId");
Object cglInstance = cglClass.cast(config);
Object ctcInstance = cglMethod.invoke(cglInstance);
Object idInstance = ctcMethod.invoke(ctcInstance);
if (String.valueOf(idInstance).contains("Intel HD Graphics 3000")) {
pgl.fboAllowed = false;
}
} catch (Exception e) { }
}
}