diff options
author | Kenneth Russel <[email protected]> | 2006-05-20 14:23:41 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2006-05-20 14:23:41 +0000 |
commit | 437584608fa8e479ba13f209ff42d609bda5c41d (patch) | |
tree | 7f10e8ace33a1e7bd1fb33b22fce285d8db6ddcd /src/classes | |
parent | c87828368dbb9e31f402de14be76af2b9af08588 (diff) |
Fixed bugs in handling of mipmapped compressed textures
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@771 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src/classes')
3 files changed, 16 insertions, 15 deletions
diff --git a/src/classes/com/sun/opengl/util/texture/Texture.java b/src/classes/com/sun/opengl/util/texture/Texture.java index 641f994ce..c04f47c32 100755 --- a/src/classes/com/sun/opengl/util/texture/Texture.java +++ b/src/classes/com/sun/opengl/util/texture/Texture.java @@ -360,15 +360,23 @@ public class Texture { gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, align[0]); // restore align } } else { - gl.glTexImage2D(newTarget, 0, data.getInternalFormat(), - texWidth, texHeight, data.getBorder(), - data.getPixelFormat(), data.getPixelType(), null); Buffer[] mipmapData = data.getMipmapData(); if (mipmapData != null) { + int width = texWidth; + int height = texHeight; for (int i = 0; i < mipmapData.length; i++) { + // Allocate texture image at this level + gl.glTexImage2D(newTarget, i, data.getInternalFormat(), + width, height, data.getBorder(), + data.getPixelFormat(), data.getPixelType(), null); updateSubImageImpl(data, newTarget, i, 0, 0); + width /= 2; + height /= 2; } } else { + gl.glTexImage2D(newTarget, 0, data.getInternalFormat(), + texWidth, texHeight, data.getBorder(), + data.getPixelFormat(), data.getPixelType(), null); updateSubImageImpl(data, newTarget, 0, 0, 0); } } @@ -574,7 +582,7 @@ public class Texture { private void updateSubImageImpl(TextureData data, int newTarget, int mipmapLevel, int x, int y) throws GLException { Buffer buffer = data.getBuffer(); - if (buffer == null) { + if (buffer == null && data.getMipmapData() == null) { // Assume user just wanted to get the Texture object allocated return; } diff --git a/src/classes/com/sun/opengl/util/texture/TextureIO.java b/src/classes/com/sun/opengl/util/texture/TextureIO.java index ca57e9886..b08bcd8a2 100755 --- a/src/classes/com/sun/opengl/util/texture/TextureIO.java +++ b/src/classes/com/sun/opengl/util/texture/TextureIO.java @@ -940,7 +940,6 @@ public class TextureIO { for (int i = 0; i < image.getNumMipMaps(); i++) { mipmapData[i] = image.getMipMap(i).getData(); } - System.err.println("Creating from mipmapped data"); data = new TextureData(internalFormat, info.getWidth(), info.getHeight(), diff --git a/src/classes/com/sun/opengl/util/texture/spi/DDSImage.java b/src/classes/com/sun/opengl/util/texture/spi/DDSImage.java index 068e3baa6..12a855c57 100755 --- a/src/classes/com/sun/opengl/util/texture/spi/DDSImage.java +++ b/src/classes/com/sun/opengl/util/texture/spi/DDSImage.java @@ -734,18 +734,12 @@ public class DDSImage { } private int mipMapSizeInBytes(int map) { + int width = mipMapWidth(map); + int height = mipMapHeight(map); if (isCompressed()) { - if (!isSurfaceDescFlagSet(DDSD_LINEARSIZE)) { - throw new RuntimeException("Illegal compressed texture: DDSD_LINEARSIZE not specified in texture header"); - } - int bytes = header.pitchOrLinearSize; - for (int i = 0; i < map; i++) { - bytes >>= 2; - } - return bytes; + int blockSize = (getCompressionFormat() == D3DFMT_DXT1 ? 8 : 16); + return ((width+3)/4)*((height+3)/4)*blockSize; } else { - int width = mipMapWidth(map); - int height = mipMapHeight(map); return width * height * (getDepth() / 8); } } |