diff options
author | Kenneth Russel <[email protected]> | 2005-10-22 23:17:08 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2005-10-22 23:17:08 +0000 |
commit | a2226ab5e37bc84a0a9dbb764993df73ec32c1d3 (patch) | |
tree | 8a30778624645505d527bea66296e06cd3d598d8 /src/classes | |
parent | 03a9d177b0e680ebe059c79422ead584df3518a3 (diff) |
Fixed Issue 177: Bug in gluBuildMipMaps2D
This appears to be yet another array index out-of-bounds bug in SGI's
original C sources (see Issue 140 for another). To work around it,
clamping on the maximum X coordinate traversed during scaling of
non-power-of-two textures has been added.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@398 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes')
-rw-r--r-- | src/classes/com/sun/opengl/impl/mipmap/ScaleInternal.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/classes/com/sun/opengl/impl/mipmap/ScaleInternal.java b/src/classes/com/sun/opengl/impl/mipmap/ScaleInternal.java index 7f6dac8a7..e000c2043 100644 --- a/src/classes/com/sun/opengl/impl/mipmap/ScaleInternal.java +++ b/src/classes/com/sun/opengl/impl/mipmap/ScaleInternal.java @@ -334,6 +334,13 @@ public class ScaleInternal { highx_float -= 1.0f; highx_int++; } + + // Clamp to make sure we don't run off the right edge + if (highx_int > widthin - 1) { + int delta = (highx_int - widthin + 1); + lowx_int -= delta; + highx_int -= delta; + } } lowy_int = highy_int; lowy_float = highy_float; @@ -545,6 +552,13 @@ public class ScaleInternal { highx_float -= 1.0f; highx_int++; } + + // Clamp to make sure we don't run off the right edge + if (highx_int > widthin - 1) { + int delta = (highx_int - widthin + 1); + lowx_int -= delta; + highx_int -= delta; + } } lowy_int = highy_int; lowy_float = highy_float; @@ -819,6 +833,13 @@ public class ScaleInternal { highx_float -= 1.0f; highx_int++; } + + // Clamp to make sure we don't run off the right edge + if (highx_int > widthin - 1) { + int delta = (highx_int - widthin + 1); + lowx_int -= delta; + highx_int -= delta; + } } lowy_int = highy_int; lowy_float = highy_float; @@ -1109,6 +1130,13 @@ public class ScaleInternal { highx_float -= 1.0f; highx_int++; } + + // Clamp to make sure we don't run off the right edge + if (highx_int > widthin - 1) { + int delta = (highx_int - widthin + 1); + lowx_int -= delta; + highx_int -= delta; + } } lowy_int = highy_int; lowy_float = highy_float; @@ -1390,6 +1418,13 @@ public class ScaleInternal { highx_float -= 1.0f; highx_int++; } + + // Clamp to make sure we don't run off the right edge + if (highx_int > widthin - 1) { + int delta = (highx_int - widthin + 1); + lowx_int -= delta; + highx_int -= delta; + } } lowy_int = highy_int; lowy_float = highy_float; @@ -1680,6 +1715,13 @@ public class ScaleInternal { highx_float -= 1.0f; highx_int++; } + + // Clamp to make sure we don't run off the right edge + if (highx_int > widthin - 1) { + int delta = (highx_int - widthin + 1); + lowx_int -= delta; + highx_int -= delta; + } } lowy_int = highy_int; lowy_float = highy_float; @@ -1970,6 +2012,13 @@ public class ScaleInternal { highx_float -= 1.0f; highx_int++; } + + // Clamp to make sure we don't run off the right edge + if (highx_int > widthin - 1) { + int delta = (highx_int - widthin + 1); + lowx_int -= delta; + highx_int -= delta; + } } lowy_int = highy_int; lowy_float = highy_float; @@ -2196,6 +2245,13 @@ public class ScaleInternal { highx_float -= 1.0f; highx_int++; } + + // Clamp to make sure we don't run off the right edge + if (highx_int > widthIn - 1) { + int delta = (highx_int - widthIn + 1); + lowx_int -= delta; + highx_int -= delta; + } } lowy_int = highy_int; lowy_float = highy_float; |