From 559d9a3b97bd5a43197088bb69078b7fd028e08c Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sun, 23 Jun 2013 21:33:47 -0400 Subject: [PATCH] beginPixelsOp/endPixelsOp are probably not needed when reading a depth or stencil buffer in PGL.readPixels() --- core/src/processing/opengl/PGL.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/processing/opengl/PGL.java b/core/src/processing/opengl/PGL.java index e5677804d..6bfd1cfda 100644 --- a/core/src/processing/opengl/PGL.java +++ b/core/src/processing/opengl/PGL.java @@ -3087,6 +3087,8 @@ public class PGL { public static final int STENCIL_INDEX4 = GL.GL_STENCIL_INDEX4; public static final int STENCIL_INDEX8 = GL.GL_STENCIL_INDEX8; + public static final int DEPTH_STENCIL = GL.GL_DEPTH_STENCIL; + public static final int FRAMEBUFFER_COMPLETE = GL.GL_FRAMEBUFFER_COMPLETE; public static final int FRAMEBUFFER_INCOMPLETE_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; public static final int FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = GL.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; @@ -3263,11 +3265,15 @@ public class PGL { // Reading Pixels public void readPixels(int x, int y, int width, int height, int format, int type, Buffer buffer) { - // The beginPixelsOp/endPixelsOp calls are needed to properly setup the - // framebuffers to read from. - PGraphicsOpenGL.pgCurrent.beginPixelsOp(PGraphicsOpenGL.OP_READ); + boolean needBeginOp = format != STENCIL_INDEX && + format != DEPTH_COMPONENT && format != DEPTH_STENCIL; + if (needBeginOp) { + PGraphicsOpenGL.pgCurrent.beginPixelsOp(PGraphicsOpenGL.OP_READ); + } readPixelsImpl(x, y, width, height, format, type, buffer); - PGraphicsOpenGL.pgCurrent.endPixelsOp(); + if (needBeginOp) { + PGraphicsOpenGL.pgCurrent.endPixelsOp(); + } } protected void readPixelsImpl(int x, int y, int width, int height, int format, int type, Buffer buffer) {