diff options
Diffstat (limited to 'src/classes/share')
8 files changed, 109 insertions, 85 deletions
diff --git a/src/classes/share/javax/media/j3d/ExceptionStrings.properties b/src/classes/share/javax/media/j3d/ExceptionStrings.properties index 8d13787..4e65926 100644 --- a/src/classes/share/javax/media/j3d/ExceptionStrings.properties +++ b/src/classes/share/javax/media/j3d/ExceptionStrings.properties @@ -812,6 +812,7 @@ Texture44=Texture: no capability to set lod offset Texture45=Texture: no capability to get lod offset Texture46=Texture: illegal width < 1 Texture47=Texture: illegal height < 1 +Texture48=Texture: maximumLevel must be zero if mipmapMode is BASE_LEVEL Texture2D0=Texture: no capability to get detail texture information Texture2D1=Texture: Illegal detail texture mode value Texture2D2=Texture: Illegal detail texture level diff --git a/src/classes/share/javax/media/j3d/NativePipeline.java b/src/classes/share/javax/media/j3d/NativePipeline.java index 97a478a..f8ca815 100644 --- a/src/classes/share/javax/media/j3d/NativePipeline.java +++ b/src/classes/share/javax/media/j3d/NativePipeline.java @@ -2276,20 +2276,20 @@ class NativePipeline extends Pipeline { int textureFormat, int imageFormat, int width, int height, int boundaryWidth, - int imageDataType, Object data); + int imageDataType, Object data, boolean useAutoMipMap); void updateTexture2DImage(Context ctx, int numLevels, int level, int textureFormat, int imageFormat, int width, int height, int boundaryWidth, - int imageDataType, Object data) { + int imageDataType, Object data, boolean useAutoMipMap) { updateTexture2DImage(unbox(ctx), numLevels, level, textureFormat, imageFormat, width, height, boundaryWidth, - imageDataType, data); + imageDataType, data, useAutoMipMap); } native void updateTexture2DSubImage(long ctx, @@ -2297,20 +2297,20 @@ class NativePipeline extends Pipeline { int textureFormat, int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width, int height, - int imageDataType, Object data); + int imageDataType, Object data, boolean useAutoMipMap); void updateTexture2DSubImage(Context ctx, int level, int xoffset, int yoffset, int textureFormat, int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width, int height, - int imageDataType, Object data) { + int imageDataType, Object data, boolean useAutoMipMap) { updateTexture2DSubImage(unbox(ctx), level, xoffset, yoffset, textureFormat, imageFormat, imgXOffset, imgYOffset, tilew, width, height, - imageDataType, data); + imageDataType, data, useAutoMipMap); } native void updateTexture2DLodRange(long ctx, @@ -2409,20 +2409,20 @@ class NativePipeline extends Pipeline { int textureFormat, int imageFormat, int width, int height, int depth, int boundaryWidth, - int imageDataType, Object imageData); + int imageDataType, Object imageData, boolean useAutoMipMap); void updateTexture3DImage(Context ctx, int numLevels, int level, int textureFormat, int imageFormat, int width, int height, int depth, int boundaryWidth, - int imageDataType, Object imageData) { + int imageDataType, Object imageData, boolean useAutoMipMap) { updateTexture3DImage(unbox(ctx), numLevels, level, textureFormat, imageFormat, width, height, depth, boundaryWidth, - imageDataType, imageData); + imageDataType, imageData, useAutoMipMap); } native void updateTexture3DSubImage(long ctx, @@ -2432,7 +2432,7 @@ class NativePipeline extends Pipeline { int imgXoffset, int imgYoffset, int imgZoffset, int tilew, int tileh, int width, int height, int depth, - int imageDataType, Object imageData); + int imageDataType, Object imageData, boolean useAutoMipMap); void updateTexture3DSubImage(Context ctx, int level, @@ -2441,7 +2441,7 @@ class NativePipeline extends Pipeline { int imgXoffset, int imgYoffset, int imgZoffset, int tilew, int tileh, int width, int height, int depth, - int imageDataType, Object imageData) { + int imageDataType, Object imageData, boolean useAutoMipMap) { updateTexture3DSubImage(unbox(ctx), level, xoffset, yoffset, zoffset, @@ -2449,7 +2449,7 @@ class NativePipeline extends Pipeline { imgXoffset, imgYoffset, imgZoffset, tilew, tileh, width, height, depth, - imageDataType, imageData); + imageDataType, imageData, useAutoMipMap); } native void updateTexture3DLodRange(long ctx, @@ -2552,20 +2552,20 @@ class NativePipeline extends Pipeline { int textureFormat, int imageFormat, int width, int height, int boundaryWidth, - int imageDataType, Object imageData); + int imageDataType, Object imageData, boolean useAutoMipMap); void updateTextureCubeMapImage(Context ctx, int face, int numLevels, int level, int textureFormat, int imageFormat, int width, int height, int boundaryWidth, - int imageDataType, Object imageData) { + int imageDataType, Object imageData, boolean useAutoMipMap) { updateTextureCubeMapImage(unbox(ctx), face, numLevels, level, textureFormat, imageFormat, width, height, boundaryWidth, - imageDataType, imageData); + imageDataType, imageData, useAutoMipMap); } native void updateTextureCubeMapSubImage(long ctx, @@ -2573,20 +2573,20 @@ class NativePipeline extends Pipeline { int textureFormat, int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width, int height, - int imageDataType, Object imageData); + int imageDataType, Object imageData, boolean useAutoMipMap); void updateTextureCubeMapSubImage(Context ctx, int face, int level, int xoffset, int yoffset, int textureFormat, int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width, int height, - int imageDataType, Object imageData) { + int imageDataType, Object imageData, boolean useAutoMipMap) { updateTextureCubeMapSubImage(unbox(ctx), face, level, xoffset, yoffset, textureFormat, imageFormat, imgXOffset, imgYOffset, tilew, width, height, - imageDataType, imageData); + imageDataType, imageData, useAutoMipMap); } native void updateTextureCubeMapLodRange(long ctx, diff --git a/src/classes/share/javax/media/j3d/NoopPipeline.java b/src/classes/share/javax/media/j3d/NoopPipeline.java index 316df5f..394281e 100644 --- a/src/classes/share/javax/media/j3d/NoopPipeline.java +++ b/src/classes/share/javax/media/j3d/NoopPipeline.java @@ -978,7 +978,7 @@ class NoopPipeline extends Pipeline { int textureFormat, int imageFormat, int width, int height, int boundaryWidth, - int imageDataType, Object data) { + int imageDataType, Object data, boolean useAutoMipMap) { } void updateTexture2DSubImage(Context ctx, @@ -986,7 +986,7 @@ class NoopPipeline extends Pipeline { int textureFormat, int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width, int height, - int imageDataType, Object data) { + int imageDataType, Object data, boolean useAutoMipMap) { } void updateTexture2DLodRange(Context ctx, @@ -1037,7 +1037,7 @@ class NoopPipeline extends Pipeline { int textureFormat, int imageFormat, int width, int height, int depth, int boundaryWidth, - int imageDataType, Object imageData) { + int imageDataType, Object imageData, boolean useAutoMipMap) { } void updateTexture3DSubImage(Context ctx, @@ -1047,7 +1047,7 @@ class NoopPipeline extends Pipeline { int imgXoffset, int imgYoffset, int imgZoffset, int tilew, int tileh, int width, int height, int depth, - int imageTypeData, Object imageData) { + int imageTypeData, Object imageData, boolean useAutoMipMap) { } void updateTexture3DLodRange(Context ctx, @@ -1099,7 +1099,7 @@ class NoopPipeline extends Pipeline { int textureFormat, int imageFormat, int width, int height, int boundaryWidth, - int imageDataType, Object imageData) { + int imageDataType, Object imageData, boolean useAutoMipMap) { } void updateTextureCubeMapSubImage(Context ctx, @@ -1107,7 +1107,7 @@ class NoopPipeline extends Pipeline { int textureFormat, int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width, int height, - int imageDataType, Object imageData) { + int imageDataType, Object imageData, boolean useAutoMipMap) { } void updateTextureCubeMapLodRange(Context ctx, diff --git a/src/classes/share/javax/media/j3d/Pipeline.java b/src/classes/share/javax/media/j3d/Pipeline.java index f20628a..380e756 100644 --- a/src/classes/share/javax/media/j3d/Pipeline.java +++ b/src/classes/share/javax/media/j3d/Pipeline.java @@ -1067,14 +1067,14 @@ abstract class Pipeline { int textureFormat, int imageFormat, int width, int height, int boundaryWidth, - int imageDataType, Object data); + int imageDataType, Object data, boolean useAutoMipMap); abstract void updateTexture2DSubImage(Context ctx, int level, int xoffset, int yoffset, int textureFormat, int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width, int height, - int imageDataType, Object data); + int imageDataType, Object data, boolean useAutoMipMap); abstract void updateTexture2DLodRange(Context ctx, int baseLevel, int maximumLevel, @@ -1116,7 +1116,7 @@ abstract class Pipeline { int textureFormat, int imageFormat, int width, int height, int depth, int boundaryWidth, - int imageDataType, Object imageData); + int imageDataType, Object imageData, boolean useAutoMipMap); abstract void updateTexture3DSubImage(Context ctx, int level, @@ -1125,7 +1125,7 @@ abstract class Pipeline { int imgXoffset, int imgYoffset, int imgZoffset, int tilew, int tileh, int width, int height, int depth, - int imageDataType, Object imageData); + int imageDataType, Object imageData, boolean useAutoMipMap); abstract void updateTexture3DLodRange(Context ctx, int baseLevel, int maximumLevel, @@ -1168,14 +1168,14 @@ abstract class Pipeline { int textureFormat, int imageFormat, int width, int height, int boundaryWidth, - int imageDataType, Object imageData); + int imageDataType, Object imageData, boolean useAutoMipMap); abstract void updateTextureCubeMapSubImage(Context ctx, int face, int level, int xoffset, int yoffset, int textureFormat, int imageFormat, int imgXOffset, int imgYOffset, int tilew, int width, int height, - int imageDataType, Object imageData); + int imageDataType, Object imageData, boolean useAutoMipMap); abstract void updateTextureCubeMapLodRange(Context ctx, int baseLevel, int maximumLevel, diff --git a/src/classes/share/javax/media/j3d/Texture.java b/src/classes/share/javax/media/j3d/Texture.java index 5d7bc2c..3e9086d 100644 --- a/src/classes/share/javax/media/j3d/Texture.java +++ b/src/classes/share/javax/media/j3d/Texture.java @@ -849,7 +849,7 @@ public abstract class Texture extends NodeComponent { * @param magFilter the magnification filter, one of: * FASTEST, NICEST, BASE_LEVEL_POINT, BASE_LEVEL_LINEAR, * LINEAR_SHARPEN, LINEAR_SHARPEN_RGB, LINEAR_SHARPEN_ALPHA, or FILTER4. - * + * * @exception RestrictedAccessException if the method is called * when this object is part of live or compiled scene graph. * @exception IllegalArgumentException if <code>magFilter</code> @@ -1311,6 +1311,8 @@ public abstract class Texture extends NodeComponent { * @exception IllegalArgumentException if specified * maximumLevel < baseLevel, or * if maximumLevel > <code>log<sub><font size=-2>2</font></sub>(max(width,height))</code> + * @exception IllegalArgumentException if mipMipMapMode is equal to BASE_LEVEL + * and maximumLevel is not equal to zero. * * @since Java 3D 1.3 * @see Canvas3D#queryProperties diff --git a/src/classes/share/javax/media/j3d/Texture3DRetained.java b/src/classes/share/javax/media/j3d/Texture3DRetained.java index 7be22dc..e79d537 100644 --- a/src/classes/share/javax/media/j3d/Texture3DRetained.java +++ b/src/classes/share/javax/media/j3d/Texture3DRetained.java @@ -110,11 +110,14 @@ class Texture3DRetained extends TextureRetained { int boundaryWidth, int imageDataType, Object imageData) { + boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures & + Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0); + Pipeline.getPipeline().updateTexture3DImage(cv.ctx, numLevels, level, textureFormat, imageFormat, width, height, depth, - boundaryWidth, imageDataType, imageData); + boundaryWidth, imageDataType, imageData, useAutoMipMap); } // Wrapper around the native call for 3D textures @@ -125,13 +128,16 @@ class Texture3DRetained extends TextureRetained { int imgXOffset, int imgYOffset, int imgZOffset, int tilew, int tileh, int width, int height, int depth, int imageDataType, Object imageData) { + + boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures & + Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0); Pipeline.getPipeline().updateTexture3DSubImage(cv.ctx, level, xoffset, yoffset, zoffset, textureFormat, imageFormat, imgXOffset, imgYOffset, imgZOffset, tilew, tileh, width, height, depth, - imageDataType, imageData); + imageDataType, imageData, useAutoMipMap); } diff --git a/src/classes/share/javax/media/j3d/TextureCubeMapRetained.java b/src/classes/share/javax/media/j3d/TextureCubeMapRetained.java index 5142241..7fa84e3 100644 --- a/src/classes/share/javax/media/j3d/TextureCubeMapRetained.java +++ b/src/classes/share/javax/media/j3d/TextureCubeMapRetained.java @@ -298,8 +298,6 @@ class TextureCubeMapRetained extends TextureRetained { } } - - // This is just a wrapper of the native method. void updateTextureImage(Canvas3D cv, int face, int numLevels, int level, @@ -308,11 +306,14 @@ class TextureCubeMapRetained extends TextureRetained { int boundaryWidth, int imageDataType, Object imageData) { + boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures & + Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0); + Pipeline.getPipeline().updateTextureCubeMapImage(cv.ctx, face, numLevels, level, textureFormat, imageFormat, width, height, - boundaryWidth, imageDataType, imageData); + boundaryWidth, imageDataType, imageData, useAutoMipMap); } // This is just a wrapper of the native method. @@ -324,12 +325,15 @@ class TextureCubeMapRetained extends TextureRetained { int tilew, int width, int height, int imageDataType, Object imageData) { + boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures & + Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0); + Pipeline.getPipeline().updateTextureCubeMapSubImage(cv.ctx, face, level, xoffset, yoffset, textureFormat, imageFormat, imgXOffset, imgYOffset, tilew, width, height, - imageDataType, imageData); + imageDataType, imageData, useAutoMipMap); } } diff --git a/src/classes/share/javax/media/j3d/TextureRetained.java b/src/classes/share/javax/media/j3d/TextureRetained.java index 43aef4d..95dd1f6 100644 --- a/src/classes/share/javax/media/j3d/TextureRetained.java +++ b/src/classes/share/javax/media/j3d/TextureRetained.java @@ -74,11 +74,11 @@ abstract class TextureRetained extends NodeComponentRetained { // Array of images (one for each mipmap level) ImageComponentRetained images[][]; // maximum number of levels needed for the mipmapMode of this texture - int maxLevels = 0; + int maxLevels = 0; // maximum number of mipmap levels that can be defined for this texture private int maxMipMapLevels = 0; // true if hardware auto mipmap generation is requested. - private boolean useAutoMipMapGeneration = false; + boolean useAutoMipMapGeneration = false; int numFaces = 1; // For CubeMap, it is 6 int baseLevel = 0; @@ -678,11 +678,16 @@ abstract class TextureRetained extends NodeComponentRetained { final void initMaximumLevel(int level) { - if ((level < baseLevel) || (level >= maxMipMapLevels)) { - throw new IllegalArgumentException( - J3dI18N.getString("Texture37")); - } - maximumLevel = level; + if ((level < baseLevel) || (level >= maxMipMapLevels)) { + throw new IllegalArgumentException( + J3dI18N.getString("Texture37")); + } + if((mipmapMode == Texture.BASE_LEVEL) && (level != 0)) { + throw new IllegalArgumentException( + J3dI18N.getString("Texture48")); + } + + maximumLevel = level; } final void setMaximumLevel(int level) { @@ -1140,7 +1145,16 @@ abstract class TextureRetained extends NodeComponentRetained { void updateTextureLOD(Canvas3D cv) { if ((cv.textureExtendedFeatures & Canvas3D.TEXTURE_LOD_RANGE) != 0 ) { - updateTextureLodRange(cv.ctx, baseLevel, maximumLevel, + + int max = 0; + if( mipmapMode == Texture.BASE_LEVEL ) { + max = maxMipMapLevels; + } + else { + max = maximumLevel; + } + + updateTextureLodRange(cv.ctx, baseLevel, max, minimumLod, maximumLod); } @@ -1163,7 +1177,7 @@ abstract class TextureRetained extends NodeComponentRetained { int magnificationFilter = magFilter; int minificationFilter = minFilter; - + // update sharpen texture function if applicable if ((magFilter >= Texture.LINEAR_SHARPEN) && @@ -1228,8 +1242,19 @@ abstract class TextureRetained extends NodeComponentRetained { } } + // Fallback to BASE mode if hardware mipmap generation is not supported. + if (useAutoMipMapGeneration && ((cv.textureExtendedFeatures & + Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) == 0)) { + + if (minFilter == Texture.NICEST || + minFilter == Texture.MULTI_LEVEL_LINEAR) { + minificationFilter = Texture.BASE_LEVEL_LINEAR; + } else if (minFilter == Texture.MULTI_LEVEL_POINT) { + minificationFilter = Texture.BASE_LEVEL_POINT; + } + } + // update texture filtering modes - updateTextureFilterModes(cv.ctx, minificationFilter, magnificationFilter); @@ -1250,23 +1275,26 @@ abstract class TextureRetained extends NodeComponentRetained { // Wrapper around the native call for 2D textures; overridden for - // Texture3D and TextureCureMap + // TextureCureMap void updateTextureImage(Canvas3D cv, int face, int numLevels, int level, int textureFormat, int imageFormat, int width, int height, int boundaryWidth, int imageDataType, Object data) { - + + boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures & + Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0); + Pipeline.getPipeline().updateTexture2DImage(cv.ctx, numLevels, level, textureFormat, imageFormat, width, height, boundaryWidth, - imageDataType, data); + imageDataType, data, useAutoMipMap); } // Wrapper around the native call for 2D textures; overridden for - // Texture3D and TextureCureMap + // TextureCureMap void updateTextureSubImage(Canvas3D cv, int face, int level, int xoffset, int yoffset, @@ -1275,12 +1303,15 @@ abstract class TextureRetained extends NodeComponentRetained { int tilew, int width, int height, int imageDataType, Object data) { + boolean useAutoMipMap = useAutoMipMapGeneration && ((cv.textureExtendedFeatures & + Canvas3D.TEXTURE_AUTO_MIPMAP_GENERATION) != 0); + Pipeline.getPipeline().updateTexture2DSubImage(cv.ctx, level, xoffset, yoffset, textureFormat, imageFormat, imgXOffset, imgYOffset, tilew, width, height, - imageDataType, data); + imageDataType, data, useAutoMipMap); } @@ -1954,43 +1985,23 @@ abstract class TextureRetained extends NodeComponentRetained { (minFilter == Texture.NICEST || minFilter == Texture.MULTI_LEVEL_POINT || minFilter == Texture.MULTI_LEVEL_LINEAR)) { - // TODO : Should this be 1 ? --- Chien. - // mirrorTexture.maxLevels = maxMipMapLevels; - mirrorTexture.maxLevels = 1; mirrorTexture.useAutoMipMapGeneration = true; - - if ((mirrorTexture.images == null) || - (mirrorTexture.images.length < numFaces) || - !(mirrorTexture.images[0].length == mirrorTexture.maxLevels)) { - mirrorTexture.images = - new ImageComponentRetained[numFaces][mirrorTexture.maxLevels]; - } + } + + mirrorTexture.maxLevels = maxLevels; + if (images != null) { for (int j = 0; j < numFaces; j++) { - mirrorTexture.images[j][0] = images[j][0]; - - // add texture to the userList of the images - if (images[j][0] != null) { - images[j][0].addUser(mirrorTexture); + for (int i = 0; i < maxLevels; i++) { + mirrorTexture.images[j][i] = images[j][i]; + + // add texture to the userList of the images + if (images[j][i] != null) { + images[j][i].addUser(mirrorTexture); + } } - } - } - else { - mirrorTexture.maxLevels = maxLevels; - if (images != null) { - - for (int j = 0; j < numFaces; j++) { - for (int i = 0; i < maxLevels; i++) { - mirrorTexture.images[j][i] = images[j][i]; - - // add texture to the userList of the images - if (images[j][i] != null) { - images[j][i].addUser(mirrorTexture); - } - } - } - } - } + } + } } |