From ac3248ca332654abd2c28d058526595553e2396d Mon Sep 17 00:00:00 2001 From: codeanticode Date: Sun, 5 Jan 2014 15:20:58 -0500 Subject: [PATCH] fix #2171 --- .../processing/opengl/PGraphicsOpenGL.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index e174b3254..8835fcb00 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -5841,12 +5841,33 @@ public class PGraphicsOpenGL extends PGraphics { flush(); // make sure that the screen contents are up to date. Texture tex = getTexture(src); + boolean invX = tex.invertedX(); + boolean invY = tex.invertedY(); + int scrX0, scrX1; + int scrY0, scrY1; + if (invX) { + scrX0 = dx + dw; + scrX1 = dx; + } else { + scrX0 = dx; + scrX1 = dx + dw; + } + if (invY) { + scrY0 = height - (dy + dh); + scrY1 = height - dy; + } else { + // Because drawTexture uses bottom-to-top orientation of Y axis. + scrY0 = height - dy; + scrY1 = height - (dy + dh); + } + pgl.drawTexture(tex.glTarget, tex.glName, tex.glWidth, tex.glHeight, width, height, sx, tex.height - (sy + sh), sx + sw, tex.height - sy, - dx, height - (dy + dh), - dx + dw, height - dy); + scrX0, scrY0, + scrX1, scrY1); + if (needEndDraw) { endDraw();