diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index f22b689c0..fd0189153 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -2041,13 +2041,10 @@ public class PGraphicsOpenGL extends PGraphics { u /= textureImage.width; v /= textureImage.height; - // TODO: GL texture shouldn't be retrieved - // until rendering. So how to know if it - // is flipped? -// PTexture tex = getTexture(textureImage); -// if (tex.isFlippedY()) { -// v = 1 - v; -// } + PTexture tex = queryTexture(textureImage); + if (tex != null && tex.isFlippedY()) { + v = 1 - v; + } } inGeo.addVertex(x, y, z, @@ -5639,6 +5636,18 @@ public class PGraphicsOpenGL extends PGraphics { } return tex; } + + + /** + * This utility method returns the texture associated to the image, + * but it doesn't create a new texture if the image has no texture. + * @param img the image to have a texture metadata associated to it + */ + protected PTexture queryTexture(PImage img) { + PTexture tex = (PTexture)img.getCache(renderer); + return tex; + } + /** * This utility method creates a texture for the provided image, and adds it diff --git a/java/libraries/opengl/src/processing/opengl/PShape3D.java b/java/libraries/opengl/src/processing/opengl/PShape3D.java index a4e76c462..9ce79eb21 100644 --- a/java/libraries/opengl/src/processing/opengl/PShape3D.java +++ b/java/libraries/opengl/src/processing/opengl/PShape3D.java @@ -623,13 +623,10 @@ public class PShape3D extends PShape { u /= texture.width; v /= texture.height; - // TODO: GL texture shouldn't be retrieved - // until rendering. So how to know if it - // is flipped? -// PTexture tex = ogl.getTexture(texture); -// if (tex.isFlippedY()) { -// v = 1 - v; -// } + PTexture tex = renderer.queryTexture(texture); + if (tex != null && tex.isFlippedY()) { + v = 1 - v; + } } float sR, sG, sB, sA, sW;