diff options
Diffstat (limited to 'src/native/d3d/Canvas3D.cpp')
-rw-r--r-- | src/native/d3d/Canvas3D.cpp | 253 |
1 files changed, 13 insertions, 240 deletions
diff --git a/src/native/d3d/Canvas3D.cpp b/src/native/d3d/Canvas3D.cpp index 6988d57..e6a3eca 100644 --- a/src/native/d3d/Canvas3D.cpp +++ b/src/native/d3d/Canvas3D.cpp @@ -198,18 +198,12 @@ jboolean JNICALL Java_javax_media_j3d_NativePipeline_initTexturemapping( objectId); } - Java_javax_media_j3d_NativePipeline_bindTexture2D( - env, texture, ctx, objectId, TRUE); - - /* TODO : This need to rewrite -- Chien. */ - /* - Java_javax_media_j3d_NativePipeline_updateTexture2DImage( - env, texture, ctx, 1, 0, J3D_RGBA, 0, texWidth, texHeight, 0, NULL); - */ + Java_javax_media_j3d_NativePipeline_bindTexture2D(env, texture, ctx, objectId, TRUE); + Java_javax_media_j3d_NativePipeline_updateTexture2DImage(env, texture, ctx, 1, 0, J3D_RGBA, 0, texWidth, texHeight, 0, 0, NULL); - return (d3dCtx->textureTable[objectId] != NULL); + return (d3dCtx->textureTable[objectId] != NULL); } @@ -239,6 +233,7 @@ void JNICALL Java_javax_media_j3d_NativePipeline_texturemapping( env, texture, ctx, objectId, TRUE); // TODO --- Need to re-write. Chien + printf("[TODO NEEDED] Canvas3dD : *** texturemapping() ***\n"); 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, @@ -364,7 +359,7 @@ void JNICALL Java_javax_media_j3d_NativePipeline_textureFillBackground( GetDevice(); /* printf("Canvas3D.textureFillBackground()\n"); */ /* TODO : Implement textureFillBackground() */ - printf("[Java3D] D3D : textureFillBackground is not implemented yet.\n"); + printf("[TODO NEEDED] Canvas3D : *** textureFillBackground is not implemented yet.\n"); } @@ -387,7 +382,7 @@ void JNICALL Java_javax_media_j3d_NativePipeline_textureFillRaster(JNIEnv *env, GetDevice(); /* printf("Canvas3D.textureFillRaster()\n"); */ /* TODO : Implement textureFillRaster() */ - printf("[Java3D] D3D : textureFillRaster is not implemented yet.\n"); + printf("[TODO NEEDED] Canvas3D : *** textureFillRaster is not implemented yet.\n"); } @@ -411,228 +406,10 @@ void JNICALL Java_javax_media_j3d_NativePipeline_executeRasterDepth(JNIEnv *env, GetDevice(); /* printf("Canvas3D.executeRasterDepth()\n"); */ /* TODO : Implement executeRasterDepth() */ - printf("[Java3D] D3D : executeRasterDepth is not implemented yet.\n"); - -} - -/* TODO : This method will be replaced by clear() and textureFill() */ -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_NativePipeline_textureclear( - JNIEnv *env, - jobject obj, - jlong ctx, - jint maxX, - jint maxY, - jfloat r, - jfloat g, - jfloat b, - jint winWidth, - jint winHeight, - jint objectId, - jint imageScaleMode, - jobject pa2d, - jboolean update) -{ - - - GetDevice(); - - /* Java 3D always clears the Z-buffer */ - /* @TODO check same operation for stencil */ - - if (!d3dCtx->zWriteEnable) { - device->SetRenderState(D3DRS_ZWRITEENABLE, TRUE); - } - - /* clear stencil, if in used */ - - if (d3dCtx->stencilWriteEnable ) - {// clear stencil and ZBuffer - HRESULT hr = device->Clear(0, NULL, D3DCLEAR_STENCIL | D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, - D3DCOLOR_COLORVALUE(r, g, b, 1.0f), 1.0, 0); - if (hr == D3DERR_INVALIDCALL) - { - printf("[Java3D] Error cleaning Canvas3D stencil & ZBuffer\n"); - } - // printf("canvas3D clear stencil & ZBuffer\n"); - } - else - { // clear ZBuffer only - HRESULT hr = device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, - D3DCOLOR_COLORVALUE(r, g, b, 1.0f), 1.0, 0); - if (hr == D3DERR_INVALIDCALL) - { - printf("[Java3D] Error cleaning Canvas3D ZBuffer\n"); - } - // printf("canvas3D clear ZBuffer\n"); - } - - - if (pa2d) { - /* - jclass pa2d_class = env->GetObjectClass(pa2d); - // It is possible that (1) Another user thread will free this - // image. (2) Another Renderer thread in case of multiple screen - // will invoke clear() at the same time. - lockBackground(); - - - jfieldID id = env->GetFieldID(pa2d_class, "hashId", "I"); - int hashCode = env->GetIntField(pa2d, id); - - D3dImageComponent *d3dImage = - D3dImageComponent::find(&BackgroundImageList, d3dCtx, hashCode); - - id = env->GetFieldID(pa2d_class, "imageYup", "[B"); - jbyteArray pixels_obj = (jbyteArray) env->GetObjectField(pa2d, id); - - id = env->GetFieldID(pa2d_class, "width", "I"); - int width = env->GetIntField(pa2d, id); - id = env->GetFieldID(pa2d_class, "height", "I"); - int height = env->GetIntField(pa2d, id); - - LPDIRECT3DTEXTURE9 surf; - - if ((d3dImage == NULL) || (d3dImage->surf == NULL)) { - surf = createSurfaceFromImage(env, pa2d, ctx, - width, height, pixels_obj); - if (surf == NULL) { - if (d3dImage != NULL) { - D3dImageComponent::remove(&BackgroundImageList, d3dImage); - } - unlockBackground(); - return; - } - - if (d3dImage == NULL) { - d3dImage = - D3dImageComponent::add(&BackgroundImageList, d3dCtx, hashCode, surf); - } else { - // need to add this one because the new imageDirtyFlag may - // cause d3dImage->surf set to NULL - d3dImage->surf = surf; - } - } - - - D3DTLVERTEX screenCoord; - DWORD zcmpfunc; - boolean texModeRepeat; - int scaleWidth, scaleHeight; - float sw, sh; - - DWORD stencilcmpfunc; - - // sz can be any number since we already disable z buffer - // However rhw can't be 0, otherwise texture will not shown - screenCoord.sz = 0.999f; - screenCoord.rhw = 1; - - // disable z buffer - device->GetRenderState(D3DRS_ZFUNC, &zcmpfunc); - device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); - device->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS); - - // must disable stencil ? I guess yes - if (d3dCtx->stencilEnable) - { - device->GetRenderState(D3DRS_STENCILFUNC, &stencilcmpfunc); - device->SetRenderState(D3DRS_STENCILENABLE, FALSE); - device->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS); - } - - - switch (imageScaleMode){ - case javax_media_j3d_Background_SCALE_NONE: - screenCoord.sx = -0.5f; - screenCoord.sy = -0.5f; - scaleWidth = width; - scaleHeight = height; - texModeRepeat = FALSE; - break; - case javax_media_j3d_Background_SCALE_FIT_MIN: - screenCoord.sx = -0.5f; - screenCoord.sy = -0.5f; - sw = winWidth/(float) width; - sh = winHeight/(float) height; - if (sw >= sh) { - scaleWidth = int(width*sh); - scaleHeight = winHeight; - } else { - scaleWidth = winWidth; - scaleHeight = int(height*sw); - } - texModeRepeat = FALSE; - break; - case javax_media_j3d_Background_SCALE_FIT_MAX: - screenCoord.sx = -0.5f; - screenCoord.sy = -0.5f; - sw = winWidth/(float) width; - sh = winHeight/(float) height; - if (sw >= sh) { - scaleWidth = winWidth; - scaleHeight = int(height*sw); - } else { - scaleWidth = int(width*sh); - scaleHeight = winHeight; - } - texModeRepeat = FALSE; - break; - case javax_media_j3d_Background_SCALE_FIT_ALL: - screenCoord.sx = -0.5f; - screenCoord.sy = -0.5f; - scaleWidth = winWidth; - scaleHeight = winHeight; - texModeRepeat = FALSE; - break; - case javax_media_j3d_Background_SCALE_REPEAT: - screenCoord.sx = -0.5f; - screenCoord.sy = -0.5f; - scaleWidth = winWidth; - scaleHeight = winHeight; - texModeRepeat = TRUE; - break; - case javax_media_j3d_Background_SCALE_NONE_CENTER: - screenCoord.sx = (winWidth - width)/2.0f - 0.5f; - screenCoord.sy = (winHeight - height)/2.0f -0.5f; - scaleWidth = width; - scaleHeight = height; - texModeRepeat = FALSE; - break; - default: - printf("Unknown Background scale mode %d\n", imageScaleMode); - } - - drawTextureRect(d3dCtx, device, d3dImage->surf, - screenCoord, 0, 0, width, height, - scaleWidth, scaleHeight, texModeRepeat); - - device->SetRenderState(D3DRS_ZFUNC, zcmpfunc); - device->SetRenderState(D3DRS_ZWRITEENABLE, d3dCtx->zWriteEnable); - - // reenable stencil ? yes - if (d3dCtx->stencilEnable) - { - device->SetRenderState(D3DRS_STENCILFUNC, stencilcmpfunc); - device->SetRenderState(D3DRS_STENCILENABLE, d3dCtx->stencilWriteEnable); - } - unlockBackground(); - */ - } - else - { - if (!d3dCtx->zWriteEnable) { - device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); - } - // disable stencil - if (d3dCtx->stencilEnable && !d3dCtx->stencilWriteEnable) { - device->SetRenderState(D3DRS_STENCILENABLE, FALSE); - } - } + printf("[TODO NEEDED] Canvas3D : *** : executeRasterDepth is not implemented yet.\n"); } - extern "C" JNIEXPORT void JNICALL Java_javax_media_j3d_NativePipeline_setRenderMode( JNIEnv *env, @@ -1036,23 +813,19 @@ void JNICALL Java_javax_media_j3d_NativePipeline_readOffScreenBuffer( } } - /* TODO : Need to re-write --- Chien. */ if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { - imageObjPtr = (void *)env->GetPrimitiveArrayCritical((jarray)data, NULL); - - /* TODO : Can't assume it is a byte array */ - copyDataFromSurface(format, 0, 0, width, height, (jbyte *)imageObjPtr, - d3dCtx->backSurface); - - + imageObjPtr = (void *)env->GetPrimitiveArrayCritical((jarray)data, NULL); } else { imageObjPtr = (void *)env->GetDirectBufferAddress(data); - - /* TODO --- Do something .... */ } + /* TODO : Need to re-write --- Chien. */ + printf("[TODO NEEDED] Canvas3D : *** ireadOffScreenBuffer() ***\n"); + copyDataFromSurface(format, 0, 0, width, height, (jbyte *)imageObjPtr, + d3dCtx->backSurface); + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { env->ReleasePrimitiveArrayCritical((jarray)data, imageObjPtr, 0); |