From ad4797e6875d8fc635971ed6d8dd68326c083540 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 30 Aug 2013 10:10:32 +0200 Subject: Texture: Add 'setMustFlipVertically(boolean)' allowing to change the flipped characteristics. --- .../com/jogamp/opengl/util/texture/Texture.java | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java index 496836d3c..4236e22fb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java @@ -431,8 +431,8 @@ public class Texture { } /** - * Updates the entire content area of this texture using the data in - * the given image. + * Updates the entire content area incl. {@link TextureCoords} + * of this texture using the data in the given image. * * @throws GLException if any OpenGL-related errors occurred */ @@ -453,7 +453,21 @@ public class Texture { } /** - * Updates the content area of the specified target of this texture + * Change whether the TextureData requires a vertical flip of + * the texture coords. + *

+ * No-op if no change, otherwise generates new {@link TextureCoords}. + *

+ */ + public void setMustFlipVertically(boolean v) { + if( v != mustFlipVertically ) { + mustFlipVertically = v; + updateTexCoords(); + } + } + + /** + * Updates the content area incl. {@link TextureCoords} of the specified target of this texture * using the data in the given image. In general this is intended * for construction of cube maps. * @@ -942,6 +956,9 @@ public class Texture { private void setImageSize(int width, int height, int target) { imgWidth = width; imgHeight = height; + updateTexCoords(); + } + private void updateTexCoords() { if (target == GL2.GL_TEXTURE_RECTANGLE_ARB) { if (mustFlipVertically) { coords = new TextureCoords(0, imgHeight, imgWidth, 0); @@ -962,7 +979,7 @@ public class Texture { (float) imgHeight / (float) texHeight // t ); } - } + } } private void updateSubImageImpl(GL gl, TextureData data, int newTarget, int mipmapLevel, -- cgit v1.2.3