aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-08-30 10:10:32 +0200
committerSven Gothel <[email protected]>2013-08-30 10:10:32 +0200
commitad4797e6875d8fc635971ed6d8dd68326c083540 (patch)
tree5d510b344f2094e99ed7a769d0d75280c7366329 /src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java
parente1883b6402231044cc6bdf67a45c1b3610e34535 (diff)
Texture: Add 'setMustFlipVertically(boolean)' allowing to change the flipped characteristics.
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/texture/Texture.java25
1 files 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.
+ * <p>
+ * No-op if no change, otherwise generates new {@link TextureCoords}.
+ * </p>
+ */
+ 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,