summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2007-03-21 22:54:08 +0000
committerChien Yang <[email protected]>2007-03-21 22:54:08 +0000
commit9327277a80d538abf0fe638065a22b16be9be8bd (patch)
treebee4bc6043d6909a1bc117eed9dc15a2b6bd9ea0 /src
parent48f2ad8638b490854eebcfa07ea59b811189efd9 (diff)
1) Implemented Issue 126 : Use OpenGL automatic mipmap generation
2) Fixed Issue 408 : Poor quality of auto-generated mipmaps git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@799 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r--src/classes/jogl/javax/media/j3d/JoglPipeline.java91
-rw-r--r--src/classes/share/javax/media/j3d/ExceptionStrings.properties1
-rw-r--r--src/classes/share/javax/media/j3d/NativePipeline.java36
-rw-r--r--src/classes/share/javax/media/j3d/NoopPipeline.java12
-rw-r--r--src/classes/share/javax/media/j3d/Pipeline.java12
-rw-r--r--src/classes/share/javax/media/j3d/Texture.java4
-rw-r--r--src/classes/share/javax/media/j3d/Texture3DRetained.java10
-rw-r--r--src/classes/share/javax/media/j3d/TextureCubeMapRetained.java12
-rw-r--r--src/classes/share/javax/media/j3d/TextureRetained.java107
-rw-r--r--src/native/d3d/Attributes.cpp30
-rw-r--r--src/native/d3d/Canvas3D.cpp4
-rw-r--r--src/native/d3d/D3dUtil.cpp10
-rw-r--r--src/native/d3d/D3dUtil.hpp3
-rw-r--r--src/native/ogl/Attributes.c48
14 files changed, 235 insertions, 145 deletions
diff --git a/src/classes/jogl/javax/media/j3d/JoglPipeline.java b/src/classes/jogl/javax/media/j3d/JoglPipeline.java
index c13c5ac..6fdbb9b 100644
--- a/src/classes/jogl/javax/media/j3d/JoglPipeline.java
+++ b/src/classes/jogl/javax/media/j3d/JoglPipeline.java
@@ -5625,12 +5625,12 @@ class JoglPipeline extends Pipeline {
int textureFormat, int imageFormat,
int width, int height,
int boundaryWidth,
- int dataType, Object data) {
+ int dataType, Object data, boolean useAutoMipMap) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DImage(width=" + width + ",height=" + height + ",level=" + level + ")");
updateTexture2DImage(ctx, GL.GL_TEXTURE_2D,
numLevels, level, textureFormat, imageFormat,
- width, height, boundaryWidth, dataType, data);
+ width, height, boundaryWidth, dataType, data, useAutoMipMap);
}
void updateTexture2DSubImage(Context ctx,
@@ -5638,7 +5638,10 @@ class JoglPipeline extends Pipeline {
int textureFormat, int imageFormat,
int imgXOffset, int imgYOffset,
int tilew, int width, int height,
- int dataType, Object data) {
+ int dataType, Object data, boolean useAutoMipMap) {
+
+ /* Note: useAutoMipMap is not use for SubImage in the jogl pipe */
+
if (VERBOSE) System.err.println("JoglPipeline.updateTexture2DSubImage()");
updateTexture2DSubImage(ctx, GL.GL_TEXTURE_2D,
@@ -5770,7 +5773,7 @@ class JoglPipeline extends Pipeline {
int textureFormat, int imageFormat,
int width, int height, int depth,
int boundaryWidth,
- int dataType, Object data) {
+ int dataType, Object data, boolean useAutoMipMap) {
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DImage()");
@@ -5804,6 +5807,13 @@ class JoglPipeline extends Pipeline {
assert false;
return;
}
+
+ if (useAutoMipMap) {
+ gl.glTexParameteri(GL.GL_TEXTURE_3D, GL.GL_GENERATE_MIPMAP, GL.GL_TRUE);
+ }
+ else {
+ gl.glTexParameteri(GL.GL_TEXTURE_3D, GL.GL_GENERATE_MIPMAP, GL.GL_FALSE);
+ }
if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
@@ -5926,10 +5936,12 @@ class JoglPipeline extends Pipeline {
int imgXOffset, int imgYOffset, int imgZOffset,
int tilew, int tileh,
int width, int height, int depth,
- int dataType, Object data) {
+ int dataType, Object data, boolean useAutoMipMap) {
+
+ /* Note: useAutoMipMap is not use for SubImage in the jogl pipe */
+
if (VERBOSE) System.err.println("JoglPipeline.updateTexture3DSubImage()");
- /* TODO Chien : Need to support INT, and NIO buffers */
GL gl = context(ctx).getGL();
int format = 0;
@@ -6193,12 +6205,12 @@ class JoglPipeline extends Pipeline {
int textureFormat, int imageFormat,
int width, int height,
int boundaryWidth,
- int dataType, Object data) {
+ int dataType, Object data, boolean useAutoMipMap) {
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapImage()");
updateTexture2DImage(ctx, _gl_textureCubeMapFace[face],
numLevels, level, textureFormat, imageFormat,
- width, height, boundaryWidth, dataType, data);
+ width, height, boundaryWidth, dataType, data, useAutoMipMap);
}
void updateTextureCubeMapSubImage(Context ctx,
@@ -6206,7 +6218,10 @@ class JoglPipeline extends Pipeline {
int textureFormat,int imageFormat,
int imgXOffset, int imgYOffset,
int tilew, int width, int height,
- int dataType, Object data) {
+ int dataType, Object data, boolean useAutoMipMap) {
+
+ /* Note: useAutoMipMap is not use for SubImage in the jogl pipe */
+
if (VERBOSE) System.err.println("JoglPipeline.updateTextureCubeMapSubImage()");
updateTexture2DSubImage(ctx, _gl_textureCubeMapFace[face],
@@ -6301,7 +6316,8 @@ class JoglPipeline extends Pipeline {
int height,
int boundaryWidth,
int dataType,
- Object data) {
+ Object data,
+ boolean useAutoMipMap) {
GL gl = context(ctx).getGL();
int format = 0, internalFormat = 0;
@@ -6331,6 +6347,13 @@ class JoglPipeline extends Pipeline {
assert false;
}
+ if (useAutoMipMap) {
+ gl.glTexParameteri(target, GL.GL_GENERATE_MIPMAP, GL.GL_TRUE);
+ }
+ else {
+ gl.glTexParameteri(target, GL.GL_GENERATE_MIPMAP, GL.GL_FALSE);
+ }
+
if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_BUFFER)) {
@@ -6373,17 +6396,16 @@ class JoglPipeline extends Pipeline {
return;
}
- if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
-
- gl.glTexImage2D(target, level, internalFormat,
- width, height, boundaryWidth,
- format, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[])data));
- }
- else {
- gl.glTexImage2D(target, level, internalFormat,
- width, height, boundaryWidth,
- format, GL.GL_UNSIGNED_BYTE, (Buffer) data);
- }
+ if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_BYTE_ARRAY) {
+
+ gl.glTexImage2D(target, level, internalFormat,
+ width, height, boundaryWidth,
+ format, GL.GL_UNSIGNED_BYTE, ByteBuffer.wrap((byte[])data));
+ } else {
+ gl.glTexImage2D(target, level, internalFormat,
+ width, height, boundaryWidth,
+ format, GL.GL_UNSIGNED_BYTE, (Buffer) data);
+ }
} else if((dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) ||
(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_BUFFER)) {
@@ -6421,16 +6443,15 @@ class JoglPipeline extends Pipeline {
gl.glPixelTransferf(GL.GL_ALPHA_BIAS, 1.0f);
}
- if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
- gl.glTexImage2D(target, level, internalFormat,
- width, height, boundaryWidth,
- format, type, IntBuffer.wrap((int[])data));
- }
- else {
- gl.glTexImage2D(target, level, internalFormat,
- width, height, boundaryWidth,
- format, type, (Buffer) data);
- }
+ if(dataType == ImageComponentRetained.IMAGE_DATA_TYPE_INT_ARRAY) {
+ gl.glTexImage2D(target, level, internalFormat,
+ width, height, boundaryWidth,
+ format, type, IntBuffer.wrap((int[])data));
+ } else {
+ gl.glTexImage2D(target, level, internalFormat,
+ width, height, boundaryWidth,
+ format, type, (Buffer) data);
+ }
/* Restore Alpha scale and bias */
if(forceAlphaToOne) {
@@ -7953,10 +7974,10 @@ class JoglPipeline extends Pipeline {
gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
gl.glBindTexture(GL.GL_TEXTURE_2D, objectId);
// set up texture parameter
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
- gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT);
+ gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT);
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE);
gl.glEnable(GL.GL_BLEND);
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);
- }
- }
- }
- }
- }
+ }
+ }
}
diff --git a/src/native/d3d/Attributes.cpp b/src/native/d3d/Attributes.cpp
index c3f6752..9540aac 100644
--- a/src/native/d3d/Attributes.cpp
+++ b/src/native/d3d/Attributes.cpp
@@ -2205,8 +2205,10 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DSubImage(
jint width,
jint height,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
+ /* Note: useAutoMipMap is not use for SubImage in the d3d pipe */
GetDevice();
if (d3dCtx->texUnitStage >= d3dCtx->bindTextureIdLen) {
@@ -2284,7 +2286,8 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DImage(
jint height,
jint boundaryWidth,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
GetDevice();
@@ -2322,7 +2325,7 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DImage(
if (surf == NULL) {
// Need to create surface
surf = createTextureSurface(d3dCtx, numLevels, textureFormat,
- width, height);
+ width, height, useAutoMipMap);
if (surf == NULL) {
return;
@@ -2529,9 +2532,11 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DImage(
jint depth,
jint boundaryWidth,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
-
+ /* Note: useAutoMipMap is not use instead numLevel will be use for d3d pipe */
+
GetDevice();
if (d3dCtx->deviceInfo->maxTextureDepth <= 0) {
@@ -2655,8 +2660,11 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DSubImage(
jint height,
jint depth,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
+ /* Note: useAutoMipMap is not use for SubImage in the d3d pipe */
+
GetDevice();
if ((d3dCtx->deviceInfo->maxTextureDepth <= 0) ||
@@ -2853,8 +2861,11 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapSubImage(
jint width,
jint height,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
+ /* Note: useAutoMipMap is not use for SubImage in the d3d pipe */
+
GetDevice();
if (d3dCtx->texUnitStage >= d3dCtx->bindTextureIdLen) {
@@ -2934,8 +2945,11 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapImage(
jint height,
jint boundaryWidth,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
+ /* Note: useAutoMipMap is not use instead numLevel will be use for d3d pipe */
+
GetDevice();
if (d3dCtx->texUnitStage >= d3dCtx->bindTextureIdLen) {
diff --git a/src/native/d3d/Canvas3D.cpp b/src/native/d3d/Canvas3D.cpp
index 699895b..80eeeb7 100644
--- a/src/native/d3d/Canvas3D.cpp
+++ b/src/native/d3d/Canvas3D.cpp
@@ -202,7 +202,7 @@ jboolean JNICALL Java_javax_media_j3d_NativePipeline_initTexturemapping(
Java_javax_media_j3d_NativePipeline_updateTexture2DImage(env, texture, ctx, 1, 0,
J3D_RGBA, 0, texWidth,
- texHeight, 0, 0, NULL);
+ texHeight, 0, 0, NULL, JNI_FALSE);
return (d3dCtx->textureTable[objectId] != NULL);
}
@@ -235,7 +235,7 @@ void JNICALL Java_javax_media_j3d_NativePipeline_texturemapping(
Java_javax_media_j3d_NativePipeline_updateTexture2DSubImage(
env, texture, ctx, 0, minX, minY, J3D_RGBA, format,
minX, minY, rasWidth, maxX-minX, maxY-minY, IMAGE_DATA_TYPE_BYTE_ARRAY,
- byteData);
+ byteData, JNI_FALSE);
LPDIRECT3DTEXTURE9 surf = d3dCtx->textureTable[objectId];
diff --git a/src/native/d3d/D3dUtil.cpp b/src/native/d3d/D3dUtil.cpp
index 2ee0e40..0cc0057 100644
--- a/src/native/d3d/D3dUtil.cpp
+++ b/src/native/d3d/D3dUtil.cpp
@@ -759,11 +759,13 @@ DWORD firstBit(DWORD mask)
LPDIRECT3DTEXTURE9 createTextureSurface(D3dCtx *d3dCtx,
jint numLevels,
jint textureFormat,
- jint width, jint height)
+ jint width, jint height,
+ jboolean useAutoMipMap)
{
LPDIRECT3DTEXTURE9 pTexture;
D3DFORMAT format;
HRESULT hr;
+ DWORD usage = 0;
LPDIRECT3DDEVICE9 pDevice = d3dCtx->pDevice;
D3dDeviceInfo *deviceInfo = d3dCtx->deviceInfo;
@@ -775,10 +777,14 @@ LPDIRECT3DTEXTURE9 createTextureSurface(D3dCtx *d3dCtx,
getTexWidthHeight(deviceInfo, &width, &height);
format = getTexFormat(textureFormat);
+ if (useAutoMipMap) {
+ usage |= D3DUSAGE_AUTOGENMIPMAP;
+ }
+
// If format not support, the utility function will adjust the
// calling parameters automatically
hr = D3DXCreateTexture(d3dCtx->pDevice, width, height,
- numLevels, 0, format, D3DPOOL_MANAGED,
+ numLevels, usage, format, D3DPOOL_MANAGED,
&pTexture);
if (FAILED(hr)) {
diff --git a/src/native/d3d/D3dUtil.hpp b/src/native/d3d/D3dUtil.hpp
index e1035cb..b1a7560 100644
--- a/src/native/d3d/D3dUtil.hpp
+++ b/src/native/d3d/D3dUtil.hpp
@@ -145,7 +145,8 @@ extern LPDIRECT3DTEXTURE9 createTextureSurface(D3dCtx *d3dCtx,
jint numLevels,
jint internalFormat,
jint width,
- jint height);
+ jint height,
+ jboolean useAutoMipMap);
extern LPDIRECT3DVOLUMETEXTURE9 createVolumeTexture(D3dCtx *d3dCtx,
diff --git a/src/native/ogl/Attributes.c b/src/native/ogl/Attributes.c
index 921b949..4d2213e 100644
--- a/src/native/ogl/Attributes.c
+++ b/src/native/ogl/Attributes.c
@@ -2197,7 +2197,8 @@ void updateTexture2DImage(
jint height,
jint boundaryWidth,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
void *imageObjPtr;
GLenum format = 0, internalFormat = 0, type = GL_UNSIGNED_INT_8_8_8_8;
@@ -2234,7 +2235,14 @@ void updateTexture2DImage(
throwAssert(env, "updateTexture2DImage : textureFormat illegal format");
return;
}
-
+
+ if (useAutoMipMap) {
+ glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
+ }
+ else {
+ glTexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);
+ }
+
if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_BYTE_BUFFER)) {
switch (imageFormat) {
/* GL_BGR */
@@ -2360,7 +2368,7 @@ void updateTexture2DSubImage(
jint height,
jint dataType,
jobject data) {
-
+
void *imageObjPtr;
GLenum format = 0, internalFormat = 0, type = GL_UNSIGNED_INT_8_8_8_8;
JNIEnv table = *env;
@@ -2670,9 +2678,10 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DSubImage(
jint width,
jint height,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
-
+ /* Note : useAutoMipMap is not use for subImage in ogl pipe */
GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo;
updateTexture2DSubImage(env, ctxProperties, GL_TEXTURE_2D,
level, xoffset, yoffset,
@@ -2695,13 +2704,14 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DImage(
jint height,
jint boundaryWidth,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo;
updateTexture2DImage(env, ctxProperties, GL_TEXTURE_2D,
numLevels, level, textureFormat, imageFormat,
- width, height, boundaryWidth, dataType, data);
+ width, height, boundaryWidth, dataType, data, useAutoMipMap);
}
JNIEXPORT
@@ -2850,7 +2860,8 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DImage(
jint depth,
jint boundaryWidth,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
void *imageObjPtr;
GLenum format = 0, internalFormat = 0, type = GL_UNSIGNED_INT_8_8_8_8;
@@ -2890,6 +2901,12 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DImage(
return;
}
+ if (useAutoMipMap) {
+ glTexParameteri(GL_TEXTURE_3D, GL_GENERATE_MIPMAP, GL_TRUE);
+ }
+ else {
+ glTexParameteri(GL_TEXTURE_3D, GL_GENERATE_MIPMAP, GL_FALSE);
+ }
if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_BYTE_BUFFER)) {
switch (imageFormat) {
@@ -3017,8 +3034,11 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DSubImage(
jint height,
jint depth,
jint dataType,
- jobject data) {
+ jobject data,
+ jboolean useAutoMipMap) {
+ /* Note : useAutoMipMap is not use for SubImage in ogl pipe */
+
void *imageObjPtr;
GLenum format = 0, internalFormat = 0, type = GL_UNSIGNED_INT_8_8_8_8;
JNIEnv table = *env;
@@ -3364,8 +3384,11 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapSubImage(
jint width,
jint height,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
+ /* Note : useAutoMipMap is not use for SubImage in ogl pipe */
+
GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo;
updateTexture2DSubImage(env, ctxProperties, _gl_textureCubeMapFace[face],
level, xoffset, yoffset, textureFormat,
@@ -3389,12 +3412,13 @@ void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapImage(
jint height,
jint boundaryWidth,
jint dataType,
- jobject data)
+ jobject data,
+ jboolean useAutoMipMap)
{
GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo;
updateTexture2DImage(env, ctxProperties, _gl_textureCubeMapFace[face],
numLevels, level, textureFormat, imageFormat,
- width, height, boundaryWidth, dataType, data);
+ width, height, boundaryWidth, dataType, data, useAutoMipMap);
}
JNIEXPORT