aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2007-03-16 02:07:41 +0000
committerKenneth Russel <[email protected]>2007-03-16 02:07:41 +0000
commit7004573742b0b2772bab30c8c540785ddc148691 (patch)
tree44dddb14d6fb5ae96dffac81d60e2d7a7634b11c /src
parentf0a6aa594b2f76b0b4ae771a7e741fd68fff69c8 (diff)
Fixed Issue 287: TextRenderer rendering artifacts
Stress testing uncovered that when neither GL_ARB_texture_non_power_of_two or GL_ARB_texture_rectangle were available, the Texture class was returning incorrect texture coordinates for textures which needed to be flipped vertically. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1170 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/Texture.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/classes/com/sun/opengl/util/texture/Texture.java b/src/classes/com/sun/opengl/util/texture/Texture.java
index 68d8dffe6..ab8997ee8 100755
--- a/src/classes/com/sun/opengl/util/texture/Texture.java
+++ b/src/classes/com/sun/opengl/util/texture/Texture.java
@@ -140,6 +140,10 @@ public class Texture {
private static final boolean DEBUG = Debug.debug("Texture");
private static final boolean VERBOSE = Debug.verbose();
+ // For testing alternate code paths on more capable hardware
+ private static final boolean disableNPOT = Debug.isPropertyDefined("jogl.texture.nonpot");
+ private static final boolean disableTexRect = Debug.isPropertyDefined("jogl.texture.notexrect");
+
// For now make Texture constructor package-private to limit the
// number of public APIs we commit to
Texture(TextureData data) throws GLException {
@@ -320,7 +324,8 @@ public class Texture {
float tx2 = (float)x2 / (float)texWidth;
float ty2 = (float)y2 / (float)texHeight;
if (mustFlipVertically) {
- return new TextureCoords(tx1, 1.0f - ty1, tx2, 1.0f - ty2);
+ float yOffset = 1.0f - ((float) imgHeight / (float) texHeight);
+ return new TextureCoords(tx1, 1.0f - yOffset - ty1, tx2, 1.0f - yOffset - ty2);
} else {
return new TextureCoords(tx1, ty1, tx2, ty2);
}
@@ -377,7 +382,7 @@ public class Texture {
texHeight = imgHeight;
newTarget = GL.GL_TEXTURE_2D;
} else if ((isPowerOfTwo(imgWidth) && isPowerOfTwo(imgHeight)) ||
- gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two")) {
+ haveNPOT(gl)) {
if (DEBUG) {
if (isPowerOfTwo(imgWidth) && isPowerOfTwo(imgHeight)) {
System.err.println("Power-of-two texture");
@@ -389,7 +394,7 @@ public class Texture {
texWidth = imgWidth;
texHeight = imgHeight;
newTarget = GL.GL_TEXTURE_2D;
- } else if (gl.isExtensionAvailable("GL_ARB_texture_rectangle")) {
+ } else if (haveTexRect(gl)) {
if (DEBUG) {
System.err.println("Using GL_ARB_texture_rectangle");
}
@@ -867,4 +872,13 @@ public class Texture {
gl.glGenTextures(1, tmp, 0);
return tmp[0];
}
+
+ // Helper routines for disabling certain codepaths
+ private static boolean haveNPOT(GL gl) {
+ return (!disableNPOT && gl.isExtensionAvailable("GL_ARB_texture_non_power_of_two"));
+ }
+
+ private static boolean haveTexRect(GL gl) {
+ return (!disableTexRect && gl.isExtensionAvailable("GL_ARB_texture_rectangle"));
+ }
}