diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index d6da0c2b2..31156581d 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -1999,8 +1999,6 @@ public class PGraphicsOpenGL extends PGraphics { @Override public void beginDraw() { - report("top beginDraw()"); - if (primaryGraphics) { if (!initialized) { initPrimary(); @@ -2011,6 +2009,10 @@ public class PGraphicsOpenGL extends PGraphics { getPrimaryPG().setCurrentPG(this); } + // This has to go after the surface initialization, otherwise offscreen + // surfaces will have a null gl object. + report("top beginDraw()"); + if (!checkGLThread()) { return; }