aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/com/sun/opengl/util/texture
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2008-10-20 00:37:46 +0000
committerKenneth Russel <[email protected]>2008-10-20 00:37:46 +0000
commit48d545ab3a42a58dc25e874313f1245249d175b5 (patch)
treeb3f3b77e072bd310d55d3b406dd7b2c6c44d0c8e /src/classes/com/sun/opengl/util/texture
parent08e46762d4b86051dade863cacdce9b8b0996d1c (diff)
Added preferential use of GL_ARB_texture_rectangle rather than
GL_ARB_texture_non_power_of_two on ATI cards on Mac OS X due to apparent software fallback git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JOGL_2_SANDBOX@1779 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes/com/sun/opengl/util/texture')
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/Texture.java46
1 files changed, 42 insertions, 4 deletions
diff --git a/src/classes/com/sun/opengl/util/texture/Texture.java b/src/classes/com/sun/opengl/util/texture/Texture.java
index 3c93d219f..168bab54f 100755
--- a/src/classes/com/sun/opengl/util/texture/Texture.java
+++ b/src/classes/com/sun/opengl/util/texture/Texture.java
@@ -445,6 +445,7 @@ public class Texture {
}
boolean expandingCompressedTexture = false;
+ boolean done = false;
if (data.getMipmap() && !haveAutoMipmapGeneration) {
// GLU always scales the texture's dimensions to be powers of
// two. It also doesn't really matter exactly what the texture
@@ -455,8 +456,24 @@ public class Texture {
texWidth = imgWidth;
texHeight = imgHeight;
texTarget = GL.GL_TEXTURE_2D;
- } else if ((isPowerOfTwo(imgWidth) && isPowerOfTwo(imgHeight)) ||
- haveNPOT(gl)) {
+ done = true;
+ }
+
+ if (!done && preferTexRect(gl) &&
+ haveTexRect(gl) && !data.isDataCompressed() && gl.isGL2()) {
+ // GL_ARB_texture_rectangle does not work for compressed textures
+ if (DEBUG) {
+ System.err.println("Using GL_ARB_texture_rectangle preferentially on this hardware");
+ }
+
+ texWidth = imgWidth;
+ texHeight = imgHeight;
+ texTarget = GL2.GL_TEXTURE_RECTANGLE;
+ done = true;
+ }
+
+ if (!done && ((isPowerOfTwo(imgWidth) && isPowerOfTwo(imgHeight)) ||
+ haveNPOT(gl))) {
if (DEBUG) {
if (isPowerOfTwo(imgWidth) && isPowerOfTwo(imgHeight)) {
System.err.println("Power-of-two texture");
@@ -468,7 +485,10 @@ public class Texture {
texWidth = imgWidth;
texHeight = imgHeight;
texTarget = GL.GL_TEXTURE_2D;
- } else if (haveTexRect(gl) && !data.isDataCompressed() && gl.isGL2()) {
+ done = true;
+ }
+
+ if (!done && haveTexRect(gl) && !data.isDataCompressed() && gl.isGL2()) {
// GL_ARB_texture_rectangle does not work for compressed textures
if (DEBUG) {
System.err.println("Using GL_ARB_texture_rectangle");
@@ -477,7 +497,10 @@ public class Texture {
texWidth = imgWidth;
texHeight = imgHeight;
texTarget = GL2.GL_TEXTURE_RECTANGLE;
- } else {
+ done = true;
+ }
+
+ if (!done) {
// If we receive non-power-of-two compressed texture data and
// don't have true hardware support for compressed textures, we
// can fake this support by producing an empty "compressed"
@@ -1047,4 +1070,19 @@ public class Texture {
TextureIO.isTexRectEnabled() &&
gl.isExtensionAvailable("GL_ARB_texture_rectangle"));
}
+
+ private static boolean preferTexRect(GL gl) {
+ // Prefer GL_ARB_texture_rectangle on ATI hardware on Mac OS X
+ // due to software fallbacks
+
+ String osName = System.getProperty("os.name").toLowerCase();
+ if (osName.startsWith("mac os x")) {
+ String vendor = gl.glGetString(GL.GL_VENDOR);
+ if (vendor != null && vendor.startsWith("ATI")) {
+ return true;
+ }
+ }
+
+ return false;
+ }
}