diff options
Diffstat (limited to 'src/native')
-rw-r--r-- | src/native/d3d/Attributes.cpp | 30 | ||||
-rw-r--r-- | src/native/d3d/Canvas3D.cpp | 4 | ||||
-rw-r--r-- | src/native/d3d/D3dUtil.cpp | 10 | ||||
-rw-r--r-- | src/native/d3d/D3dUtil.hpp | 3 | ||||
-rw-r--r-- | src/native/ogl/Attributes.c | 48 |
5 files changed, 70 insertions, 25 deletions
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 |