fixes #2345, and also a bug in the coordinates passed to drawTexture()

in the Texture class.
This commit is contained in:
codeanticode
2014-03-03 15:45:21 -05:00
parent 27d002c9de
commit a0e117981d
3 changed files with 16 additions and 11 deletions

View File

@@ -3392,8 +3392,8 @@ public class PGraphicsOpenGL extends PGraphics {
pushMatrix();
if (shapeMode == CENTER) {
translate(x - shape.getWidth() / 2, y - shape.getHeight() / 2, z
- shape.getDepth() / 2);
translate(x - shape.getWidth() / 2, y - shape.getHeight() / 2,
z - shape.getDepth() / 2);
} else if ((shapeMode == CORNER) || (shapeMode == CORNERS)) {
translate(x, y, z);
@@ -5894,21 +5894,27 @@ public class PGraphicsOpenGL extends PGraphics {
scrX0 = dx;
scrX1 = dx + dw;
}
int texX0 = sx;
int texX1 = sx + sw;
int texY0, texY1;
if (invY) {
scrY0 = height - (dy + dh);
scrY1 = height - dy;
texY0 = tex.height - (sy + sh);
texY1 = tex.height - sy;
} else {
// Because drawTexture uses bottom-to-top orientation of Y axis.
scrY0 = height - dy;
scrY1 = height - (dy + dh);
texY0 = sy;
texY1 = sy + sh;
}
pgl.drawTexture(tex.glTarget, tex.glName,
tex.glWidth, tex.glHeight, width, height,
sx, tex.height - (sy + sh),
sx + sw, tex.height - sy,
scrX0, scrY0,
scrX1, scrY1);
texX0, texY0, texX1, texY1,
scrX0, scrY0, scrX1, scrY1);
if (needEndDraw) {