diff options
author | Kevin Rushforth <[email protected]> | 2006-09-29 18:04:13 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2006-09-29 18:04:13 +0000 |
commit | 908d0fbb2ea26226165cd42f12abf0d27e4a3f53 (patch) | |
tree | 0258d2293efab8f4eafba39a528a3d2eedd0c3cb /src/native | |
parent | 0661a22dd9278b20856b13b08ff22d248119cf6b (diff) |
Merged dev-1_5 branch back to MAIN trunk
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@701 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src/native')
52 files changed, 3175 insertions, 5358 deletions
diff --git a/src/native/build.xml b/src/native/build.xml index 9203b95..de87ff4 100644 --- a/src/native/build.xml +++ b/src/native/build.xml @@ -20,112 +20,102 @@ <target name="nativeSetup-debug-solaris" if="isSolarisOnSparc"> <property name="bldFlag" value="-g -DDEBUG"/> <property name="coreLibDependency" value="lib/sparc/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/sparc/libj3dutils.so"/> </target> <target name="nativeSetup-debug-solaris-x86" if="isSolarisOnX86"> <property name="bldFlag" value="-g -DDEBUG"/> <property name="coreLibDependency" value="lib/i386/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/i386/libj3dutils.so"/> </target> <target name="nativeSetup-debug-linux" if="isLinuxOnX86"> <property name="bldFlag" value="-g -DDEBUG"/> <property name="coreLibDependency" value="lib/i386/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/i386/libj3dutils.so"/> </target> <target name="nativeSetup-debug-linux-amd64" if="isLinuxOnAmd64"> <property name="bldFlag" value="-g -DDEBUG -fPIC -march=k8 -msse2 -mfpmath=sse"/> <property name="coreLibDependency" value="lib/amd64/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/amd64/libj3dutils.so"/> </target> <target name="nativeSetup-debug-linux-ia64" if="isLinuxOnIA64"> <property name="bldFlag" value="-g -DDEBUG"/> <property name="coreLibDependency" value="lib/ia64/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/ia64/libj3dutils.so"/> </target> <target name="nativeSetup-debug-linux-ppc" if="isLinuxOnPPC"> <property name="bldFlag" value="-g -DDEBUG"/> <property name="coreLibDependency" value="lib/ppc/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/ppc/libj3dutils.so"/> </target> <target name="nativeSetup-debug-win32" if="isWindowsOnX86"> <property name="bldFlag" value="-DDEBUG -DWIN32 -D_WINDOWS"/> <property name="coreLibDependency" value="bin/j3dcore-${build.rend}.dll"/> - <property name="coreUtilsLibDependency" value="bin/j3dutils.dll"/> </target> - <target name="nativeSetup-debug" depends="nativeSetup-debug-solaris, nativeSetup-debug-solaris-x86, nativeSetup-debug-linux, nativeSetup-debug-linux-amd64, nativeSetup-debug-linux-ia64, nativeSetup-debug-linux-ppc, nativeSetup-debug-win32"> + <target name="nativeSetup-debug-winamd64" if="isWindowsOnAmd64"> + <property name="bldFlag" + value="-DDEBUG -DWIN32 -D_WINDOWS"/> + <property name="coreLibDependency" value="bin/j3dcore-${build.rend}.dll"/> + </target> + + <target name="nativeSetup-debug" depends="nativeSetup-debug-solaris, nativeSetup-debug-solaris-x86, nativeSetup-debug-linux, nativeSetup-debug-linux-amd64, nativeSetup-debug-linux-ia64, nativeSetup-debug-linux-ppc, nativeSetup-debug-win32, nativeSetup-debug-winamd64"> <property name="bldType" value="debug"/> <property name="javahCoreSrc" location="${src}/classes/share/javax/media/j3d"/> <property name="javahCoreTarget" location="${build}/${platform}/${bldType}/native/javah/j3dcore"/> - <property name="javahUtilsSrc" - location="${core_utils_src}/classes/share/com/sun/j3d/utils/timer"/> - <property name="javahUtilsTarget" - location="${build}/${platform}/${bldType}/native/javah/j3dutils"/> </target> <target name="nativeSetup-opt-solaris" if="isSolarisOnSparc"> <property name="bldFlag" value="-O"/> <property name="coreLibDependency" value="lib/sparc/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/sparc/libj3dutils.so"/> </target> <target name="nativeSetup-opt-solaris-x86" if="isSolarisOnX86"> <property name="bldFlag" value="-O"/> <property name="coreLibDependency" value="lib/i386/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/i386/libj3dutils.so"/> </target> <target name="nativeSetup-opt-linux" if="isLinuxOnX86"> <property name="bldFlag" value="-O"/> <property name="coreLibDependency" value="lib/i386/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/i386/libj3dutils.so"/> </target> <target name="nativeSetup-opt-linux-amd64" if="isLinuxOnAmd64"> <property name="bldFlag" value="-O -fPIC -march=k8 -msse2 -mfpmath=sse"/> <property name="coreLibDependency" value="lib/amd64/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/amd64/libj3dutils.so"/> </target> <target name="nativeSetup-opt-linux-ia64" if="isLinuxOnIA64"> <property name="bldFlag" value="-O"/> <property name="coreLibDependency" value="lib/ia64/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/ia64/libj3dutils.so"/> </target> <target name="nativeSetup-opt-linux-ppc" if="isLinuxOnPPC"> <property name="bldFlag" value="-O"/> <property name="coreLibDependency" value="lib/ppc/libj3dcore-ogl.so"/> - <property name="coreUtilsLibDependency" value="lib/ppc/libj3dutils.so"/> </target> <target name="nativeSetup-opt-win32" if="isWindowsOnX86"> <property name="bldFlag" value="-DWIN32 -D_WINDOWS"/> <property name="coreLibDependency" value="bin/j3dcore-${build.rend}.dll"/> - <property name="coreUtilsLibDependency" value="bin/j3dutils.dll"/> </target> - <target name="nativeSetup-opt" depends="nativeSetup-opt-solaris, nativeSetup-opt-solaris-x86, nativeSetup-opt-linux, nativeSetup-opt-linux-amd64, nativeSetup-opt-linux-ia64, nativeSetup-opt-linux-ppc, nativeSetup-opt-win32"> + <target name="nativeSetup-opt-winamd64" if="isWindowsOnAmd64"> + <property name="bldFlag" + value="-DWIN32 -D_WINDOWS"/> + <property name="coreLibDependency" value="bin/j3dcore-${build.rend}.dll"/> + </target> + + <target name="nativeSetup-opt" depends="nativeSetup-opt-solaris, nativeSetup-opt-solaris-x86, nativeSetup-opt-linux, nativeSetup-opt-linux-amd64, nativeSetup-opt-linux-ia64, nativeSetup-opt-linux-ppc, nativeSetup-opt-win32, nativeSetup-opt-winamd64"> <property name="bldType" value="opt"/> <property name="javahCoreSrc" location="${src}/classes/share/javax/media/j3d"/> <property name="javahCoreTarget" location="${build}/${platform}/${bldType}/native/javah/j3dcore"/> - <property name="javahUtilsSrc" - location="${core_utils_src}/classes/share/com/sun/j3d/utils/timer"/> - <property name="javahUtilsTarget" - location="${build}/${platform}/${bldType}/native/javah/j3dutils"/> </target> <target name="dependencyCheck"> @@ -152,9 +142,6 @@ srcfile="${javahCoreSrc}/DepthComponentRetained.java" targetfile="${javahCoreTarget}/javax_media_j3d_DepthComponentRetained.h"/> <uptodate - srcfile="${javahCoreSrc}/DetailTextureImage.java" - targetfile="${javahCoreTarget}/javax_media_j3d_DetailTextureImage.h"/> - <uptodate srcfile="${javahCoreSrc}/DirectionalLightRetained.java" targetfile="${javahCoreTarget}/javax_media_j3d_DirectionalLightRetained.h"/> <uptodate @@ -212,10 +199,10 @@ srcfile="${javahCoreSrc}/ModelClipRetained.java" targetfile="${javahCoreTarget}/javax_media_j3d_ModelClipRetained.h"/> <uptodate - srcfile="${javahCoreSrc}/NativeAPIInfo.java" - targetfile="${javahCoreTarget}/javax_media_j3d_NativeAPIInfo.h"/> + srcfile="${javahCoreSrc}/NativePipeline.java" + targetfile="${javahCoreTarget}/javax_media_j3d_NativePipeline.h"/> <uptodate - srcfile="${src}/classes/${ostype}/javax/media/j3d/NativeConfigTemplate3D.java" + srcfile="${src}/classes/${wstype}/javax/media/j3d/NativeConfigTemplate3D.java" targetfile="${javahCoreTarget}/javax_media_j3d_NativeConfigTemplate3D.h"/> <uptodate srcfile="${javahCoreSrc}/NodeRetained.java" @@ -307,9 +294,6 @@ <uptodate srcfile="${javahCoreSrc}/ShaderError.java" targetfile="${javahCoreTarget}/javax_media_j3d_ShaderError.h"/> - <uptodate - srcfile="${javahUtilsSrc}/J3DTimer.java" - targetfile="${javahUtilsTarget}/com_sun_j3d_utils_timer_J3DTimer.h"/> </and> </condition> <echo message="javahBuild.notRequired = ${javahBuild.notRequired}"/> @@ -324,11 +308,6 @@ <mapper type="merge" from="*.c,*.h,*.cpp,*.hpp" to="${build}/${platform}/${bldType}/${coreLibDependency}"/> </uptodate> - <uptodate> - <srcfiles dir= "${core_utils_src}/native/share" includes="*.c,*.h,*.cpp,*.hpp"/> - <mapper type="merge" from="*.c,*.h,*.cpp,*.hpp" - to="${build}/${platform}/${bldType}/${coreUtilsLibDependency}"/> - </uptodate> </and> </condition> <echo message="nativeOGLBuild.notRequired = ${nativeOGLBuild.notRequired}"/> @@ -338,7 +317,6 @@ <!-- Create the build directory structure used for JNI header --> <mkdir dir="${javahCoreTarget}"/> - <mkdir dir="${javahUtilsTarget}"/> <!-- Generate JNI headers from ${build}/${platform}/${bldType}/classes --> <!-- into ${javahCoreTarget} --> @@ -353,7 +331,6 @@ <class name="javax.media.j3d.ColoringAttributesRetained"/> <class name="javax.media.j3d.CompressedGeometryRetained"/> <class name="javax.media.j3d.DepthComponentRetained"/> - <class name="javax.media.j3d.DetailTextureImage"/> <class name="javax.media.j3d.DirectionalLightRetained"/> <class name="javax.media.j3d.DisplayListRenderMethod"/> <class name="javax.media.j3d.DrawingSurfaceObjectAWT"/> @@ -373,7 +350,7 @@ <class name="javax.media.j3d.Material"/> <class name="javax.media.j3d.MaterialRetained"/> <class name="javax.media.j3d.ModelClipRetained"/> - <class name="javax.media.j3d.NativeAPIInfo"/> + <class name="javax.media.j3d.NativePipeline"/> <class name="javax.media.j3d.NativeConfigTemplate3D"/> <class name="javax.media.j3d.NodeRetained"/> <class name="javax.media.j3d.PointAttributesRetained"/> @@ -408,31 +385,19 @@ </javah> - <!-- Generate JNI headers from ${build}/${platform}/${bldType}/classes --> - <!-- into ${javahUtilsTarget} --> - <javah destdir="${javahUtilsTarget}" force="yes"> - <classpath> - <pathelement path="${build}/${platform}/${bldType}/classes"/> - </classpath> - <class name="com.sun.j3d.utils.timer.J3DTimer"/> - </javah> - </target> <target name="compile-debug" depends="nativeSetup-debug, dependencyCheck, genJavah" unless="nativeOGLBuild.notRequired"> <ant antfile="build-${platform}.xml" dir="${build.rend}" target="compile"/> - <ant antfile="build-${platform}.xml" dir="share" target="compile"/> </target> <target name="compile-opt" depends="nativeSetup-opt, dependencyCheck, genJavah" unless="nativeOGLBuild.notRequired"> <ant antfile="build-${platform}.xml" dir="${build.rend}" target="compile"/> - <ant antfile="build-${platform}.xml" dir="share" target="compile"/> </target> <target name="dist"> <ant antfile="build-${platform}.xml" dir="${build.rend}" target="dist"/> - <ant antfile="build-${platform}.xml" dir="share" target="dist"/> </target> </project> diff --git a/src/native/d3d/Attributes.cpp b/src/native/d3d/Attributes.cpp index a55c13f..8461c66 100644 --- a/src/native/d3d/Attributes.cpp +++ b/src/native/d3d/Attributes.cpp @@ -73,7 +73,7 @@ BOOL isLinePatternMessOutput = false; BOOL isTexBorderMessOutput = false; extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_LinearFogRetained_update( +void JNICALL Java_javax_media_j3d_NativePipeline_updateLinearFog( JNIEnv *env, jobject obj, jlong ctx, @@ -104,7 +104,7 @@ void JNICALL Java_javax_media_j3d_LinearFogRetained_update( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_ExponentialFogRetained_update( +void JNICALL Java_javax_media_j3d_NativePipeline_updateExponentialFog( JNIEnv *env, jobject obj, jlong ctx, @@ -129,7 +129,7 @@ void JNICALL Java_javax_media_j3d_ExponentialFogRetained_update( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_ModelClipRetained_update( +void JNICALL Java_javax_media_j3d_NativePipeline_updateModelClip( JNIEnv *env, jobject obj, jlong ctx, @@ -164,7 +164,7 @@ void JNICALL Java_javax_media_j3d_ModelClipRetained_update( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setModelViewMatrix( +void JNICALL Java_javax_media_j3d_NativePipeline_setModelViewMatrix( JNIEnv * env, jobject obj, jlong ctx, @@ -206,7 +206,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setModelViewMatrix( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setProjectionMatrix( +void JNICALL Java_javax_media_j3d_NativePipeline_setProjectionMatrix( JNIEnv * env, jobject obj, jlong ctx, @@ -291,7 +291,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setProjectionMatrix( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setViewport( +void JNICALL Java_javax_media_j3d_NativePipeline_setViewport( JNIEnv *env, jobject obj, jlong ctx, @@ -313,7 +313,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setViewport( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setSceneAmbient( +void JNICALL Java_javax_media_j3d_NativePipeline_setSceneAmbient( JNIEnv *env, jobject obj, jlong ctx, @@ -333,7 +333,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setSceneAmbient( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setLightEnables( +void JNICALL Java_javax_media_j3d_NativePipeline_setLightEnables( JNIEnv *env, jobject obj, jlong ctx, @@ -351,7 +351,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setLightEnables( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setLightingEnable( +void JNICALL Java_javax_media_j3d_NativePipeline_setLightingEnable( JNIEnv *env, jobject obj, jlong ctx, @@ -365,7 +365,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setLightingEnable( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_disableFog( +void JNICALL Java_javax_media_j3d_NativePipeline_disableFog( JNIEnv *env, jobject obj, jlong ctx) @@ -375,7 +375,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_disableFog( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_disableModelClip( +void JNICALL Java_javax_media_j3d_NativePipeline_disableModelClip( JNIEnv *env, jobject obj, jlong ctx) @@ -491,7 +491,7 @@ DWORD getDepthFunc(jint func) extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetRenderingAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetRenderingAttributes( JNIEnv *env, jobject obj, jlong ctx, @@ -535,7 +535,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetRenderingAttributes( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateRenderingAttributes( JNIEnv *env, jobject obj, jlong ctx, @@ -670,7 +670,7 @@ void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetPolygonAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetPolygonAttributes( JNIEnv *env, jobject obj, jlong ctx) @@ -687,7 +687,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetPolygonAttributes( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_PolygonAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updatePolygonAttributes( JNIEnv *env, jobject obj, jlong ctx, @@ -782,7 +782,7 @@ void printDepthFunc(jint func) */ extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetLineAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetLineAttributes( JNIEnv *env, jobject obj, jlong ctx) @@ -807,7 +807,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetLineAttributes( // Note that some graphics card don't support it. // In this case use RGB Emulation. extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateLineAttributes( JNIEnv *env, jobject obj, jlong ctx, @@ -877,7 +877,7 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetPointAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetPointAttributes( JNIEnv *env, jobject obj, jlong ctx) @@ -891,7 +891,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetPointAttributes( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_PointAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updatePointAttributes( JNIEnv *env, jobject obj, jlong ctx, @@ -919,7 +919,7 @@ void JNICALL Java_javax_media_j3d_PointAttributesRetained_updateNative( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetTexCoordGeneration( +void JNICALL Java_javax_media_j3d_NativePipeline_resetTexCoordGeneration( JNIEnv *env, jobject obj, jlong ctx) @@ -947,7 +947,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetTexCoordGeneration( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TexCoordGenerationRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexCoordGeneration( JNIEnv *env, jobject obj, jlong ctx, @@ -1110,7 +1110,7 @@ void JNICALL Java_javax_media_j3d_TexCoordGenerationRetained_updateNative( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetTextureAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetTextureAttributes( JNIEnv *env, jobject obj, jlong ctx) @@ -1143,7 +1143,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetTextureAttributes( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureAttributes( JNIEnv *env, jobject obj, jlong ctx, @@ -1408,54 +1408,54 @@ void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateNative( } -// This procedure is invoked after Blend2Pass to restore the original value -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_restoreBlend1Pass( - JNIEnv *env, - jobject obj, - jlong ctx) -{ - GetDevice(); +// // This procedure is invoked after Blend2Pass to restore the original value +// extern "C" JNIEXPORT +// void JNICALL Java_javax_media_j3d_NativePipeline_restoreBlend1Pass( +// JNIEnv *env, +// jobject obj, +// jlong ctx) +// { +// GetDevice(); - device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - device->SetTextureStageState(0, D3DTSS_COLORARG1, - D3DTA_TEXTURE|D3DTA_COMPLEMENT); - device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT); +// device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); +// device->SetTextureStageState(0, D3DTSS_COLORARG1, +// D3DTA_TEXTURE|D3DTA_COMPLEMENT); +// device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_CURRENT); - device->SetRenderState(D3DRS_SRCBLEND, - d3dCtx->srcBlendFunc); - device->SetRenderState(D3DRS_DESTBLEND, - d3dCtx->dstBlendFunc); - device->SetRenderState(D3DRS_ALPHABLENDENABLE, - d3dCtx->blendEnable); -} +// device->SetRenderState(D3DRS_SRCBLEND, +// d3dCtx->srcBlendFunc); +// device->SetRenderState(D3DRS_DESTBLEND, +// d3dCtx->dstBlendFunc); +// device->SetRenderState(D3DRS_ALPHABLENDENABLE, +// d3dCtx->blendEnable); +// } -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateBlend2Pass( - JNIEnv *env, - jobject obj, - jlong ctx) -{ - GetDevice(); - device->GetRenderState(D3DRS_SRCBLEND, - &d3dCtx->srcBlendFunc); - device->GetRenderState(D3DRS_DESTBLEND, - &d3dCtx->dstBlendFunc); - device->GetRenderState(D3DRS_ALPHABLENDENABLE, - &d3dCtx->blendEnable); +// extern "C" JNIEXPORT +// void JNICALL Java_javax_media_j3d_NativePipeline_updateBlend2Pass( +// JNIEnv *env, +// jobject obj, +// jlong ctx) +// { +// GetDevice(); +// device->GetRenderState(D3DRS_SRCBLEND, +// &d3dCtx->srcBlendFunc); +// device->GetRenderState(D3DRS_DESTBLEND, +// &d3dCtx->dstBlendFunc); +// device->GetRenderState(D3DRS_ALPHABLENDENABLE, +// &d3dCtx->blendEnable); - device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); - device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); - device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); - device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); - device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR); -} +// device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); +// device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); +// device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE); +// device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); +// device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); +// device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR); +// } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateCombinerNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateCombiner( JNIEnv *env, jobject obj, jlong ctx, @@ -1524,7 +1524,7 @@ void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateCombinerNative } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateTextureColorTableNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureColorTable( JNIEnv *env, jobject obj, jlong ctx, @@ -1537,7 +1537,7 @@ void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateTextureColorTa extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_updateMaterial( +void JNICALL Java_javax_media_j3d_NativePipeline_updateMaterialColor( JNIEnv *env, jobject obj, jlong ctx, @@ -1569,7 +1569,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_updateMaterial( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_MaterialRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateMaterial( JNIEnv *env, jobject obj, jlong ctx, @@ -1661,7 +1661,7 @@ void JNICALL Java_javax_media_j3d_MaterialRetained_updateNative( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetTransparency( +void JNICALL Java_javax_media_j3d_NativePipeline_resetTransparency( JNIEnv *env, jobject obj, jlong ctx, @@ -1690,7 +1690,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetTransparency( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TransparencyAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTransparencyAttributes( JNIEnv *env, jobject tr, jlong ctx, @@ -1736,7 +1736,7 @@ void JNICALL Java_javax_media_j3d_TransparencyAttributesRetained_updateNative( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetColoringAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetColoringAttributes( JNIEnv *env, jobject obj, jlong ctx, @@ -1761,7 +1761,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetColoringAttributes( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_ColoringAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateColoringAttributes( JNIEnv *env, jobject obj, jlong ctx, @@ -1799,9 +1799,9 @@ void JNICALL Java_javax_media_j3d_ColoringAttributesRetained_updateNative( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetTextureNative( +void JNICALL Java_javax_media_j3d_NativePipeline_resetTextureNative( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint texUnitIndex) { @@ -1841,9 +1841,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetTextureNative( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_bindTexture( +void JNICALL Java_javax_media_j3d_NativePipeline_bindTexture2D( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint objectId, jboolean enable) @@ -1893,9 +1893,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_bindTexture( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilterModes( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DFilterModes( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint minFilter, jint magFilter) @@ -1960,9 +1960,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilterModes( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureLodRange( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DLodRange( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint baseLevel, jint maximumLevel, @@ -1971,11 +1971,10 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureLodRange( { } - extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureLodOffset( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DLodOffset( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jfloat lodOffsetS, jfloat lodOffsetT, @@ -1985,7 +1984,7 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureLodOffset( } void updateTextureBoundary(JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint boundaryModeS, jint boundaryModeT, @@ -2083,9 +2082,9 @@ void updateTextureBoundary(JNIEnv *env, } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureBoundary( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DBoundary( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint boundaryModeS, jint boundaryModeT, @@ -2094,7 +2093,7 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureBoundary( jfloat boundaryBlue, jfloat boundaryAlpha) { - updateTextureBoundary(env, texture, ctx, boundaryModeS, + updateTextureBoundary(env, obj, ctx, boundaryModeS, boundaryModeT, -1, boundaryRed, boundaryGreen, boundaryBlue, boundaryAlpha); @@ -2103,9 +2102,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureBoundary( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureSharpenFunc( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DSharpenFunc( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint numPts, jfloatArray pts) @@ -2113,9 +2112,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureSharpenFunc( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilter4Func( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DFilter4Func( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint numPts, jfloatArray pts) @@ -2156,9 +2155,9 @@ void updateTextureAnisotropicFilter( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureAnisotropicFilter( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DAnisotropicFilter( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jfloat degree) { @@ -2167,9 +2166,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureAnisotropicFilter extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureAnisotropicFilter( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DAnisotropicFilter( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jfloat degree) { @@ -2182,9 +2181,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureAnisotropicFilt } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureAnisotropicFilter( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapAnisotropicFilter( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jfloat degree) { @@ -2193,21 +2192,22 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureAnisotropi extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureSubImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DSubImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint level, jint xoffset, jint yoffset, - jint internalFormat, - jint storedFormat, + jint textureFormat, + jint imageFormat, jint imgXOffset, jint imgYOffset, jint tilew, jint width, jint height, - jbyteArray image) + jint dataType, + jobject data) { GetDevice(); @@ -2232,44 +2232,60 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureSubImage( return; } + // TODO --- Need to re-write. Chien + void *imageObjPtr; + + /* Need to support INT, and NIO buffers -- Chien */ + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *) env->GetPrimitiveArrayCritical((jarray)data, NULL); + } + else { + imageObjPtr = (void *)env->GetDirectBufferAddress(data); + } + // update Image data - if (storedFormat != FORMAT_USHORT_GRAY) { - jbyte *byteData = (jbyte *) env->GetPrimitiveArrayCritical(image, NULL); - copyDataToSurface(storedFormat, internalFormat, xoffset, yoffset, + if (imageFormat != IMAGE_FORMAT_USHORT_GRAY) { + jbyte *byteData = (jbyte *) imageObjPtr; + copyDataToSurface(imageFormat, textureFormat, xoffset, yoffset, imgXOffset, imgYOffset, width, height, tilew, byteData, surf, level); - env->ReleasePrimitiveArrayCritical(image, byteData, 0); - } else { + /* jshort *shortData = (jshort *) env->GetPrimitiveArrayCritical(image, NULL); - copyDataToSurface(storedFormat, internalFormat, xoffset, yoffset, + copyDataToSurface(imageFormat, textureFormat, xoffset, yoffset, imgXOffset, imgYOffset, width, height, tilew, shortData, surf, level); env->ReleasePrimitiveArrayCritical(image, shortData, 0); + */ + } + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + env->ReleasePrimitiveArrayCritical((jarray)data, imageObjPtr, 0); } } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint numLevels, jint level, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint width, jint height, jint boundaryWidth, - jbyteArray imageYup) + jint dataType, + jobject data) { GetDevice(); - - if (d3dCtx->texUnitStage >= d3dCtx->bindTextureIdLen) { if (debug) { printf("Internal Error: texUnitState %d, bindTextureIDLen %d\n", @@ -2304,7 +2320,7 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureImage( if (surf == NULL) { // Need to create surface - surf = createTextureSurface(d3dCtx, numLevels, internalFormat, + surf = createTextureSurface(d3dCtx, numLevels, textureFormat, width, height); if (surf == NULL) { @@ -2326,99 +2342,48 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureImage( return; } + // TODO --- Need to re-write. Chien // update Image data - if (imageYup != NULL) { - if (format != FORMAT_USHORT_GRAY) { - jbyte *byteData = (jbyte *) env->GetPrimitiveArrayCritical(imageYup, NULL); - copyDataToSurface(format, internalFormat, 0, 0, 0, 0, + if (data != NULL) { + void *imageObjPtr; + + /* Need to support INT, and NIO buffers -- Chien */ + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *) env->GetPrimitiveArrayCritical((jarray)data, NULL); + } + else { + imageObjPtr = (void *)env->GetDirectBufferAddress(data); + } + + if (imageFormat != IMAGE_FORMAT_USHORT_GRAY) { + jbyte *byteData = (jbyte *) imageObjPtr; + copyDataToSurface(imageFormat, textureFormat, 0, 0, 0, 0, width, height, width, byteData, surf, level); - env->ReleasePrimitiveArrayCritical(imageYup, byteData, 0); - } else { + /* jshort *shortData = (jshort *) env->GetPrimitiveArrayCritical(imageYup, NULL); - copyDataToSurface(format, internalFormat, 0, 0, 0, 0, + copyDataToSurface(imageFormat, textureFormat, 0, 0, 0, 0, width, height, width, shortData, surf, level); env->ReleasePrimitiveArrayCritical(imageYup, shortData, 0); + */ } - } - + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + env->ReleasePrimitiveArrayCritical((jarray)data, imageObjPtr, 0); + } + } device->SetTexture(d3dCtx->texUnitStage, surf); } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture2DRetained_bindTexture( +void JNICALL Java_javax_media_j3d_NativePipeline_bindTexture3D( JNIEnv *env, - jobject texture, - jlong ctx, - jint objectId, - jboolean enable) -{ - Java_javax_media_j3d_TextureRetained_bindTexture(env, texture, - ctx, objectId, enable); -} - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture2DRetained_updateTextureSubImage( - JNIEnv *env, - jobject texture, - jlong ctx, - jint level, - jint xoffset, - jint yoffset, - jint internalFormat, - jint storedFormat, - jint imgXOffset, - jint imgYOffset, - jint tilew, - jint width, - jint height, - jbyteArray image) -{ - Java_javax_media_j3d_TextureRetained_updateTextureSubImage( - env, texture, ctx, level, xoffset, yoffset, internalFormat, - storedFormat, imgXOffset, imgYOffset, tilew, width, height, image); -} - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture2DRetained_updateTextureImage( - JNIEnv *env, - jobject texture, - jlong ctx, - jint numLevels, - jint level, - jint internalFormat, - jint format, - jint width, - jint height, - jint boundaryWidth, - jbyteArray imageYup) -{ - Java_javax_media_j3d_TextureRetained_updateTextureImage(env, texture, - ctx, numLevels, level, internalFormat, format, - width, height, boundaryWidth, imageYup); -} - - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture2DRetained_updateDetailTextureParameters( - JNIEnv *env, - jobject texture, - jlong ctx, - jint detailTextureMode, - jint detailTextureLevel, - jint numPts, - jfloatArray funcPts) -{ - // Not support -} - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_bindTexture( - JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint objectId, jboolean enable) @@ -2471,9 +2436,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_bindTexture( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureFilterModes( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DFilterModes( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint minFilter, jint magFilter) @@ -2481,15 +2446,15 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureFilterModes( GetCtx(); if (d3dCtx->deviceInfo->maxTextureDepth > 0) { - Java_javax_media_j3d_TextureRetained_updateTextureFilterModes( - env, texture, ctx, minFilter, magFilter); + Java_javax_media_j3d_NativePipeline_updateTexture2DFilterModes( + env, obj, ctx, minFilter, magFilter); } } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureLodRange( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DLodRange( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint baseLevel, jint maximumLevel, @@ -2501,9 +2466,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureLodRange( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureLodOffset( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DLodOffset( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jfloat lodOffsetS, jfloat lodOffsetT, @@ -2514,9 +2479,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureLodOffset( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureBoundary( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DBoundary( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint boundaryModeS, jint boundaryModeT, @@ -2532,7 +2497,7 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureBoundary( if (d3dCtx->deviceInfo->maxTextureDepth > 0) { updateTextureBoundary( - env, texture, ctx, + env, obj, ctx, boundaryModeS, boundaryModeT, boundaryModeR, @@ -2546,19 +2511,20 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureBoundary( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint numLevels, jint level, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint width, jint height, jint depth, jint boundaryWidth, - jbyteArray imageYup) + jint dataType, + jobject data) { GetDevice(); @@ -2600,7 +2566,7 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureImage( } if (surf == NULL) { - surf = createVolumeTexture(d3dCtx, numLevels, internalFormat, + surf = createVolumeTexture(d3dCtx, numLevels, textureFormat, width, height, depth); if (surf == NULL) { return; @@ -2621,21 +2587,40 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureImage( return; } + // TODO --- Need to re-write. Chien // update Image data - if (imageYup != NULL) { - if (format != FORMAT_USHORT_GRAY) { - jbyte *byteData = (jbyte *) env->GetPrimitiveArrayCritical(imageYup, NULL); - copyDataToVolume(format, internalFormat, 0, 0, 0, 0, 0, 0, + if (data != NULL) { + void *imageObjPtr; + + /* Need to support INT, and NIO buffers -- Chien */ + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *) env->GetPrimitiveArrayCritical((jarray)data, NULL); + } + else { + imageObjPtr = (void *)env->GetDirectBufferAddress(data); + } + + if (imageFormat != IMAGE_FORMAT_USHORT_GRAY) { + jbyte *byteData = (jbyte *) imageObjPtr; + copyDataToVolume(imageFormat, textureFormat, 0, 0, 0, 0, 0, 0, width, height, depth, width, height, byteData, surf, level); - env->ReleasePrimitiveArrayCritical(imageYup, byteData, 0); } else { + /* jshort *shortData = (jshort *) env->GetPrimitiveArrayCritical(imageYup, NULL); - copyDataToVolume(format, internalFormat, 0, 0, 0, 0, 0, 0, + copyDataToVolume(imageFormat, textureFormat, 0, 0, 0, 0, 0, 0, width, height, depth, width, height, shortData, surf, level); env->ReleasePrimitiveArrayCritical(imageYup, shortData, 0); + */ + } + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + env->ReleasePrimitiveArrayCritical((jarray)data, imageObjPtr, 0); } } device->SetTexture(d3dCtx->texUnitStage, surf); @@ -2643,16 +2628,16 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureImage( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSubImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DSubImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint level, jint xoffset, jint yoffset, jint zoffset, - jint internalFormat, - jint storedFormat, + jint textureFormat, + jint imageFormat, jint imgXOffset, jint imgYOffset, jint imgZOffset, @@ -2661,7 +2646,8 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSubImage( jint width, jint height, jint depth, - jbyteArray image) + jint dataType, + jobject data) { GetDevice(); @@ -2687,32 +2673,49 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSubImage( return; } + // TODO --- Need to re-write. Chien + void *imageObjPtr; + + /* Need to support INT, and NIO buffers -- Chien */ + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *) env->GetPrimitiveArrayCritical((jarray)data, NULL); + } + else { + imageObjPtr = (void *)env->GetDirectBufferAddress(data); + } + // update Image data - if (storedFormat != FORMAT_USHORT_GRAY) { - jbyte *byteData = (jbyte *) env->GetPrimitiveArrayCritical(image, NULL); - copyDataToVolume(storedFormat, internalFormat, xoffset, + if (imageFormat != IMAGE_FORMAT_USHORT_GRAY) { + jbyte *byteData = (jbyte *) imageObjPtr; + copyDataToVolume(imageFormat, textureFormat, xoffset, yoffset, zoffset, imgXOffset, imgYOffset, imgZOffset, width, height, depth, tilew, tileh, byteData, surf, level); - env->ReleasePrimitiveArrayCritical(image, byteData, 0); - } else { + /* jshort *shortData = (jshort *) env->GetPrimitiveArrayCritical(image, NULL); - copyDataToVolume(storedFormat, internalFormat, xoffset, + copyDataToVolume(imageFormat, textureFormat, xoffset, yoffset, zoffset, imgXOffset, imgYOffset, imgZOffset, width, height, depth, tilew, tileh, shortData, surf, level); env->ReleasePrimitiveArrayCritical(image, shortData, 0); + */ + } + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + env->ReleasePrimitiveArrayCritical((jarray)data, imageObjPtr, 0); } } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_bindTexture( +void JNICALL Java_javax_media_j3d_NativePipeline_bindTextureCubeMap( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint objectId, jboolean enable) @@ -2764,22 +2767,22 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_bindTexture( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureFilterModes( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapFilterModes( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint minFilter, jint magFilter) { - Java_javax_media_j3d_TextureRetained_updateTextureFilterModes(env, - texture, ctx, minFilter, magFilter); + Java_javax_media_j3d_NativePipeline_updateTexture2DFilterModes(env, + obj, ctx, minFilter, magFilter); } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureLodRange( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapLodRange( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint baseLevel, jint maximumLevel, @@ -2791,9 +2794,9 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureLodRange( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureLodOffset( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapLodOffset( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jfloat lodOffsetS, jfloat lodOffsetT, @@ -2804,9 +2807,9 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureLodOffset( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureBoundary( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapBoundary( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint boundaryModeS, jint boundaryModeT, @@ -2815,7 +2818,7 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureBoundary( jfloat boundaryBlue, jfloat boundaryAlpha) { - updateTextureBoundary(env, texture, ctx, boundaryModeS, + updateTextureBoundary(env, obj, ctx, boundaryModeS, boundaryModeT, -1, boundaryRed, boundaryGreen, boundaryBlue, boundaryAlpha); @@ -2823,22 +2826,23 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureBoundary( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureSubImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapSubImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint face, jint level, jint xoffset, jint yoffset, - jint internalFormat, - jint storedFormat, + jint textureFormat, + jint imageFormat, jint imgXOffset, jint imgYOffset, jint tilew, jint width, jint height, - jbyteArray image) + jint dataType, + jobject data) { GetDevice(); @@ -2863,43 +2867,63 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureSubImage( return; } + // TODO --- Need to re-write. Chien + void *imageObjPtr; + + /* Need to support INT, and NIO buffers -- Chien */ + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *) env->GetPrimitiveArrayCritical((jarray)data, NULL); + } + else { + imageObjPtr = (void *)env->GetDirectBufferAddress(data); + } + // update Image data - if (storedFormat != FORMAT_USHORT_GRAY) { - jbyte *byteData = (jbyte *) env->GetPrimitiveArrayCritical(image, NULL); - copyDataToCubeMap(storedFormat, internalFormat, + if (imageFormat != IMAGE_FORMAT_USHORT_GRAY) { + jbyte *byteData = (jbyte *) imageObjPtr; + copyDataToCubeMap(imageFormat, textureFormat, xoffset, yoffset, imgXOffset, imgYOffset, width, height, tilew, byteData, surf, level, face); - env->ReleasePrimitiveArrayCritical(image, byteData, 0); } else { + /* jshort *shortData = (jshort *) env->GetPrimitiveArrayCritical(image, NULL); - copyDataToCubeMap(storedFormat, internalFormat, + copyDataToCubeMap(imageFormat, textureFormat, xoffset, yoffset, imgXOffset, imgYOffset, width, height, tilew, shortData, surf, level, face); env->ReleasePrimitiveArrayCritical(image, shortData, 0); + */ } + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + env->ReleasePrimitiveArrayCritical((jarray)data, imageObjPtr, 0); + } + } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctx, jint face, jint numLevels, jint level, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint width, jint height, jint boundaryWidth, - jbyteArray imageYup) + jint dataType, + jobject data) { GetDevice(); @@ -2937,7 +2961,7 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureImage( if (surf == NULL) { // Need to create surface - surf = createCubeMapTexture(d3dCtx, numLevels, internalFormat, + surf = createCubeMapTexture(d3dCtx, numLevels, textureFormat, width, height); if (surf == NULL) { return; @@ -2958,22 +2982,41 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureImage( return; } + // TODO --- Need to re-write. Chien // update Image data - if (imageYup != NULL) { - if (format != FORMAT_USHORT_GRAY) { - jbyte *byteData = (jbyte *) env->GetPrimitiveArrayCritical(imageYup, NULL); - copyDataToCubeMap(format, internalFormat, 0, 0, 0, 0, + if (data != NULL) { + void *imageObjPtr; + + /* Need to support INT, and NIO buffers -- Chien */ + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *) env->GetPrimitiveArrayCritical((jarray)data, NULL); + } + else { + imageObjPtr = (void *)env->GetDirectBufferAddress(data); + } + + if (imageFormat != IMAGE_FORMAT_USHORT_GRAY) { + jbyte *byteData = (jbyte *) imageObjPtr; + copyDataToCubeMap(imageFormat, textureFormat, 0, 0, 0, 0, width, height, width, byteData, surf, level, face); - env->ReleasePrimitiveArrayCritical(imageYup, byteData, 0); } else { + /* jshort *shortData = (jshort *) env->GetPrimitiveArrayCritical(imageYup, NULL); - copyDataToCubeMap(format, internalFormat, 0, 0, 0, 0, + copyDataToCubeMap(imageFormat, textureFormat, 0, 0, 0, 0, width, height, width, shortData, surf, level, face); env->ReleasePrimitiveArrayCritical(imageYup, shortData, 0); + */ + } + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || + (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + env->ReleasePrimitiveArrayCritical((jarray)data, imageObjPtr, 0); } + } device->SetTexture(d3dCtx->texUnitStage, surf); @@ -2981,34 +3024,7 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureImage( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_DetailTextureImage_bindTexture( - JNIEnv *env, - jobject texture, - jlong ctx, - jint objectId) -{ - // NOT SUPPORTED -} - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_DetailTextureImage_updateTextureImage( - JNIEnv *env, - jobject texture, - jlong ctx, - jint numLevels, - jint level, - jint internalFormat, - jint format, - jint width, - jint height, - jint boundaryWidth, - jbyteArray imageYup) -{ - // NOT SUPPORTED -} - -extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_decal1stChildSetup( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_decal1stChildSetup( JNIEnv *env, jobject obj, jlong ctx) @@ -3030,7 +3046,7 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_decal1stChildSetup( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_decalNthChildSetup( +void JNICALL Java_javax_media_j3d_NativePipeline_decalNthChildSetup( JNIEnv *env, jobject obj, jlong ctx) @@ -3052,7 +3068,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_decalNthChildSetup( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_decalReset( +void JNICALL Java_javax_media_j3d_NativePipeline_decalReset( JNIEnv *env, jobject obj, jlong ctx, @@ -3069,7 +3085,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_decalReset( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_ctxUpdateEyeLightingEnable( +void JNICALL Java_javax_media_j3d_NativePipeline_ctxUpdateEyeLightingEnable( JNIEnv *env, jobject obj, jlong ctx, @@ -3080,7 +3096,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_ctxUpdateEyeLightingEnable( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_activeTextureUnit( +void JNICALL Java_javax_media_j3d_NativePipeline_activeTextureUnit( JNIEnv *env, jobject obj, jlong ctx, @@ -3097,7 +3113,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_activeTextureUnit( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureUnitStateRetained_updateTextureUnitState( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureUnitState( JNIEnv *env, jobject obj, jlong ctx, @@ -3120,7 +3136,7 @@ void JNICALL Java_javax_media_j3d_TextureUnitStateRetained_updateTextureUnitStat } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setDepthFunc( +void JNICALL Java_javax_media_j3d_NativePipeline_setDepthFunc( JNIEnv * env, jobject obj, jlong ctx, @@ -3140,7 +3156,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setDepthFunc( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setBlendColor( +void JNICALL Java_javax_media_j3d_NativePipeline_setBlendColor( JNIEnv *env, jobject obj, jlong ctx, @@ -3154,7 +3170,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setBlendColor( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setBlendFunc( +void JNICALL Java_javax_media_j3d_NativePipeline_setBlendFunc( JNIEnv * env, jobject obj, jlong ctx, @@ -3171,7 +3187,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setBlendFunc( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setFogEnableFlag( +void JNICALL Java_javax_media_j3d_NativePipeline_setFogEnableFlag( JNIEnv * env, jobject obj, jlong ctx, @@ -3183,7 +3199,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setFogEnableFlag( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_updateSeparateSpecularColorEnable( +void JNICALL Java_javax_media_j3d_NativePipeline_updateSeparateSpecularColorEnable( JNIEnv *env, jobject obj, jlong ctx, @@ -3191,39 +3207,18 @@ void JNICALL Java_javax_media_j3d_Canvas3D_updateSeparateSpecularColorEnable( { } -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_updateTexUnitStateMap( - JNIEnv *env, - jobject obj, - jlong ctx, - jint numActiveTexUnit, - jintArray texUnitStateMapArray) -{ - if ((texUnitStateMapArray != NULL) && (numActiveTexUnit > 0)) { - GetDevice(); - - jint* texUnitStateMap = (jint *) env->GetPrimitiveArrayCritical( - texUnitStateMapArray, NULL); - int genMode; - int ts; - for (int i = 0; i < numActiveTexUnit; i++) { - genMode = setTextureStage(d3dCtx, device, i, texUnitStateMap[i]); - if (genMode != TEX_GEN_AUTO) { - ts = d3dCtx->texStride[i]; - if (ts == 0) { - /* - In multiTexture case when no tex defined in non object - linear mode. - */ - ts = d3dCtx->texCoordFormat[i]; - } - } else { - ts = d3dCtx->texCoordFormat[i]; - } - setTexTransformStageFlag(d3dCtx, device, i, ts, genMode); - } - env->ReleasePrimitiveArrayCritical(texUnitStateMapArray, - texUnitStateMap, 0); - } +// Fix issue 221 : Temporary stub until Cg is implemented +/* + * Class: javax_media_j3d_NativePipeline + * Method: loadNativeCgLibrary + * Signature: ([Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL +Java_javax_media_j3d_NativePipeline_loadNativeCgLibrary( + JNIEnv *env, + jobject thiz, + jobjectArray libpath) +{ + return JNI_FALSE; } diff --git a/src/native/d3d/Canvas3D.cpp b/src/native/d3d/Canvas3D.cpp index faeafbf..ba9c918 100644 --- a/src/native/d3d/Canvas3D.cpp +++ b/src/native/d3d/Canvas3D.cpp @@ -14,7 +14,7 @@ extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setDrawActive( +void JNICALL Java_javax_media_j3d_NativePipeline_setDrawActive( JNIEnv *env, jobject obj, jint fd) @@ -24,7 +24,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setDrawActive( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_widSync( +void JNICALL Java_javax_media_j3d_NativePipeline_widSync( JNIEnv *env, jobject obj, jint fd, @@ -36,7 +36,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_widSync( extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_useSharedCtx( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_useSharedCtx( JNIEnv *env, jobject obj) { @@ -46,12 +46,12 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_useSharedCtx( extern "C" JNIEXPORT -jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( +jlong JNICALL Java_javax_media_j3d_NativePipeline_createNewContext( JNIEnv *env, jobject obj, + jobject cv, jlong display, - jint window, - jint vid, + jlong window, jlong fbConfigListPtr, jlong sharedCtx, jboolean isSharedCtx, @@ -59,10 +59,11 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( jboolean glslLibraryAvailable, jboolean cgLibraryAvailable) { - HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(jlong(window))); + HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(window)); lock(); - D3dCtx* ctx = new D3dCtx(env, obj, hwnd, offScreen, vid); + int vid = 0; // TODO: get needed info from fbConfigListPtr + D3dCtx* ctx = new D3dCtx(env, cv, hwnd, offScreen, vid); if (ctx == NULL) { printf("%s", getErrorMessage(OUTOFMEMORY)); unlock(); @@ -71,11 +72,11 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( if (offScreen) { - jclass cls = (jclass) env->GetObjectClass(obj); + jclass cls = (jclass) env->GetObjectClass(cv); jfieldID fieldId = env->GetFieldID(cls, "offScreenCanvasSize", "Ljava/awt/Dimension;"); - jobject dimObj = env->GetObjectField(obj, fieldId); + jobject dimObj = env->GetObjectField(cv, fieldId); if (dimObj == NULL) { // user invoke queryProperties() @@ -92,7 +93,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( } } - if (!ctx->initialize(env, obj)) + if (!ctx->initialize(env, cv)) { delete ctx; unlock(); @@ -106,12 +107,12 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( +void JNICALL Java_javax_media_j3d_NativePipeline_createQueryContext( JNIEnv *env, jobject obj, + jobject cv, jlong display, - jint window, - jint vid, + jlong window, jlong fbConfigListPtr, jboolean offScreen, jint width, @@ -119,7 +120,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( jboolean glslLibraryAvailable, jboolean cgLibraryAvailable) { - HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(jlong(window))); + HWND hwnd = WindowFromDC(reinterpret_cast<HDC>(window)); lock(); // always use offscreen for property since it @@ -128,7 +129,8 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( // instead of current window width/height to create // context. - D3dCtx* ctx = new D3dCtx(env, obj, hwnd, true, vid); + int vid = 0; // TODO: get needed info from fbConfigListPtr + D3dCtx* ctx = new D3dCtx(env, cv, hwnd, true, vid); if (ctx == NULL) { printf("%s", getErrorMessage(OUTOFMEMORY)); unlock(); @@ -138,18 +140,18 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( ctx->offScreenWidth = width; ctx->offScreenHeight = height; - ctx->initialize(env, obj); + ctx->initialize(env, cv); delete ctx; unlock(); } extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_useCtx( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_useCtx( JNIEnv *env, - jclass cl, + jobject obj, jlong ctx, jlong display, - jint window) + jlong window) { return JNI_TRUE; // D3D doesn't have notation of current context @@ -157,7 +159,7 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_useCtx( extern "C" JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_getNumCtxLights( +jint JNICALL Java_javax_media_j3d_NativePipeline_getNumCtxLights( JNIEnv *env, jobject obj, jlong ctx) @@ -173,43 +175,8 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_getNumCtxLights( return nlight; } - extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_composite( - JNIEnv *env, - jobject obj, - jlong ctx, - jint px, - jint py, - jint minX, - jint minY, - jint maxX, - jint maxY, - jint rasWidth, - jbyteArray imageYdown, - jint winWidth, - jint winHeight) - -{ - GetDevice(); - - // However we use the following texturemapping function instead - // so this will not invoke. - if (d3dCtx->backSurface == NULL) { - device->GetBackBuffer(0,0, D3DBACKBUFFER_TYPE_MONO,//iSwapChain is 0 - &d3dCtx->backSurface); - } - jbyte *byteData = (jbyte *) (env->GetPrimitiveArrayCritical( - imageYdown, NULL)); - compositeDataToSurface(px, py, - minX, minY, maxX-minX, maxY-minY, - rasWidth, - byteData, d3dCtx->backSurface); - env->ReleasePrimitiveArrayCritical(imageYdown, byteData, 0); -} - -extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_initTexturemapping( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_initTexturemapping( JNIEnv *env, jobject texture, jlong ctx, @@ -225,24 +192,29 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_initTexturemapping( (d3dCtx->textureTable[objectId] != NULL)) { // delete the previous texture reference // when canvas resize - Java_javax_media_j3d_Canvas3D_freeTexture(env, + Java_javax_media_j3d_NativePipeline_freeTexture(env, NULL, ctx, objectId); } - Java_javax_media_j3d_TextureRetained_bindTexture( + Java_javax_media_j3d_NativePipeline_bindTexture2D( env, texture, ctx, objectId, TRUE); - Java_javax_media_j3d_TextureRetained_updateTextureImage( - env, texture, ctx, 1, 0, J3D_RGBA, 0, texWidth, texHeight, 0, NULL); - + /* 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_updateTexture2DImage(env, texture, ctx, 1, 0, + J3D_RGBA, 0, texWidth, + texHeight, 0, 0, NULL); return (d3dCtx->textureTable[objectId] != NULL); } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( +void JNICALL Java_javax_media_j3d_NativePipeline_texturemapping( JNIEnv *env, jobject texture, jlong ctx, @@ -263,13 +235,14 @@ void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( { GetDevice(); - Java_javax_media_j3d_TextureRetained_bindTexture( + Java_javax_media_j3d_NativePipeline_bindTexture2D( env, texture, ctx, objectId, TRUE); - - Java_javax_media_j3d_Texture2DRetained_updateTextureSubImage( + // TODO --- Need to re-write. Chien + Java_javax_media_j3d_NativePipeline_updateTexture2DSubImage( env, texture, ctx, 0, minX, minY, J3D_RGBA, format, - minX, minY, rasWidth, maxX-minX, maxY-minY, imageYdown); + minX, minY, rasWidth, maxX-minX, maxY-minY, IMAGE_DATA_TYPE_BYTE_ARRAY, + imageYdown); LPDIRECT3DTEXTURE9 surf = d3dCtx->textureTable[objectId]; @@ -312,7 +285,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( minX, minY, maxX, maxY, maxX - minX, maxY - minY, false); - Java_javax_media_j3d_TextureRetained_bindTexture( + Java_javax_media_j3d_NativePipeline_bindTexture2D( env, texture, ctx, objectId, FALSE); device->SetRenderState(D3DRS_ALPHABLENDENABLE, blendEnable); @@ -325,19 +298,142 @@ void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_clear( - JNIEnv *env, - jobject obj, - jlong ctx, - jfloat r, - jfloat g, - jfloat b, - jint winWidth, - jint winHeight, - jobject pa2d, - jint imageScaleMode, - jbyteArray pixels_obj) +void JNICALL Java_javax_media_j3d_NativePipeline_clear( + JNIEnv *env, + jobject obj, + jlong ctx, + jfloat r, + jfloat g, + jfloat b) +{ + + 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 (!d3dCtx->zWriteEnable) { + device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); + } + // disable stencil + if (d3dCtx->stencilEnable && !d3dCtx->stencilWriteEnable) { + device->SetRenderState(D3DRS_STENCILENABLE, FALSE); + } + +} + +extern "C" JNIEXPORT +void JNICALL Java_javax_media_j3d_NativePipeline_textureFill( + JNIEnv *env, + jobject obj, + jlong ctx, + jfloat texMinU, + jfloat texMaxU, + jfloat texMinV, + jfloat texMaxV, + jfloat mapMinX, + jfloat mapMaxX, + jfloat mapMinY, + jfloat mapMaxY) +{ + GetDevice(); + /* printf("Canvas3D.textureFill()\n"); */ + /* TODO : Implement textureFill() */ + printf("[Java3D] D3D : textureFill is not implemented yet.\n"); + + +} + +extern "C" JNIEXPORT +void JNICALL Java_javax_media_j3d_NativePipeline_textureFillRaster(JNIEnv *env, + jobject obj, + jlong ctx, + jfloat texMinU, + jfloat texMaxU, + jfloat texMinV, + jfloat texMaxV, + jfloat mapMinX, + jfloat mapMaxX, + jfloat mapMinY, + jfloat mapMaxY, + jfloat mapZ, + jfloat alpha) +{ + GetDevice(); + /* printf("Canvas3D.textureFillRaster()\n"); */ + /* TODO : Implement textureFillRaster() */ + printf("[Java3D] D3D : textureFillRaster is not implemented yet.\n"); + +} + + +JNIEXPORT +void JNICALL Java_javax_media_j3d_NativePipeline_executeRasterDepth(JNIEnv *env, + jobject obj, + jlong ctx, + jfloat posX, + jfloat posY, + jfloat posZ, + jint srcOffsetX, + jint srcOffsetY, + jint rasterWidth, + jint rasterHeight, + jint depthWidth, + jint depthHeight, + jint depthFormat, + jobject depthData) +{ + 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(); @@ -371,15 +467,10 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear( // printf("canvas3D clear ZBuffer\n"); } - + if (pa2d) { - jclass pa2d_class = env->GetObjectClass(pa2d); /* - jfieldID id = env->GetFieldID(pa2d_class, "surfaceDirty", "I"); - if (env->GetIntField(pa2d, id) == NOTLIVE) { - return; - } - */ + 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. @@ -392,6 +483,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear( 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"); @@ -523,25 +617,24 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clear( 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); - } - } - + if (!d3dCtx->zWriteEnable) { + device->SetRenderState(D3DRS_ZWRITEENABLE, FALSE); + } + // disable stencil + if (d3dCtx->stencilEnable && !d3dCtx->stencilWriteEnable) { + device->SetRenderState(D3DRS_STENCILENABLE, FALSE); + } + } } - extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setRenderMode( +void JNICALL Java_javax_media_j3d_NativePipeline_setRenderMode( JNIEnv *env, jobject obj, jlong ctx, @@ -554,7 +647,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setRenderMode( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_clearAccum( +void JNICALL Java_javax_media_j3d_NativePipeline_clearAccum( JNIEnv *env, jobject obj, jlong ctx) @@ -566,7 +659,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clearAccum( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_accum( +void JNICALL Java_javax_media_j3d_NativePipeline_accum( JNIEnv *env, jobject obj, jlong ctx, @@ -577,7 +670,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_accum( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_accumReturn( +void JNICALL Java_javax_media_j3d_NativePipeline_accumReturn( JNIEnv *env, jobject obj, jlong ctx) @@ -587,7 +680,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_accumReturn( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setDepthBufferWriteEnable( +void JNICALL Java_javax_media_j3d_NativePipeline_setDepthBufferWriteEnable( JNIEnv *env, jobject obj, jlong ctx, @@ -632,12 +725,13 @@ VOID freePointerList() extern "C" JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers( +jint JNICALL Java_javax_media_j3d_NativePipeline_swapBuffers( JNIEnv *env, jobject obj, + jobject cv, jlong ctx, jlong display, - jint win) + jlong window) { GetDevice2(); @@ -655,7 +749,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers( printf("Buffer swap error %s, try Reset() the surface... \n", DXGetErrorString9(hr)); } - retCode = d3dCtx->resetSurface(env, obj); + retCode = d3dCtx->resetSurface(env, cv); GetDevice2(); hr = device->Present(NULL, NULL, NULL, NULL); if (FAILED(hr)) { @@ -674,7 +768,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_syncRender( +void JNICALL Java_javax_media_j3d_NativePipeline_syncRender( JNIEnv *env, jobject obj, jlong ctx, @@ -685,7 +779,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_syncRender( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_newDisplayList( +void JNICALL Java_javax_media_j3d_NativePipeline_newDisplayList( JNIEnv *env, jobject obj, jlong ctx, @@ -737,7 +831,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_newDisplayList( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_endDisplayList( +void JNICALL Java_javax_media_j3d_NativePipeline_endDisplayList( JNIEnv *env, jobject obj, jlong ctx) @@ -748,7 +842,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_endDisplayList( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_callDisplayList( +void JNICALL Java_javax_media_j3d_NativePipeline_callDisplayList( JNIEnv *env, jobject obj, jlong ctx, @@ -785,9 +879,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_callDisplayList( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_freeDisplayList( +void JNICALL Java_javax_media_j3d_NativePipeline_freeDisplayList( JNIEnv *env, - jclass cl, + jobject obj, jlong ctx, jint id) { @@ -810,9 +904,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_freeDisplayList( has been deleted by java garbage collector. */ extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_freeTexture( +void JNICALL Java_javax_media_j3d_NativePipeline_freeTexture( JNIEnv *env, - jclass cls, + jobject obj, jlong ctx, jint id) { @@ -839,28 +933,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_freeTexture( extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_isTexture3DAvailable( - JNIEnv *env, - jobject obj, - jlong ctx) -{ - return JNI_FALSE; -} - - -extern "C" JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_getTextureColorTableSize( - JNIEnv *env, - jobject obj, - jlong ctx) -{ - // Not support by D3D - return 0; -} - - -extern "C" JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_getTextureUnitCount( +jint JNICALL Java_javax_media_j3d_NativePipeline_getTextureUnitCount( JNIEnv *env, jobject obj, jlong ctx) @@ -871,12 +944,12 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_getTextureUnitCount( extern "C" JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( +jlong JNICALL Java_javax_media_j3d_NativePipeline_createOffScreenBuffer( JNIEnv *env, jobject obj, + jobject cv, jlong ctx, jlong display, - jint window, jlong fbConfigListPtr, jint width, jint height) @@ -890,18 +963,18 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( GetCtx2(); d3dCtx->d3dPresent.BackBufferWidth = width; d3dCtx->d3dPresent.BackBufferHeight = height; - return SUCCEEDED(d3dCtx->resetSurface(env, obj)); + return SUCCEEDED(d3dCtx->resetSurface(env, cv)); } } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_destroyContext( +void JNICALL Java_javax_media_j3d_NativePipeline_destroyContext( JNIEnv *env, - jclass cl, + jobject obj, jlong display, - jint window, + jlong window, jlong ctx) { GetDevice(); @@ -911,36 +984,45 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyContext( delete d3dCtx; unlock(); - Java_javax_media_j3d_Renderer_D3DCleanUp(env, cl); + Java_javax_media_j3d_NativePipeline_cleanupRenderer(env, obj); } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_destroyOffScreenBuffer( JNIEnv *env, jobject obj, + jobject cv, jlong ctx, jlong display, jlong fbConfigListPtr, - jint window) + jlong window) { // do nothing, since the old buffer will destory // in createOffScreenBuffer + + // TODO : this means that we will hold onto the last off-screen buffer; + // we should clean this up at some point } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_readOffScreenBuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_readOffScreenBuffer( JNIEnv *env, jobject obj, + jobject cv, jlong ctx, jint format, + jint dataType, + jobject data, jint width, jint height) { + void *imageObjPtr; + GetDevice(); - if (format == FORMAT_USHORT_GRAY) { - printf("[Java 3D] readOffScreenBuffer not support FORMAT_USHORT_GRAY\n"); + if (format == IMAGE_FORMAT_USHORT_GRAY) { + printf("[Java 3D] readOffScreenBuffer not support IMAGE_FORMAT_USHORT_GRAY\n"); return; } @@ -954,32 +1036,43 @@ void JNICALL Java_javax_media_j3d_Canvas3D_readOffScreenBuffer( } } - jclass cv_class = env->GetObjectClass(obj); + /* 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); + + + } + else { + imageObjPtr = (void *)env->GetDirectBufferAddress(data); + + /* TODO --- Do something .... */ + } - jfieldID byteData_field = env->GetFieldID(cv_class, "byteBuffer", "[B"); - jbyteArray byteData_array = (jbyteArray) env->GetObjectField(obj, byteData_field); - jbyte *byteData = (jbyte *) env->GetPrimitiveArrayCritical( - byteData_array, NULL); - copyDataFromSurface(format, 0, 0, width, height, byteData, - d3dCtx->backSurface); - env->ReleasePrimitiveArrayCritical(byteData_array, byteData, 0); - return; + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + env->ReleasePrimitiveArrayCritical((jarray)data, imageObjPtr, 0); + } + return; } extern "C" JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_resizeD3DCanvas( +jint JNICALL Java_javax_media_j3d_NativePipeline_resizeD3DCanvas( JNIEnv *env, jobject obj, + jobject cv, jlong ctx) { int status; GetCtx2(); lock(); - status = d3dCtx->resize(env, obj); + status = d3dCtx->resize(env, cv); unlock(); return status; @@ -987,16 +1080,17 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_resizeD3DCanvas( extern "C" JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_toggleFullScreenMode( +jint JNICALL Java_javax_media_j3d_NativePipeline_toggleFullScreenMode( JNIEnv *env, jobject obj, + jobject cv, jlong ctx) { int status; GetCtx2(); lock(); - status = d3dCtx->toggleMode(!d3dCtx->bFullScreen, env, obj); + status = d3dCtx->toggleMode(!d3dCtx->bFullScreen, env, cv); unlock(); if (status == RECREATEDFAIL) { return RECREATEDDRAW; @@ -1005,7 +1099,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_toggleFullScreenMode( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setFullSceneAntialiasing( +void JNICALL Java_javax_media_j3d_NativePipeline_setFullSceneAntialiasing( JNIEnv *env, jobject obj, jlong ctx, @@ -1019,7 +1113,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setFullSceneAntialiasing( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Renderer_D3DCleanUp( +void JNICALL Java_javax_media_j3d_NativePipeline_cleanupRenderer( JNIEnv *env, jobject obj) { @@ -1035,24 +1129,26 @@ void JNICALL Java_javax_media_j3d_Renderer_D3DCleanUp( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_ImageComponent2DRetained_freeD3DSurface( +void JNICALL Java_javax_media_j3d_NativePipeline_freeD3DSurface( JNIEnv *env, + jobject obj, jobject image, jint hashCode) { - + /* lockImage(); D3dImageComponent::remove(&RasterList, hashCode); unlockImage(); lockBackground(); D3dImageComponent::remove(&BackgroundImageList, hashCode); unlockBackground(); + */ } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_beginScene( +void JNICALL Java_javax_media_j3d_NativePipeline_beginScene( JNIEnv *env, jobject obj, jlong ctx) @@ -1063,7 +1159,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_beginScene( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_endScene( +void JNICALL Java_javax_media_j3d_NativePipeline_endScene( JNIEnv *env, jobject obj, jlong ctx) @@ -1074,7 +1170,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_endScene( extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_validGraphicsMode( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_validGraphicsMode( JNIEnv *env, jobject obj) { @@ -1082,4 +1178,4 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_validGraphicsMode( EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devMode); return (devMode.dmBitsPerPel > 8); -}
\ No newline at end of file +} diff --git a/src/native/d3d/D3dCtx.cpp b/src/native/d3d/D3dCtx.cpp index 32776c4..8ad3b2f 100644 --- a/src/native/d3d/D3dCtx.cpp +++ b/src/native/d3d/D3dCtx.cpp @@ -65,6 +65,7 @@ D3dCtx::D3dCtx(JNIEnv* env, jobject obj, HWND _hwnd, BOOL _offScreen, zWriteEnable = TRUE; zEnable = TRUE; + // TODO: THIS NEEDS TO BE REDONE WITH INFO FROM THE FBCONFIG PTR // this is the pixelFormat return from NativeConfigTemplate. minZDepth = vid & 0x3fffffff; if (vid & 0x80000000) @@ -269,6 +270,7 @@ VOID D3dCtx::releaseTexture() cubeMapTableLen = 0; unlockSurfaceList(); + /* lockImage(); D3dImageComponent::remove(&RasterList, this); unlockImage(); @@ -276,6 +278,7 @@ VOID D3dCtx::releaseTexture() lockBackground(); D3dImageComponent::remove(&BackgroundImageList, this); unlockBackground(); + */ // free list0 freeList(); @@ -346,8 +349,10 @@ VOID D3dCtx::releaseVB() VOID D3dCtx::release() { + /* D3dImageComponent::removeAll(&BackgroundImageList); D3dImageComponent::removeAll(&RasterList); + */ releaseTexture(); SafeFree(bindTextureId); bindTextureIdLen = 0; diff --git a/src/native/d3d/D3dDriverInfo.cpp b/src/native/d3d/D3dDriverInfo.cpp index fdad7a9..57d7b8a 100644 --- a/src/native/d3d/D3dDriverInfo.cpp +++ b/src/native/d3d/D3dDriverInfo.cpp @@ -362,8 +362,10 @@ VOID D3dDriverInfo::initialize(JNIEnv *env) D3dCtx::setImplicitMultisamplingProperty(env); + /* RasterList.init(); BackgroundImageList.init(); + */ // Setup Global constant Ambient light ambientLight.Type = D3DLIGHT_DIRECTIONAL; diff --git a/src/native/d3d/D3dImageComponent.hpp b/src/native/d3d/D3dImageComponent.hpp index fef2ed8..8226d30 100644 --- a/src/native/d3d/D3dImageComponent.hpp +++ b/src/native/d3d/D3dImageComponent.hpp @@ -46,7 +46,8 @@ public: static VOID removeAll(D3dImageComponent *list); }; -extern D3dImageComponent RasterList; -extern D3dImageComponent BackgroundImageList; - +/* + extern D3dImageComponent RasterList; + extern D3dImageComponent BackgroundImageList; +*/ #endif diff --git a/src/native/d3d/D3dUtil.cpp b/src/native/d3d/D3dUtil.cpp index 236827a..12ff9d6 100644 --- a/src/native/d3d/D3dUtil.cpp +++ b/src/native/d3d/D3dUtil.cpp @@ -966,8 +966,8 @@ void copyDataFromSurface(jint internalFormat, (yoffset*lockedRect.Pitch); - if ((internalFormat == FORMAT_BYTE_RGBA) || - (internalFormat == FORMAT_BYTE_RGB)) { + if ((internalFormat == IMAGE_FORMAT_BYTE_RGBA) || + (internalFormat == IMAGE_FORMAT_BYTE_RGB)) { dstPitch = subWidth << 2; destRow += (subHeight-1)*dstPitch; @@ -1208,7 +1208,7 @@ void copyDataFromSurface(jint internalFormat, } } } - } else if (internalFormat == FORMAT_BYTE_LA) { + } else if (internalFormat == IMAGE_FORMAT_BYTE_LA) { int gshift = firstBit(ddpf.dwGBitMask) + ucountBits(ddpf.dwGBitMask) - 8; int ashift = firstBit(ddpf.dwRGBAlphaBitMask) + @@ -1370,7 +1370,7 @@ void copyDataFromSurface(jint internalFormat, } } - } else if (internalFormat == FORMAT_BYTE_GRAY) { + } else if (internalFormat == IMAGE_FORMAT_BYTE_GRAY) { int gshift = firstBit(ddpf.dwGBitMask) + ucountBits(ddpf.dwGBitMask) - 8; dstPitch = subWidth; @@ -1482,7 +1482,7 @@ void copyDataFromSurface(jint internalFormat, } } else { - // FORMAT_USHORT_GRAY + // IMAGE_FORMAT_USHORT_GRAY printf("[Java 3D] copyDataFromSurface: Format not support %d\n", internalFormat); } @@ -8997,7 +8997,7 @@ void copyDataToSurface(jint storedFormat, } int offset = tilew*imgYOffset + imgXOffset; switch (storedFormat) { - case FORMAT_BYTE_RGBA : + case IMAGE_FORMAT_BYTE_RGBA : // This is the one we use when byReference = false copyDataToSurfaceRGBA(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, @@ -9006,7 +9006,7 @@ void copyDataToSurface(jint storedFormat, xoffset, yoffset, xlimit, ylimit, tilew); break; - case FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGB: copyDataToSurfaceRGB(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, @@ -9014,7 +9014,7 @@ void copyDataToSurface(jint storedFormat, xoffset, yoffset, xlimit, ylimit, tilew); break; - case FORMAT_BYTE_ABGR: + case IMAGE_FORMAT_BYTE_ABGR: copyDataToSurfaceABGR(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, @@ -9022,7 +9022,7 @@ void copyDataToSurface(jint storedFormat, xoffset, yoffset, xlimit, ylimit, tilew); break; - case FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_BGR: copyDataToSurfaceBGR(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, @@ -9030,7 +9030,7 @@ void copyDataToSurface(jint storedFormat, xoffset, yoffset, xlimit, ylimit, tilew); break; - case FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_LA: copyDataToSurfaceLA(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, @@ -9038,7 +9038,7 @@ void copyDataToSurface(jint storedFormat, xoffset, yoffset, xlimit, ylimit, tilew); break; - case FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_BYTE_GRAY: copyDataToSurfaceGray(internalFormat, &ddpf, (unsigned char *) lockedRect.pBits, lockedRect.Pitch, @@ -10839,7 +10839,7 @@ void copyDataToVolume(jint storedFormat, switch (storedFormat) { - case FORMAT_BYTE_RGBA : + case IMAGE_FORMAT_BYTE_RGBA : // This is the one we use when byReference = false data += (imgOffset << 2); srcSlicePitch <<= 2; @@ -10857,7 +10857,7 @@ void copyDataToVolume(jint storedFormat, } break; - case FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGB: data += (imgOffset*3); srcSlicePitch *= 3; @@ -10873,7 +10873,7 @@ void copyDataToVolume(jint storedFormat, data += srcSlicePitch; } break; - case FORMAT_BYTE_ABGR: + case IMAGE_FORMAT_BYTE_ABGR: data += (imgOffset << 2); srcSlicePitch <<= 2; @@ -10889,7 +10889,7 @@ void copyDataToVolume(jint storedFormat, data += srcSlicePitch; } break; - case FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_BGR: data += (imgOffset*3); srcSlicePitch *= 3; @@ -10905,7 +10905,7 @@ void copyDataToVolume(jint storedFormat, data += srcSlicePitch; } break; - case FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_LA: data += (imgOffset << 1); srcSlicePitch <<= 1; @@ -10921,7 +10921,7 @@ void copyDataToVolume(jint storedFormat, data += srcSlicePitch; } break; - case FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_BYTE_GRAY: data += imgOffset; for (i = zoffset; i < zlimit; i++) { @@ -11044,17 +11044,17 @@ LPDIRECT3DTEXTURE9 createSurfaceFromImage(JNIEnv *env, switch (internalFormat) { - case FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_RGBA: internalFormat = J3D_RGBA; break; - case FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGB: internalFormat = J3D_RGB; break; - case FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_LA: internalFormat = LUMINANCE_ALPHA; break; - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: internalFormat = LUMINANCE; break; default: @@ -11073,7 +11073,7 @@ LPDIRECT3DTEXTURE9 createSurfaceFromImage(JNIEnv *env, } if (imageYdown != NULL) { - if (storedFormat != FORMAT_USHORT_GRAY) { + if (storedFormat != IMAGE_FORMAT_USHORT_GRAY) { jbyte *byteData = (jbyte *) (env->GetPrimitiveArrayCritical( imageYdown, NULL)); copyDataToSurface(storedFormat, internalFormat, 0, 0, 0, 0, @@ -11367,7 +11367,7 @@ void copyDataToCubeMap(jint storedFormat, int offset = tilew*imgYOffset + imgXOffset; switch (storedFormat) { - case FORMAT_BYTE_RGBA : + case IMAGE_FORMAT_BYTE_RGBA : // This is the one we use when byReference = false if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { @@ -11391,7 +11391,7 @@ void copyDataToCubeMap(jint storedFormat, xlimit, ylimit, tilew); } break; - case FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGB: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { copyDataToSurfaceRGB(internalFormat, &ddpf, @@ -11410,7 +11410,7 @@ void copyDataToCubeMap(jint storedFormat, xlimit, ylimit, tilew); } break; - case FORMAT_BYTE_ABGR: + case IMAGE_FORMAT_BYTE_ABGR: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { copyDataToSurfaceABGR(internalFormat, &ddpf, @@ -11429,7 +11429,7 @@ void copyDataToCubeMap(jint storedFormat, xlimit, ylimit, tilew); } break; - case FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_BGR: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { copyDataToSurfaceBGR(internalFormat, &ddpf, @@ -11448,7 +11448,7 @@ void copyDataToCubeMap(jint storedFormat, xlimit, ylimit, tilew); } break; - case FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_LA: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { copyDataToSurfaceLA(internalFormat, &ddpf, @@ -11467,7 +11467,7 @@ void copyDataToCubeMap(jint storedFormat, xlimit, ylimit, tilew); } break; - case FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_BYTE_GRAY: if ((face == D3DCUBEMAP_FACE_NEGATIVE_Y) || (face == D3DCUBEMAP_FACE_POSITIVE_Y)) { copyDataToSurfaceGray(internalFormat, &ddpf, diff --git a/src/native/d3d/D3dUtil.hpp b/src/native/d3d/D3dUtil.hpp index 0117e47..c0961a4 100644 --- a/src/native/d3d/D3dUtil.hpp +++ b/src/native/d3d/D3dUtil.hpp @@ -142,7 +142,6 @@ extern VOID unlockSurfaceList(); extern VOID freeSurface(LPDIRECT3DBASETEXTURE9 surf); extern VOID freePointer(void* surf); extern VOID freePointerList(); -extern VOID setWindowCallback(HWND topHwnd, HWND hwnd); extern char* getErrorMessage(int idx); extern HWND getTopWindow(HWND hwnd); diff --git a/src/native/d3d/GeometryArrayRetained.cpp b/src/native/d3d/GeometryArrayRetained.cpp index fcafd4b..2d947a7 100644 --- a/src/native/d3d/GeometryArrayRetained.cpp +++ b/src/native/d3d/GeometryArrayRetained.cpp @@ -3195,7 +3195,6 @@ void setTextureCoordPointers(JNIEnv *env, D3dCtx* d3dCtx, LPDIRECT3DDEVICE9 device, D3DDRAWPRIMITIVESTRIDEDDATA *strideData, - jint pass, jint texoff, jint texStride, jint ts, @@ -3204,7 +3203,6 @@ void setTextureCoordPointers(JNIEnv *env, jint texCoordMapLength, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray tunitstatemap, DWORD* vertexFormat, // Used by executeGeometryArray() & // executeIndexedGeometryArray() only @@ -3216,7 +3214,6 @@ void setTextureCoordPointers(JNIEnv *env, jintArray texindices) { - jint *texUnitStateMap = NULL; jint *texCoordSetMapOffset = NULL; jint *initialTexIndices = NULL; jint *texCoordSetMap = NULL; @@ -3226,6 +3223,9 @@ void setTextureCoordPointers(JNIEnv *env, BOOL nonVAGeom = (verts != NULL); int texSetInVB = 0; + // TODO : + int pass = -1; + /* * In case of automatic texture generation, * (vformat & GA_TEXTURE_COORDINATE) may equal to zero so we @@ -3256,259 +3256,167 @@ void setTextureCoordPointers(JNIEnv *env, initialTexIndices = (jint *) env->GetPrimitiveArrayCritical(texindices, NULL); } - if (pass >= 0) { - /* - * Single texture coordinate used or in multi-pass mode. - * In multi-pass mode, texture stage 0 is set so we - * should not use - * setTextureStage(d3dCtx, device, 0, pass); - */ - - genMode = setTextureStage(d3dCtx, device, 0, 0); - -#ifdef TEXDEBUG - printf("*** Single Pass *** %d, nonVAGeom %d, buildDL %d, numActiveTexUnit, texCoordMapLength %d, texDef %d, genMode %d \n", pass, nonVAGeom, (d3dCtx->currDisplayListID > 0), numActiveTexUnit, texCoordMapLength, textureDefined, genMode); -#endif - - if ((texCoordMapLength > 0) && - (pass < texCoordMapLength)) { - offsetOrTexset = (nonVAGeom ? - texCoordSetMapOffset[pass] : texCoordSetMap[pass]); - } else { - // TexUnitState is not used or disable, - // so by default we use texUnitIndex 0 - offsetOrTexset = 0; - } - - if (genMode != TEX_OBJ_LINEAR) { - // Only Object Linear Mode will not use DisplayList at - // all. That mean genMode must be correctly set before - // enter this Geometry execute() function/ - // In non displaylist mode genMode may not set correctly - // when so we can't rely on it. - if (textureDefined) { - if (offsetOrTexset != -1) { - if (nonVAGeom) { - // In executeGeometryArray() or executeIndexedGeometryArray() - strideData->textureCoordsPtr[0] = - &verts[texoff + offsetOrTexset]; - } else if (initialTexIndices != NULL) { - // executeGeometryArrayVA() - strideData->textureCoordsPtr[0] = - &(texCoordPointer[offsetOrTexset][initialTexIndices[offsetOrTexset]*texStride]); - } else { // executeIndexedGeometryArrayVA() - strideData->textureCoordsPtr[0] = - &(texCoordPointer[offsetOrTexset][0]); - } - - strideData->textureCoordsStride[0] = texStride; - *vertexFormat |= (TexFormatSizeTable[ts] << 16); - d3dCtx->texSetUsed = 1; - strideData->texCoordPosition[0] = offsetOrTexset; - d3dCtx->texStride[0] = ts; - setTexTransformStageFlag(d3dCtx, device, 0, ts, genMode); -#ifdef TEXDEBUG - printf("[pass 0] Non Object Linear, texDefined, ts=%d\n", ts); -#endif - } - } else { - // may be automatic texture generation used - // TexSetUsed remain unchange i.e. 0 since we will not - // allocate VB space for texture coords. - setTexTransformStageFlag(d3dCtx, device, 0, - d3dCtx->texCoordFormat[0], genMode); -#ifdef TEXDEBUG - printf("[pass 0] Non Object Linear, No texDefined, ts=%d\n", - d3dCtx->texCoordFormat[0]); -#endif - } - } else { - // Automatic texture generation Object Linear - // strideData->textureCoordsPtr[0] & - // strideData->textureCoordsStride[0] - // are not use in VertexBuffer texture copy so - // it doesn't matter to set them using default. - setDefaultTextureCoordPointers(d3dCtx, strideData, - vertexFormat, - d3dCtx->texCoordFormat[0], - genMode, 0); - setTexTransformStageFlag(d3dCtx, device, 0, - d3dCtx->texCoordFormat[0], genMode); - d3dCtx->texSetUsed = 1; -#ifdef TEXDEBUG - printf("[pass 0] Object Linear, ts=%d\n", d3dCtx->texCoordFormat[0]); -#endif - } - texSetInVB = d3dCtx->texSetUsed; - - } else { - // DisplayList is used for multiple texture single pass mode - // Or when go through the VertexArray in OGL, pass = -1 - int tus; + // DisplayList is used for multiple texture single pass mode + // Or when go through the VertexArray in OGL, pass = -1 + int tus; #ifdef TEXDEBUG - printf("*** Multiple Pass *** %d, nonVAGeom %d, buildDL %d, numActiveTexUnit %d, texCoordMapLength %d, texDef %d\n", pass, + printf("*** Multiple Pass *** %d, nonVAGeom %d, buildDL %d, numActiveTexUnit %d, texCoordMapLength %d, texDef %d\n", pass, nonVAGeom, (d3dCtx->currDisplayListID > 0), numActiveTexUnit, texCoordMapLength, textureDefined); #endif - if (tunitstatemap != NULL) { - texUnitStateMap = (jint *) env->GetPrimitiveArrayCritical(tunitstatemap, NULL); - } - for (textureUnitIndex = 0; textureUnitIndex < numActiveTexUnit; - textureUnitIndex++) { - tus = (texUnitStateMap != NULL ? - texUnitStateMap[textureUnitIndex]: textureUnitIndex); + for (textureUnitIndex = 0; textureUnitIndex < numActiveTexUnit; + textureUnitIndex++) { - if (d3dCtx->currDisplayListID > 0) { - genMode = setTextureStage(d3dCtx, device, - textureUnitIndex, tus); - } else { - // This happen when we switch from displayList to - // vertexArray mode. The displayList is already - // built with 1-1 mapping so we can't use the - // textureUnitIndex Mapping - genMode = setTextureStage(d3dCtx, device, - textureUnitIndex, - textureUnitIndex); - } + tus = textureUnitIndex; + + if (d3dCtx->currDisplayListID > 0) { + genMode = setTextureStage(d3dCtx, device, + textureUnitIndex, tus); + } else { + // This happen when we switch from displayList to + // vertexArray mode. The displayList is already + // built with 1-1 mapping so we can't use the + // textureUnitIndex Mapping + genMode = setTextureStage(d3dCtx, device, + textureUnitIndex, + textureUnitIndex); + } #ifdef TEXDEBUG - printf("[pass %d] genMode %d, tus %d\n", textureUnitIndex, - genMode, tus); -#endif - if (genMode != TEX_OBJ_LINEAR) { - if (textureDefined) { - if (tus < texCoordMapLength) { - offsetOrTexset = (nonVAGeom ? - texCoordSetMapOffset[tus]:texCoordSetMap[tus]); - - if (offsetOrTexset != -1) { - if (nonVAGeom) { - strideData->textureCoordsPtr[textureUnitIndex] = - &verts[texoff + offsetOrTexset]; - } else if (initialTexIndices != NULL) { - strideData->textureCoordsPtr[textureUnitIndex] = - &(texCoordPointer[offsetOrTexset][initialTexIndices[offsetOrTexset]*texStride]); - } else { - strideData->textureCoordsPtr[textureUnitIndex] = - &(texCoordPointer[offsetOrTexset][0]); - } - strideData->textureCoordsStride[textureUnitIndex] = texStride; - strideData->texCoordPosition[textureUnitIndex] - = offsetOrTexset; - *vertexFormat |= (TexFormatSizeTable[ts] << (textureUnitIndex*2 + 16)); - d3dCtx->texStride[textureUnitIndex] = ts; - setTexTransformStageFlag(d3dCtx, device, - textureUnitIndex, - ts, genMode); - texSetInVB++; -#ifdef TEXDEBUG - printf("[pass %d] Non Object Linear, texDefined, ts=%d, tus %d\n", textureUnitIndex, ts, tus); + printf("[pass %d] genMode %d, tus %d\n", textureUnitIndex, + genMode, tus); #endif + if (genMode != TEX_OBJ_LINEAR) { + if (textureDefined) { + if (tus < texCoordMapLength) { + offsetOrTexset = (nonVAGeom ? + texCoordSetMapOffset[tus]:texCoordSetMap[tus]); + + if (offsetOrTexset != -1) { + if (nonVAGeom) { + strideData->textureCoordsPtr[textureUnitIndex] = + &verts[texoff + offsetOrTexset]; + } else if (initialTexIndices != NULL) { + strideData->textureCoordsPtr[textureUnitIndex] = + &(texCoordPointer[offsetOrTexset][initialTexIndices[offsetOrTexset]*texStride]); } else { - // This texture status is disable, this - // should not happen in D3D since - // TextureBin always compact unused state - // - unless when DisplayList is build and - // automatic texture generation - // used. Since if DL use - // updateAttributes() not yet invoke to - // set genMode correctly. - if (debug && (d3dCtx->currDisplayListID <= 0)) { - printf("[Java3D] TextureBin not compact textureUnitState correctly, numActiveTex %d, disableUnit %d, current mapped Texture Unit %d\n", numActiveTexUnit, tus, textureUnitIndex); - } - setDefaultTextureCoordPointers(d3dCtx, strideData, - vertexFormat, ts, - genMode, - textureUnitIndex); - setTexTransformStageFlag(d3dCtx, device, - textureUnitIndex, - ts, genMode); - texSetInVB++; + strideData->textureCoordsPtr[textureUnitIndex] = + &(texCoordPointer[offsetOrTexset][0]); + } + strideData->textureCoordsStride[textureUnitIndex] = texStride; + strideData->texCoordPosition[textureUnitIndex] + = offsetOrTexset; + *vertexFormat |= (TexFormatSizeTable[ts] << (textureUnitIndex*2 + 16)); + d3dCtx->texStride[textureUnitIndex] = ts; + setTexTransformStageFlag(d3dCtx, device, + textureUnitIndex, + ts, genMode); + texSetInVB++; #ifdef TEXDEBUG - printf("[pass %d] Non Object Linear, texDefined, ts=%d\n", textureUnitIndex, ts); + printf("[pass %d] Non Object Linear, texDefined, ts=%d, tus %d\n", textureUnitIndex, ts, tus); #endif - } } else { - // Internal error, should not happen. - if (debug) { - printf("[Java3D] TextureCoordMapLength length %d, is smaller than texture unit %d, map texture unit %d\n", texCoordMapLength, tus, textureUnitIndex); + // This texture status is disable, this + // should not happen in D3D since + // TextureBin always compact unused state + // - unless when DisplayList is build and + // automatic texture generation + // used. Since if DL use + // updateAttributes() not yet invoke to + // set genMode correctly. + if (debug && (d3dCtx->currDisplayListID <= 0)) { + printf("[Java3D] TextureBin not compact textureUnitState correctly, numActiveTex %d, disableUnit %d, current mapped Texture Unit %d\n", numActiveTexUnit, tus, textureUnitIndex); } setDefaultTextureCoordPointers(d3dCtx, strideData, vertexFormat, ts, - TEX_GEN_INVALID, + genMode, textureUnitIndex); setTexTransformStageFlag(d3dCtx, device, - textureUnitIndex, ts, - genMode); - + textureUnitIndex, + ts, genMode); texSetInVB++; #ifdef TEXDEBUG - printf("[pass %d] Non Object Linear, texDefined, offset/texset = -1, ts=%d\n", textureUnitIndex, ts); + printf("[pass %d] Non Object Linear, texDefined, ts=%d\n", textureUnitIndex, ts); #endif } } else { - // May be in automatically texture coordinate - // generation mode. - // May have trouble if automatically texture - // coordinate not used. Note that we pass ts = 0 - // so that copyVertexToVB() will not inc. the - // stride for this unused tex stage. - - // It is also the case in buildGA() case when - // numActiveTexUnit is 1 by default even though - // texture is not used. - /* - if ((d3dCtx->currDisplayListID <= 0) && - (genMode == TEX_GEN_NONE)) { - // application error, use default TexCoord - setDefaultTextureCoordPointers(d3dCtx, strideData, - vertexFormat, - ts, - TEX_GEN_NONE, - textureUnitIndex); - texSetInVB++; - } - */ - + // Internal error, should not happen. + if (debug) { + printf("[Java3D] TextureCoordMapLength length %d, is smaller than texture unit %d, map texture unit %d\n", texCoordMapLength, tus, textureUnitIndex); + } setDefaultTextureCoordPointers(d3dCtx, strideData, - vertexFormat, - 0, - // This must be < 0 - TEX_GEN_AUTO, + vertexFormat, ts, + TEX_GEN_INVALID, textureUnitIndex); - setTexTransformStageFlag(d3dCtx, device, textureUnitIndex, - d3dCtx->texCoordFormat[textureUnitIndex], genMode); - - + setTexTransformStageFlag(d3dCtx, device, + textureUnitIndex, ts, + genMode); + + texSetInVB++; #ifdef TEXDEBUG - printf("[pass %d] Non Object Linear, No texDefined, ts=0\n", textureUnitIndex); + printf("[pass %d] Non Object Linear, texDefined, offset/texset = -1, ts=%d\n", textureUnitIndex, ts); #endif } } else { - // Automatic Texture generation Object Linear is used + // May be in automatically texture coordinate + // generation mode. + // May have trouble if automatically texture + // coordinate not used. Note that we pass ts = 0 + // so that copyVertexToVB() will not inc. the + // stride for this unused tex stage. + + // It is also the case in buildGA() case when + // numActiveTexUnit is 1 by default even though + // texture is not used. + /* + if ((d3dCtx->currDisplayListID <= 0) && + (genMode == TEX_GEN_NONE)) { + // application error, use default TexCoord + setDefaultTextureCoordPointers(d3dCtx, strideData, + vertexFormat, + ts, + TEX_GEN_NONE, + textureUnitIndex); + texSetInVB++; + } + */ + setDefaultTextureCoordPointers(d3dCtx, strideData, vertexFormat, - d3dCtx->texCoordFormat[textureUnitIndex], - genMode, + 0, + // This must be < 0 + TEX_GEN_AUTO, textureUnitIndex); setTexTransformStageFlag(d3dCtx, device, textureUnitIndex, d3dCtx->texCoordFormat[textureUnitIndex], genMode); - texSetInVB++; + + #ifdef TEXDEBUG - printf("[pass %d] Object Linear, No texDefined, ts=%d\n", textureUnitIndex, d3dCtx->texCoordFormat[textureUnitIndex]); + printf("[pass %d] Non Object Linear, No texDefined, ts=0\n", textureUnitIndex); #endif } - } - d3dCtx->texSetUsed = numActiveTexUnit; + } else { + // Automatic Texture generation Object Linear is used + setDefaultTextureCoordPointers(d3dCtx, strideData, + vertexFormat, + d3dCtx->texCoordFormat[textureUnitIndex], + genMode, + textureUnitIndex); + setTexTransformStageFlag(d3dCtx, device, textureUnitIndex, + d3dCtx->texCoordFormat[textureUnitIndex], genMode); + texSetInVB++; #ifdef TEXDEBUG - printf("No of texSetInVB %d, numActiveTexUnit %d\n", - texSetInVB, numActiveTexUnit); + printf("[pass %d] Object Linear, No texDefined, ts=%d\n", textureUnitIndex, d3dCtx->texCoordFormat[textureUnitIndex]); #endif - if (texUnitStateMap != NULL) { - env->ReleasePrimitiveArrayCritical(tunitstatemap, texUnitStateMap, NULL); } } + d3dCtx->texSetUsed = numActiveTexUnit; +#ifdef TEXDEBUG + printf("No of texSetInVB %d, numActiveTexUnit %d\n", + texSetInVB, numActiveTexUnit); +#endif + if (texCoordSetMapOffset != NULL) { env->ReleasePrimitiveArrayCritical(texUnitOffset, @@ -3540,7 +3448,6 @@ void executeGeometryArrayVA( jboolean isNonUniformScale, jboolean modAlpha, float alpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint vcount, jint vformat, @@ -3553,11 +3460,9 @@ void executeGeometryArrayVA( jbyte* bclrs, jint initialNormalIndex, jfloat* norms, - int pass, // or texUnitIndex int texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jintArray texindices, jint texStride, jfloat** texCoordPointer, @@ -3645,13 +3550,12 @@ void executeGeometryArrayVA( // setup texture pointer setTextureCoordPointers(env, d3dCtx, device, &strideData, - pass, 0, texStride, ts, + 0, texStride, ts, textureDefined, tcoordsetmap, texCoordMapLength, NULL, numActiveTexUnit, - tunitstatemap, &vertexFormat, NULL, texCoordPointer, texindices); @@ -3688,14 +3592,13 @@ void executeGeometryArrayVA( /* execute geometry array with java array format */ extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_executeVABuffer( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint vcount, jint vformat, @@ -3712,11 +3615,9 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( jintArray vertexAttrSizes, jintArray vertexAttrIndices, jobjectArray vertexAttrData, - jint pass, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jintArray texindices, jint texStride, jobjectArray texCoords, @@ -3788,13 +3689,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( } executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, - isNonUniformScale, false, 0, multiScreen, ignoreVertexColors, + isNonUniformScale, false, 0, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, norms, - pass, texCoordMapLength, - tcoordsetmap,numActiveTexUnit, tunitstatemap, + texCoordMapLength, + tcoordsetmap,numActiveTexUnit, texindices,texStride,texCoordPointer, NULL, NULL, cdirty); @@ -3806,14 +3707,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( +void JNICALL Java_javax_media_j3d_NativePipeline_executeVA( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint vcount, jint vformat, @@ -3829,12 +3729,10 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( jint vertexAttrCount, jintArray vertexAttrSizes, jintArray vertexAttrIndices, - jobjectArray vertexAttrData, - jint pass, + jobjectArray vertexAttrData, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jintArray texindices, jint texStride, jobjectArray texCoords, @@ -3899,12 +3797,12 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( } executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, false, 0, - multiScreen, ignoreVertexColors, + ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, - norms, pass, texCoordMapLength, - tcoordsetmap,numActiveTexUnit, tunitstatemap, + norms, texCoordMapLength, + tcoordsetmap,numActiveTexUnit, texindices,texStride,texCoordPointer, NULL, NULL, cdirty); @@ -3936,57 +3834,38 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVA( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setGlobalAlpha( - JNIEnv *env, - jobject obj, - jlong ctx, - jfloat alpha) -{ - // not use in D3D -} - - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_disableGlobalAlpha( +void JNICALL Java_javax_media_j3d_NativePipeline_disableGlobalAlpha( JNIEnv *env, jobject obj, jlong ctx, + jobject geo, jint vformat, jboolean useAlpha, jboolean ignoreVertexColors) { - // not use in D3D + // not used in D3D } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setVertexFormat( +void JNICALL Java_javax_media_j3d_NativePipeline_setVertexFormat( JNIEnv *env, jobject obj, jlong ctxInfo, + jobject geo, jint vformat, jboolean useAlpha, jboolean ignoreVertexColors) { - // not use in D3D + // not used in D3D } -extern "C" JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_GeometryArrayRetained_globalAlphaSUN - (JNIEnv *env, jobject obj, jlong ctx) -{ - return JNI_FALSE; -} - - - void executeGeometryArray(JNIEnv *env, jobject obj, jlong ctx, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean modAlpha, // buildGA, should alpha be mode jfloat alpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint startVIndex, jint vcount, jint vformat, jint texCoordSetCount, @@ -3994,8 +3873,7 @@ void executeGeometryArray(JNIEnv *env, jint texCoordMapLength, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray tunitstatemap, - jfloat* verts, jfloatArray carray, jint pass, + jfloat* verts, jfloatArray carray, jdoubleArray xform, jdoubleArray nxform, jint cDirty, jboolean useAlpha) // Should alpha be sent down @@ -4108,13 +3986,12 @@ void executeGeometryArray(JNIEnv *env, // setup texture pointer setTextureCoordPointers(env, d3dCtx, device, &strideData, - pass, texoff, stride, ts, + texoff, stride, ts, (vformat & GA_TEXTURE_COORDINATE), NULL, texCoordMapLength, texUnitOffset, numActiveTexUnit, - tunitstatemap, &vertexFormat, verts, NULL, NULL); @@ -4151,12 +4028,12 @@ void executeGeometryArray(JNIEnv *env, /* - * Class: javax_media_j3d_GeometryArrayRetained + * Class: javax_media_j3d_NativePipeline * Method: buildGA * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[II[II[I[D[D[F)V */ extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, +void JNICALL Java_javax_media_j3d_NativePipeline_buildGA(JNIEnv *env, jobject obj, jlong ctx, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean updateAlpha, float alpha, @@ -4193,7 +4070,6 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, obj, ctx, geo, geo_type, isNonUniformScale, updateAlpha, alpha, - false, ignoreVertexColors, startVIndex, vcount, @@ -4203,9 +4079,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, texCoordMapLength, texUnitOffset, texCoordMapLength, - NULL, verts, NULL, - -1, xform, nxform, javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED, false); @@ -4216,20 +4090,17 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, +void JNICALL Java_javax_media_j3d_NativePipeline_execute(JNIEnv *env, jobject obj, jlong ctx,jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint startVIndex, jint vcount, jint vformat, jint texCoordSetCount, jintArray texCoordSetMapArray, jint texCoordMapLength, jintArray texUnitOffset, - jint numActiveTexUnit, - jintArray tunitstatemap, - jint vertexAttrCount, jintArray vertexAttrSizes, - jfloatArray varray, jfloatArray carray, - jint texUnitIndex, jint cDirty) + jint numActiveTexUnit, + jint vertexAttrCount, jintArray vertexAttrSizes, + jfloatArray varray, jfloatArray carray, jint cDirty) { jfloat *verts = NULL; @@ -4244,13 +4115,12 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, executeGeometryArray(env, obj, ctx, geo, geo_type, isNonUniformScale, false, - 0, multiScreen, - ignoreVertexColors, startVIndex, + 0, ignoreVertexColors, startVIndex, vcount, vformat, texCoordSetCount, texCoordSetMapArray, texCoordMapLength, texUnitOffset, - numActiveTexUnit, tunitstatemap, - verts, carray, texUnitIndex, NULL, NULL, cDirty,useAlpha); + numActiveTexUnit, + verts, carray, NULL, NULL, cDirty,useAlpha); env->ReleasePrimitiveArrayCritical( varray, verts, 0); @@ -4259,10 +4129,9 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, /* interleaved data with nio buffer as data format */ extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeInterleavedBuffer(JNIEnv *env, +void JNICALL Java_javax_media_j3d_NativePipeline_executeInterleavedBuffer(JNIEnv *env, jobject obj, jlong ctx, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, + jboolean isNonUniformScale, jboolean useAlpha, jboolean ignoreVertexColors, jint startVIndex, jint vcount, jint vformat, @@ -4270,9 +4139,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeInterleavedBuffer jintArray texCoordSetMapArray, jint texCoordMapLength, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray tunitstatemap, - jobject varray, jfloatArray carray, - jint texUnitIndex, jint cDirty) { + jobject varray, jfloatArray carray, jint cDirty) { jfloat *verts = NULL; @@ -4289,20 +4156,22 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeInterleavedBuffer executeGeometryArray(env, obj, ctx, geo, geo_type, isNonUniformScale, false, - 0, multiScreen, - ignoreVertexColors, startVIndex, + 0, ignoreVertexColors, startVIndex, vcount, vformat, texCoordSetCount, texCoordSetMapArray, texCoordMapLength, texUnitOffset, - numActiveTexUnit, tunitstatemap, - verts, carray, texUnitIndex, NULL, NULL, cDirty,useAlpha); + numActiveTexUnit, + verts, carray, NULL, NULL, cDirty,useAlpha); } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_freeD3DArray - (JNIEnv *env, jobject geo, jboolean deleteVB) +void JNICALL Java_javax_media_j3d_NativePipeline_freeD3DArray( + JNIEnv *env, + jobject obj, + jobject geo, + jboolean deleteVB) { lockGeometry(); @@ -4340,7 +4209,6 @@ void executeIndexedGeometryArray(JNIEnv *env, jboolean isNonUniformScale, jboolean modAlpha, // buildGA, should alpha be mode jfloat alpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint vcount, jint vformat, @@ -4349,8 +4217,7 @@ void executeIndexedGeometryArray(JNIEnv *env, jint texCoordMapLength, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray tunitstatemap, - jfloat* verts, jfloatArray carray, jint pass, + jfloat* verts, jfloatArray carray, jdoubleArray xform, jdoubleArray nxform, jint cDirty, jboolean useAlpha, @@ -4463,13 +4330,12 @@ void executeIndexedGeometryArray(JNIEnv *env, // setup texture pointer setTextureCoordPointers(env, d3dCtx, device, &strideData, - pass, texoff, stride, ts, + texoff, stride, ts, (vformat & GA_TEXTURE_COORDINATE), NULL, texCoordMapLength, texUnitOffset, numActiveTexUnit, - tunitstatemap, &vertexFormat, verts, NULL, NULL); @@ -4514,12 +4380,11 @@ void executeIndexedGeometryArray(JNIEnv *env, extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometry( +void JNICALL Java_javax_media_j3d_NativePipeline_executeIndexedGeometry( JNIEnv *env, jobject obj, jlong ctx, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint indexCount, @@ -4530,9 +4395,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jintArray texCoordSetMapArray, jint texCoordMapLength, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray tunitstatemap, - jfloatArray varray, jfloatArray carray, - jint texUnitIndex, jint cDirty, + jfloatArray varray, jfloatArray carray, jint cDirty, jintArray indexCoord) { jfloat *verts = NULL; @@ -4547,7 +4410,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo executeIndexedGeometryArray(env, obj, ctx, geo, geo_type, isNonUniformScale, - false, 0, multiScreen, + false, 0, ignoreVertexColors, vcount, vformat, texCoordSetCount, @@ -4555,10 +4418,8 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo texCoordMapLength, texUnitOffset, numActiveTexUnit, - tunitstatemap, verts, carray, - texUnitIndex, NULL, NULL, cDirty, useAlpha, @@ -4570,12 +4431,11 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryBuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_executeIndexedGeometryBuffer( JNIEnv *env, jobject obj, jlong ctx, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint indexCount, @@ -4584,9 +4444,8 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jintArray texCoordSetMapArray, jint texCoordMapLength, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray tunitstatemap, jobject varray, jfloatArray carray, - jint texUnitIndex, jint cDirty, + jint cDirty, jintArray indexCoord) { jfloat *verts = NULL; @@ -4601,7 +4460,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo executeIndexedGeometryArray(env, obj, ctx, geo, geo_type, isNonUniformScale, - false, 0, multiScreen, + false, 0, ignoreVertexColors, vcount, vformat, texCoordSetCount, @@ -4609,10 +4468,8 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo texCoordMapLength, texUnitOffset, numActiveTexUnit, - tunitstatemap, verts, carray, - texUnitIndex, NULL, NULL, cDirty, useAlpha, @@ -4623,7 +4480,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeometry( +void JNICALL Java_javax_media_j3d_NativePipeline_buildIndexedGeometry( JNIEnv *env, jobject obj, jlong ctx, jobject geo, jint geo_type, @@ -4661,7 +4518,6 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome executeIndexedGeometryArray(env, obj, ctx, geo, geo_type, isNonUniformScale, updateAlpha, alpha, - false, ignoreVertexColors, vertexCount, vformat, @@ -4669,10 +4525,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeome texCoordSetMapArray, texCoordMapLength, texUnitOffset, - texCoordMapLength, - NULL, + texCoordMapLength, verts, - NULL, -1, + NULL, xform, nxform, javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED| javax_media_j3d_GeometryArrayRetained_INDEX_CHANGED, @@ -4694,7 +4549,6 @@ void executeIndexedGeometryArrayVA( jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint indexCount, @@ -4705,12 +4559,10 @@ void executeIndexedGeometryArrayVA( jdouble* dverts, jfloat* fclrs, jbyte* bclrs, - jfloat* norms, - jint pass, + jfloat* norms, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jint texStride, jfloat** texCoordPointer, jint cDirty, @@ -4789,14 +4641,13 @@ void executeIndexedGeometryArrayVA( // setup texture pointer setTextureCoordPointers(env, d3dCtx, device, &strideData, - pass, 0, + 0, texStride, ts, textureDefined, tcoordsetmap, texCoordMapLength, NULL, numActiveTexUnit, - tunitstatemap, &vertexFormat, NULL, texCoordPointer, NULL); @@ -4816,14 +4667,13 @@ void executeIndexedGeometryArrayVA( } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryVA( +void JNICALL Java_javax_media_j3d_NativePipeline_executeIndexedGeometryVA( JNIEnv *env, jobject obj, jlong ctx, jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint indexCount, @@ -4838,11 +4688,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jint vertexAttrCount, jintArray vertexAttrSizes, jobjectArray vertexAttrData, - jint pass, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jint texStride, jobjectArray texCoords, jint cDirty, @@ -4914,7 +4762,6 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo geo, geo_type, isNonUniformScale, - multiScreen, ignoreVertexColors, initialIndexIndex, indexCount, @@ -4926,11 +4773,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo fclrs, bclrs, norms, - pass, texCoordMapLength, tcoordsetmap, numActiveTexUnit, - tunitstatemap, texStride, texCoordPointer, cDirty, @@ -4963,14 +4808,13 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryVABuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_executeIndexedGeometryVABuffer( JNIEnv *env, jobject obj, jlong ctx, jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint indexCount, @@ -4985,11 +4829,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jint vertexAttrCount, jintArray vertexAttrSizes, jobjectArray vertexAttrData, - jint pass, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jint texStride, jobjectArray texCoords, jint cDirty, @@ -5067,7 +4909,6 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo geo, geo_type, isNonUniformScale, - multiScreen, ignoreVertexColors, initialIndexIndex, indexCount, @@ -5079,11 +4920,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo fclrs, bclrs, norms, - pass, texCoordMapLength, tcoordsetmap, numActiveTexUnit, - tunitstatemap, texStride, texCoordPointer, cDirty, @@ -5097,7 +4936,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo } extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_buildGAForBuffer( JNIEnv *env, jobject obj, jlong ctx, @@ -5181,12 +5020,12 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( executeGeometryArrayVA(env, obj, ctx, geo, geo_type, isNonUniformScale, updateAlpha, alpha, - false, ignoreVertexColors, + ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, - norms, -1, texCoordMapLength, - tcoordsetmap,texCoordMapLength, NULL, + norms, texCoordMapLength, + tcoordsetmap,texCoordMapLength, texindices,texStride,texCoordPointer, xform, nxform, javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED); @@ -5194,13 +5033,13 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( /* execute geometry array with java array format */ /* - * Class: javax_media_j3d_GeometryArrayRetained + * Class: javax_media_j3d_NativePipeline * Method: buildGAForByRef * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[F[DI[F[BI[FI[I[I[[FI[I[II[Ljava/lang/Object;[D[D)V */ extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( +void JNICALL Java_javax_media_j3d_NativePipeline_buildGAForByRef( JNIEnv *env, jobject obj, jlong ctx, @@ -5294,12 +5133,12 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( executeGeometryArrayVA(env, obj, ctx, geo, geo_type, isNonUniformScale, updateAlpha, alpha, - false, ignoreVertexColors, + ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, - norms, -1, texCoordMapLength, - tcoordsetmap,texCoordMapLength, NULL, + norms, texCoordMapLength, + tcoordsetmap,texCoordMapLength, texindices,texStride,texCoordPointer, xform, nxform, javax_media_j3d_GeometryArrayRetained_VERTEX_CHANGED); diff --git a/src/native/d3d/GraphicsContext3D.cpp b/src/native/d3d/GraphicsContext3D.cpp index 427cd33..22ead53 100644 --- a/src/native/d3d/GraphicsContext3D.cpp +++ b/src/native/d3d/GraphicsContext3D.cpp @@ -13,7 +13,21 @@ #include "StdAfx.h" extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( +void JNICALL Java_javax_media_j3d_NativePipeline_readRaster( + JNIEnv *env, jobject obj, jlong ctx, + jint type, jint xOffset, jint yOffset, + jint wRaster, jint hRaster, jint hCanvas, + jint imageDataType, + jint imageFormat, jobject imageBuffer, + jint depthFormat, jobject depthBuffer) +{ + printf("[Java3D] D3D : readRaster is not implemented yet.\n"); + +} + +#if 0 +extern "C" JNIEXPORT +void JNICALL Java_javax_media_j3d_NativePipeline_readRasterNative( JNIEnv *env, jobject obj, jlong ctx, jint type, jint xOffset, jint yOffset, jint wRaster, jint hRaster, jint hCanvas, jint format, @@ -152,3 +166,5 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( } } } + +#endif diff --git a/src/native/d3d/Lights.cpp b/src/native/d3d/Lights.cpp index 270e52a..5d0f030 100644 --- a/src/native/d3d/Lights.cpp +++ b/src/native/d3d/Lights.cpp @@ -15,9 +15,9 @@ #define D3DLIGHT_RANGE_MAX sqrt(FLT_MAX) extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_DirectionalLightRetained_updateLight( +void JNICALL Java_javax_media_j3d_NativePipeline_updateDirectionalLight( JNIEnv *env, - jobject light, + jobject obj, jlong ctx, jint lightSlot, jfloat red, @@ -56,9 +56,9 @@ void JNICALL Java_javax_media_j3d_DirectionalLightRetained_updateLight( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_PointLightRetained_updateLight( +void JNICALL Java_javax_media_j3d_NativePipeline_updatePointLight( JNIEnv *env, - jobject light, + jobject obj, jlong ctx, jint lightSlot, jfloat red, @@ -99,9 +99,9 @@ void JNICALL Java_javax_media_j3d_PointLightRetained_updateLight( extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_SpotLightRetained_updateLight( +void JNICALL Java_javax_media_j3d_NativePipeline_updateSpotLight( JNIEnv *env, - jobject light, + jobject obj, jlong ctx, jint lightSlot, jfloat red, diff --git a/src/native/d3d/NativeAPIInfo.c b/src/native/d3d/NativeAPIInfo.c deleted file mode 100644 index b5a5bde..0000000 --- a/src/native/d3d/NativeAPIInfo.c +++ /dev/null @@ -1,23 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -#include <jni.h> - -#include "javax_media_j3d_MasterControl.h" -#include "javax_media_j3d_NativeAPIInfo.h" - -JNIEXPORT -jint JNICALL Java_javax_media_j3d_NativeAPIInfo_getRenderingAPI( - JNIEnv *env, jobject obj) -{ - return (jint)javax_media_j3d_MasterControl_RENDER_DIRECT3D; -} diff --git a/src/native/d3d/NativeWSInfo.cpp b/src/native/d3d/NativeWSInfo.cpp deleted file mode 100644 index e1af6e5..0000000 --- a/src/native/d3d/NativeWSInfo.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -#include "StdAfx.h" - - - -#ifdef STRICT -typedef WNDPROC PROC_TYPE; -#else -typedef FARPROC PROC_TYPE; -#endif - - -static PROC_TYPE g_lpDefWindowProcChild; -static long oldWindowHandle = 0; - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_NativeWSInfo_subclass( - JNIEnv * env, - jobject obj, - jint hwnd) -{ - // For some reason, setting the callback before - // setCooperative level will cause setCooperative level - // to hang when start in fullscreen mode - // So we delay it later. -} - -// Handle child move request -static LRESULT CALLBACK canvas3dWndProcChild( - HWND hwnd, - UINT message, - WPARAM wParam, - LPARAM lParam) -{ - /* - switch (message) { - case WM_NCPAINT: - // handle switch mode from 256 back to >= 16 bits color mode - DWORD status; - if (hSema != NULL) { - status = WaitForSingleObject(hSema, 0); - if (status == WAIT_OBJECT_0) { - // This prevent deadlock, otherwise the window event - // thread will hangs if lock already acquired - // during window resize/toggle. - D3dCtx *ctx = findCtx(hwnd); - if (ctx != NULL) { - ctx->retryRestoreSurface = true; - } - unlock(); - } - } - break; - } - */ - return CallWindowProc(g_lpDefWindowProcChild, hwnd, message, - wParam, lParam); -} - - -VOID setWindowCallback(HWND topHwnd, HWND hwnd) -{ - // For some reasons, setting proc for the same handle - // will crash the application. So we work around this - // by checking the old window handle before setting the - // new one. - // long newWindowHandle; - /* - if (oldWindowHandle == 0) { - oldWindowHandle = GetWindowLong((HWND) hwnd, GWL_WNDPROC); - } - - newWindowHandle = GetWindowLong((HWND) hwnd, GWL_WNDPROC); - if (newWindowHandle == oldWindowHandle) { - g_lpDefWindowProcChild = (PROC_TYPE) - SetWindowLong((HWND) hwnd, GWL_WNDPROC, - (LONG) canvas3dWndProcChild); - } - */ -} - diff --git a/src/native/d3d/RasterRetained.cpp b/src/native/d3d/RasterRetained.cpp deleted file mode 100644 index 9cd3750..0000000 --- a/src/native/d3d/RasterRetained.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -#include "StdAfx.h" - -D3dImageComponent RasterList; -D3dImageComponent BackgroundImageList; - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env, - jobject obj, jlong ctx, jobject geo, - jboolean updateAlpha, jfloat alpha, - jint type, jint w_raster, jint h_raster, - jint x_offset, jint y_offset, jfloat x, jfloat y, jfloat z, - jbyteArray imageYdown) -{ - jfieldID id; - int width, height; - int hashCode; - D3DVERTEX worldCoord; - D3DTLVERTEX screenCoord; - - GetDevice(); - - int startx = x_offset; - int starty = y_offset; - int endx = x_offset + w_raster; - int endy = y_offset + h_raster; - - jclass geo_class = env->GetObjectClass(geo); - - if ((type == javax_media_j3d_Raster_RASTER_COLOR) || - (type == javax_media_j3d_Raster_RASTER_COLOR_DEPTH)) { - - int alphaChanged = 0; // used so we can get alpha data from - // JNI before using it so we can use - // GetPrimitiveArrayCritical - - id = env->GetFieldID(geo_class, "image", - "Ljavax/media/j3d/ImageComponent2DRetained;"); - jobject image = env->GetObjectField(geo, id); - - - jclass image_class = env->GetObjectClass(image); - - if (image_class == NULL) { - return; - } - /* - id = env->GetFieldID(image_class, "surfaceDirty", "I"); - if (env->GetIntField(image, id) == NOTLIVE) { - return; - } - */ - id = env->GetFieldID(image_class, "width", "I"); - width = env->GetIntField(image, id); - id = env->GetFieldID(image_class, "height", "I"); - height = env->GetIntField(image, id); - - id = env->GetFieldID(image_class, "hashId", "I"); - hashCode = env->GetIntField(image, id); - - // clipping - if (startx > width) { - startx = width; - } else if (startx < 0) { - startx = 0; - } - if (starty > height) { - starty = height; - } else if (starty < 0) { - starty = 0; - } - if (endx > width) { - endx = width; - } else if (endx < 0) { - endx = 0; - } - if (endy > height) { - endy = height; - } else if (endy < 0) { - endy = 0; - } - - // raster position is upper left corner, default for Java3D - // ImageComponent currently has the data reverse in Y - worldCoord.x = x; - worldCoord.y = y; - worldCoord.z = z; - - lockImage(); - - D3dImageComponent* d3dImage = - D3dImageComponent::find(&RasterList, d3dCtx, hashCode); - - LPDIRECT3DTEXTURE9 surf = NULL ; - - if ((d3dImage == NULL) || (d3dImage->surf == NULL)) { - - surf = createSurfaceFromImage(env, image, ctx, - width, height, imageYdown); - - if (surf == NULL) { - if (d3dImage != NULL) { - D3dImageComponent::remove(&RasterList, d3dImage); - } - unlockImage(); - return; - } - if (d3dImage == NULL) { - d3dImage = D3dImageComponent::add(&RasterList, d3dCtx, hashCode, surf); - - if (d3dImage == NULL) { - return; - } - - } else { - d3dImage->surf = surf; - } - } - - d3dCtx->transform(&worldCoord, &screenCoord); - if ((screenCoord.sz >= 0) && (screenCoord.sz <= 1)) { - screenCoord.sx -= 0.5f; - screenCoord.sy -= 0.5f; - drawTextureRect(d3dCtx, device, d3dImage->surf, screenCoord, - startx, starty, endx, endy, - endx - startx, endy - starty, false); - } - unlockImage(); - - } - - if ((type == javax_media_j3d_Raster_RASTER_DEPTH) || - (type == javax_media_j3d_Raster_RASTER_COLOR_DEPTH)) { - id = env->GetFieldID(geo_class, "depthComponent", - "Ljavax/media/j3d/DepthComponentRetained;"); - - jobject depth = env->GetObjectField(geo, id); - jclass depth_class = env->GetObjectClass(depth); - - if (depth_class == NULL) { - return; - } - id = env->GetFieldID(depth_class, "type", "I"); - int depth_type = env->GetIntField(depth, id); - id = env->GetFieldID(depth_class, "width", "I"); - width = env->GetIntField(depth, id); - id = env->GetFieldID(depth_class, "height", "I"); - height = env->GetIntField(depth, id); - - - - // clipping - if (startx > width) { - startx = width; - } else if (startx < 0) { - startx = 0; - } - if (starty > height) { - starty = height; - } else if (starty < 0) { - starty = 0; - } - if (endx > width) { - endx = width; - } else if (endx < 0) { - endx = 0; - } - if (endy > height) { - endy = height; - } else if (endy < 0) { - endy = 0; - } - - int h = endy - starty; - int w = endx - startx; - - // raster position is upper left corner, default for Java3D - // ImageComponent currently has the data reverse in Y - if ((h > 0) && (w > 0)) { - worldCoord.x = x; - worldCoord.y = y; - worldCoord.z = z; - - d3dCtx->transform(&worldCoord, &screenCoord); - - if (d3dCtx->depthStencilSurface == NULL) { - HRESULT hr = - device->GetDepthStencilSurface(&d3dCtx->depthStencilSurface); - if (FAILED(hr)) { - if (debug) { - printf("[Java3D] Fail to get depth stencil surface %s\n", - DXGetErrorString9(hr)); - } - return; - } - } - - if (depth_type == javax_media_j3d_DepthComponentRetained_DEPTH_COMPONENT_TYPE_INT) { - id = env->GetFieldID(depth_class, "depthData","[I"); - jintArray intData_array = (jintArray) env->GetObjectField(depth, id); - jint * intData = (jint *) env->GetPrimitiveArrayCritical( - intData_array, NULL); - copyDepthToSurface(d3dCtx, - device, - (int)(screenCoord.sx), - (int)(screenCoord.sy), - x_offset, y_offset, - w, h,width, height, - intData, d3dCtx->depthStencilSurface); - env->ReleasePrimitiveArrayCritical(intData_array, - intData, 0); - } else { // javax_media_j3d_DepthComponentRetained_DEPTH_COMPONENT_TYPE_FLOAT - - id = env->GetFieldID(depth_class, "depthData","[F"); - jfloatArray floatData_array = (jfloatArray) - env->GetObjectField(depth, id); - - jfloat *floatData = (jfloat *) env->GetPrimitiveArrayCritical( - floatData_array, NULL); - copyDepthToSurface(d3dCtx, - device, - (jint)(screenCoord.sx), - (jint)(screenCoord.sy), - x_offset, y_offset, - w, h, width, height, - floatData, d3dCtx->depthStencilSurface); - env->ReleasePrimitiveArrayCritical(floatData_array, - floatData, 0); - } - } - } -} - - - -extern "C" JNIEXPORT -void JNICALL Java_javax_media_j3d_RasterRetained_executeTiled(JNIEnv *env, - jobject obj, jlong ctx, jobject geo, - jint format, jint w_raster, jint h_raster, - jint x_offset, jint y_offset, jint deltaw, jint deltah, - jfloat x, jfloat y, jfloat z, jbyteArray tile) -{ - // This is is not used by both OGL and D3D -} diff --git a/src/native/d3d/build-windows-amd64-vc.xml b/src/native/d3d/build-windows-amd64-vc.xml new file mode 100644 index 0000000..7182711 --- /dev/null +++ b/src/native/d3d/build-windows-amd64-vc.xml @@ -0,0 +1,64 @@ +<?xml version="1.0"?> + +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<!-- Win64 ant file for d3d renderer --> +<project name="Java 3D" default="compile"> + + <target name="compile"> + + <echo message="Executing 64 bit native renderer build [${bldType}]"/> + + <!-- Create the build directories for amd64 --> + <mkdir dir="${build}/${platform}/${bldType}/native/d3d/objs"/> + <mkdir dir="${build}/${platform}/${bldType}/bin"/> + + <property name="javaInclude" + location="${java.home}/../include"/> + + <property name="javaWin32Include" + location="${java.home}/../include/win32"/> + + <property name="oglsrc" location="${src}/native/ogl"/> + <property name="d3dsrc" location="${src}/native/d3d"/> + + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/d3d/objs" executable="cl"> + <arg line="-Ox -O2 -Ob2 -Os -Oi -GT -GL /nologo -wd4996 -I"${javaInclude}" -I"${javaWin32Include}" -I"${src}/native/ogl" -I"${javahCoreTarget}" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "J3DDX90PORT_EXPORTS" /D "WIN32" /D "D3D" /D "J3D_BUILDVERTICES" /D "NVIDIA_DEBUG" /FD /EHsc /MT /Fp"J3dDX90Port.pch" /W2 /c /TP "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/MasterControl.c" "${d3dsrc}/D3dVertexBuffer.cpp" "${d3dsrc}/D3dDisplayList.cpp" "${d3dsrc}/D3dDriverInfo.cpp" "${d3dsrc}/D3dDeviceInfo.cpp" "${d3dsrc}/D3dCtx.cpp" "${d3dsrc}/D3dUtil.cpp" "${d3dsrc}/D3dImageComponent.cpp" "${d3dsrc}/GeometryArrayRetained.cpp" "${d3dsrc}/Canvas3D.cpp" "${d3dsrc}/GraphicsContext3D.cpp" "${d3dsrc}/Attributes.cpp" "${d3dsrc}/Lights.cpp" "${d3dsrc}/NativeConfigTemplate3D.cpp" "/> + </exec> + + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/d3d/objs" executable="link"> + <arg line="/OUT:"j3dcore-d3d.dll" /nologo -DLL -DELAYLOAD:jawt.dll -IMPLIB:"j3dcore-d3d.lib" -LTCG /ignore:4089 ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib DelayImp.lib Attributes.obj Canvas3D.obj D3dCtx.obj D3dDeviceInfo.obj D3dDisplayList.obj D3dDriverInfo.obj D3dImageComponent.obj D3dUtil.obj D3dVertexBuffer.obj DrawingSurfaceObjectAWT.obj GeometryArrayRetained.obj GraphicsContext3D.obj Lights.obj MasterControl.obj NativeConfigTemplate3D.obj ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib -LIBPATH:"${java.home}\..\lib" jawt.lib"/> + </exec> + + <!-- Copy the copyright library file --> + <copy file="${build}/${platform}/${bldType}/native/d3d/objs/j3dcore-d3d.dll" + todir="${build}/${platform}/${bldType}/bin"/> + + </target> + + <target name="dist"> + <!-- Create the distribution directory --> + <mkdir dir="${dist}/${platform}/bin"/> + + <!-- Copy the library files --> + <copy file="${build}/${platform}/opt/bin/j3dcore-d3d.dll" + todir="${dist}/${platform}/bin"/> + + </target> + +</project> diff --git a/src/native/d3d/build-windows-i586-vc.xml b/src/native/d3d/build-windows-i586-vc.xml index a1ad3b0..f432e0b 100644 --- a/src/native/d3d/build-windows-i586-vc.xml +++ b/src/native/d3d/build-windows-i586-vc.xml @@ -36,13 +36,13 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/d3d/objs" executable="cl"> - <arg line="-Ox -Og -O2 -Ob2 -Os -Oi -GT -GL /nologo -I"${javaInclude}" -I"${javaWin32Include}" -I"${src}/native/ogl" -I"${javahCoreTarget}" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "J3DDX90PORT_EXPORTS" /D "WIN32" /D "D3D" /D "J3D_BUILDVERTICES" /D "NVIDIA_DEBUG" /FD /EHsc /MT /Fp"J3dDX90Port.pch" /W2 /c /TP "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/MasterControl.c" "${d3dsrc}/D3dVertexBuffer.cpp" "${d3dsrc}/D3dDisplayList.cpp" "${d3dsrc}/D3dDriverInfo.cpp" "${d3dsrc}/D3dDeviceInfo.cpp" "${d3dsrc}/D3dCtx.cpp" "${d3dsrc}/D3dUtil.cpp" "${d3dsrc}/D3dImageComponent.cpp" "${d3dsrc}/GeometryArrayRetained.cpp" "${d3dsrc}/Canvas3D.cpp" "${d3dsrc}/GraphicsContext3D.cpp" "${d3dsrc}/Attributes.cpp" "${d3dsrc}/Lights.cpp" "${d3dsrc}/NativeConfigTemplate3D.cpp" "${d3dsrc}/NativeWSInfo.cpp" "${d3dsrc}/NativeAPIInfo.c" "${d3dsrc}/RasterRetained.cpp" "/> + <arg line="-Ox -Og -O2 -Ob2 -Os -Oi -GT -GL /nologo -I"${javaInclude}" -I"${javaWin32Include}" -I"${src}/native/ogl" -I"${javahCoreTarget}" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "J3DDX90PORT_EXPORTS" /D "WIN32" /D "D3D" /D "J3D_BUILDVERTICES" /D "NVIDIA_DEBUG" /FD /EHsc /MT /Fp"J3dDX90Port.pch" /W2 /c /TP "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/MasterControl.c" "${d3dsrc}/D3dVertexBuffer.cpp" "${d3dsrc}/D3dDisplayList.cpp" "${d3dsrc}/D3dDriverInfo.cpp" "${d3dsrc}/D3dDeviceInfo.cpp" "${d3dsrc}/D3dCtx.cpp" "${d3dsrc}/D3dUtil.cpp" "${d3dsrc}/D3dImageComponent.cpp" "${d3dsrc}/GeometryArrayRetained.cpp" "${d3dsrc}/Canvas3D.cpp" "${d3dsrc}/GraphicsContext3D.cpp" "${d3dsrc}/Attributes.cpp" "${d3dsrc}/Lights.cpp" "${d3dsrc}/NativeConfigTemplate3D.cpp" "/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/d3d/objs" executable="link"> - <arg line="/OUT:"j3dcore-d3d.dll" /nologo -DLL -DELAYLOAD:jawt.dll -IMPLIB:"j3dcore-d3d.lib" -MACHINE:X86 -LTCG /ignore:4089 ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib DelayImp.lib Attributes.obj Canvas3D.obj D3dCtx.obj D3dDeviceInfo.obj D3dDisplayList.obj D3dDriverInfo.obj D3dImageComponent.obj D3dUtil.obj D3dVertexBuffer.obj DrawingSurfaceObjectAWT.obj GeometryArrayRetained.obj GraphicsContext3D.obj Lights.obj MasterControl.obj NativeAPIInfo.obj NativeConfigTemplate3D.obj NativeWSInfo.obj RasterRetained.obj ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib -LIBPATH:"${java.home}\..\lib" jawt.lib"/> + <arg line="/OUT:"j3dcore-d3d.dll" /nologo -DLL -DELAYLOAD:jawt.dll -IMPLIB:"j3dcore-d3d.lib" -MACHINE:X86 -LTCG /ignore:4089 ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib DelayImp.lib Attributes.obj Canvas3D.obj D3dCtx.obj D3dDeviceInfo.obj D3dDisplayList.obj D3dDriverInfo.obj D3dImageComponent.obj D3dUtil.obj D3dVertexBuffer.obj DrawingSurfaceObjectAWT.obj GeometryArrayRetained.obj GraphicsContext3D.obj Lights.obj MasterControl.obj NativeConfigTemplate3D.obj ddraw.lib d3d9.lib d3dx9.lib dxerr9.lib dxguid.lib dinput.lib dinput8.lib delayimp.lib WinStrm.lib -LIBPATH:"${java.home}\..\lib" jawt.lib"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/Attributes.c b/src/native/ogl/Attributes.c index bb35990..db87e70 100644 --- a/src/native/ogl/Attributes.c +++ b/src/native/ogl/Attributes.c @@ -217,18 +217,25 @@ const unsigned int screen_door[17][32] = { }, }; +void +throwAssert(JNIEnv *env, char *str) +{ + jclass rte; + if ((rte = (*env)->FindClass(env, "java/lang/AssertionError")) != NULL) { + (*env)->ThrowNew(env, rte, str); + } +} - JNIEXPORT -void JNICALL Java_javax_media_j3d_LinearFogRetained_update( +void JNICALL Java_javax_media_j3d_NativePipeline_updateLinearFog( JNIEnv *env, - jobject fog, + jobject obj, jlong ctxInfo, jfloat red, jfloat green, jfloat blue, jdouble fdist, - jdouble bdist) + jdouble bdist) { float color[3]; @@ -248,9 +255,9 @@ void JNICALL Java_javax_media_j3d_LinearFogRetained_update( } JNIEXPORT -void JNICALL Java_javax_media_j3d_ExponentialFogRetained_update( +void JNICALL Java_javax_media_j3d_NativePipeline_updateExponentialFog( JNIEnv *env, - jobject fog, + jobject obj, jlong ctxInfo, jfloat red, jfloat green, @@ -274,9 +281,9 @@ void JNICALL Java_javax_media_j3d_ExponentialFogRetained_update( } JNIEXPORT -void JNICALL Java_javax_media_j3d_ModelClipRetained_update( +void JNICALL Java_javax_media_j3d_NativePipeline_updateModelClip( JNIEnv *env, - jobject modelClip, + jobject obj, jlong ctxInfo, jint planeNum, jboolean enableFlag, @@ -308,7 +315,7 @@ void JNICALL Java_javax_media_j3d_ModelClipRetained_update( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setModelViewMatrix( +void JNICALL Java_javax_media_j3d_NativePipeline_setModelViewMatrix( JNIEnv * env, jobject obj, jlong ctxInfo, @@ -327,11 +334,10 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setModelViewMatrix( glMatrixMode(GL_MODELVIEW); - - if (ctxProperties->arb_transpose_matrix) { - ctxProperties->glLoadTransposeMatrixdARB(vmatrix_pointer); - ctxProperties->glMultTransposeMatrixdARB(mmatrix_pointer); + if (ctxProperties->gl13) { + ctxProperties->glLoadTransposeMatrixd(vmatrix_pointer); + ctxProperties->glMultTransposeMatrixd(mmatrix_pointer); } else { double v[16]; double m[16]; @@ -364,7 +370,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setModelViewMatrix( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setProjectionMatrix( +void JNICALL Java_javax_media_j3d_NativePipeline_setProjectionMatrix( JNIEnv * env, jobject obj, jlong ctxInfo, @@ -379,7 +385,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setProjectionMatrix( glMatrixMode(GL_PROJECTION); - if (ctxProperties->arb_transpose_matrix) { + if (ctxProperties->gl13) { /* * Invert the Z value in clipping coordinates because OpenGL uses * left-handed clipping coordinates, while Java3D defines right-handed @@ -389,7 +395,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setProjectionMatrix( matrix_pointer[9] *= -1.0; matrix_pointer[10] *= -1.0; matrix_pointer[11] *= -1.0; - ctxProperties->glLoadTransposeMatrixdARB(matrix_pointer); + ctxProperties->glLoadTransposeMatrixd(matrix_pointer); matrix_pointer[8] *= -1.0; matrix_pointer[9] *= -1.0; matrix_pointer[10] *= -1.0; @@ -427,7 +433,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setProjectionMatrix( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setViewport( +void JNICALL Java_javax_media_j3d_NativePipeline_setViewport( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -445,7 +451,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setViewport( #endif JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setSceneAmbient( +void JNICALL Java_javax_media_j3d_NativePipeline_setSceneAmbient( JNIEnv *env, jobject cv, jlong ctxInfo, @@ -463,7 +469,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setSceneAmbient( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setLightEnables( +void JNICALL Java_javax_media_j3d_NativePipeline_setLightEnables( JNIEnv *env, jobject cv, jlong ctxInfo, @@ -489,7 +495,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setLightEnables( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setLightingEnable( +void JNICALL Java_javax_media_j3d_NativePipeline_setLightingEnable( JNIEnv *env, jobject cv, jlong ctxInfo, @@ -509,7 +515,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setLightingEnable( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_disableFog( +void JNICALL Java_javax_media_j3d_NativePipeline_disableFog( JNIEnv *env, jobject cv, jlong ctxInfo) @@ -521,7 +527,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_disableFog( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_disableModelClip( +void JNICALL Java_javax_media_j3d_NativePipeline_disableModelClip( JNIEnv *env, jobject cv, jlong ctxInfo) @@ -540,7 +546,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_disableModelClip( JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetRenderingAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetRenderingAttributes( JNIEnv *env, jobject cv, jlong ctxInfo, @@ -618,9 +624,9 @@ GLenum getStencilOpValue(jint op) { } JNIEXPORT -void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateRenderingAttributes( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jboolean db_write_enable_override, jboolean db_enable_override, @@ -750,7 +756,7 @@ void JNICALL Java_javax_media_j3d_RenderingAttributesRetained_updateNative( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetPolygonAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetPolygonAttributes( JNIEnv *env, jobject cv, jlong ctxInfo) @@ -769,9 +775,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetPolygonAttributes( } JNIEXPORT -void JNICALL Java_javax_media_j3d_PolygonAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updatePolygonAttributes( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jint polygonMode, jint cullFace, @@ -834,7 +840,7 @@ void JNICALL Java_javax_media_j3d_PolygonAttributesRetained_updateNative( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetLineAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetLineAttributes( JNIEnv *env, jobject cv, jlong ctxInfo) @@ -852,9 +858,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetLineAttributes( } JNIEXPORT -void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateLineAttributes( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jfloat lineWidth, jint linePattern, @@ -888,7 +894,7 @@ void JNICALL Java_javax_media_j3d_LineAttributesRetained_updateNative( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetPointAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetPointAttributes( JNIEnv *env, jobject cv, jlong ctxInfo) @@ -900,9 +906,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetPointAttributes( } JNIEXPORT -void JNICALL Java_javax_media_j3d_PointAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updatePointAttributes( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jfloat pointSize, jboolean pointAntialiasing) @@ -918,7 +924,7 @@ void JNICALL Java_javax_media_j3d_PointAttributesRetained_updateNative( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetTexCoordGeneration( +void JNICALL Java_javax_media_j3d_NativePipeline_resetTexCoordGeneration( JNIEnv *env, jobject cv, jlong ctxInfo) @@ -930,9 +936,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetTexCoordGeneration( } JNIEXPORT -void JNICALL Java_javax_media_j3d_TexCoordGenerationRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexCoordGeneration( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jboolean enable, jint genMode, @@ -1016,8 +1022,8 @@ void JNICALL Java_javax_media_j3d_TexCoordGenerationRetained_updateNative( glMatrixMode(GL_MODELVIEW); glPushMatrix(); - if (ctxProperties->arb_transpose_matrix) { - ctxProperties->glLoadTransposeMatrixdARB(mat); + if (ctxProperties->gl13) { + ctxProperties->glLoadTransposeMatrixd(mat); } else { jdouble v[16]; COPY_TRANSPOSE(mat, v); @@ -1084,7 +1090,7 @@ void JNICALL Java_javax_media_j3d_TexCoordGenerationRetained_updateNative( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetTextureAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetTextureAttributes( JNIEnv *env, jobject cv, jlong ctxInfo) @@ -1110,9 +1116,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetTextureAttributes( } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureAttributes( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jdoubleArray transform, jboolean isIdentity, @@ -1144,8 +1150,8 @@ void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateNative( NULL); if (isIdentity) { glLoadIdentity(); - } else if (ctxProperties->arb_transpose_matrix) { - ctxProperties->glLoadTransposeMatrixdARB(mx_ptr); + } else if (ctxProperties->gl13) { + ctxProperties->glLoadTransposeMatrixd(mx_ptr); } else { double mx[16]; COPY_TRANSPOSE(mx_ptr, mx); @@ -1215,9 +1221,9 @@ GLenum getCombinerArg(jint arg, GLenum textureUnit, GLenum combUnit) { } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateNativeRegisterCombiners( +void JNICALL Java_javax_media_j3d_NativePipeline_updateRegisterCombiners( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jdoubleArray transform, jboolean isIdentity, @@ -1262,8 +1268,8 @@ void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateNativeRegister NULL); if (isIdentity) { glLoadIdentity(); - } else if (ctxProperties->arb_transpose_matrix) { - ctxProperties->glLoadTransposeMatrixdARB(mx_ptr); + } else if (ctxProperties->gl13) { + ctxProperties->glLoadTransposeMatrixd(mx_ptr); } else { double mx[16]; COPY_TRANSPOSE(mx_ptr, mx); @@ -1564,9 +1570,9 @@ jint _gl_combineFcn[] = { JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateCombinerNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateCombiner( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxProperties, jint combineRgbMode, jint combineAlphaMode, @@ -1642,9 +1648,9 @@ void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateCombinerNative JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateTextureColorTableNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureColorTable( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jint numComponents, jint colorTableSize, @@ -1672,9 +1678,9 @@ void JNICALL Java_javax_media_j3d_TextureAttributesRetained_updateTextureColorTa } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_updateMaterial( +void JNICALL Java_javax_media_j3d_NativePipeline_updateMaterialColor( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jfloat colorRed, jfloat colorGreen, @@ -1692,9 +1698,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_updateMaterial( } JNIEXPORT -void JNICALL Java_javax_media_j3d_MaterialRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateMaterial( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jfloat colorRed, jfloat colorGreen, @@ -1762,7 +1768,7 @@ void JNICALL Java_javax_media_j3d_MaterialRetained_updateNative( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetTransparency( +void JNICALL Java_javax_media_j3d_NativePipeline_resetTransparency( JNIEnv *env, jobject cv, jlong ctxInfo, @@ -1787,7 +1793,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetTransparency( } JNIEXPORT -void JNICALL Java_javax_media_j3d_TransparencyAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTransparencyAttributes( JNIEnv *env, jobject tr, jlong ctxInfo, @@ -1826,7 +1832,7 @@ void JNICALL Java_javax_media_j3d_TransparencyAttributesRetained_updateNative( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetColoringAttributes( +void JNICALL Java_javax_media_j3d_NativePipeline_resetColoringAttributes( JNIEnv *env, jobject cv, jlong ctxInfo, @@ -1849,9 +1855,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_resetColoringAttributes( } JNIEXPORT -void JNICALL Java_javax_media_j3d_ColoringAttributesRetained_updateNative( +void JNICALL Java_javax_media_j3d_NativePipeline_updateColoringAttributes( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jfloat dRed, jfloat dGreen, @@ -1883,32 +1889,25 @@ void JNICALL Java_javax_media_j3d_ColoringAttributesRetained_updateNative( JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_resetTextureNative( +void JNICALL Java_javax_media_j3d_NativePipeline_resetTextureNative( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint texUnitIndex) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if(ctxProperties->arb_multitexture) { - - if (texUnitIndex >= 0) { - ctxProperties->glActiveTextureARB(texUnitIndex + GL_TEXTURE0_ARB); - ctxProperties->glClientActiveTextureARB(texUnitIndex + GL_TEXTURE0_ARB); - } + if(ctxProperties->gl13) { + if (texUnitIndex >= 0) { + ctxProperties->glActiveTexture(texUnitIndex + GL_TEXTURE0); + ctxProperties->glClientActiveTexture(texUnitIndex + GL_TEXTURE0); + } } glDisable(GL_TEXTURE_1D); glDisable(GL_TEXTURE_2D); - - if(ctxProperties->texture3DAvailable) { - glDisable(ctxProperties->texture_3D_ext_enum); - } - - if(ctxProperties->textureCubeMapAvailable) { - glDisable(ctxProperties->texture_cube_map_ext_enum); - } + glDisable(GL_TEXTURE_3D); + glDisable(GL_TEXTURE_CUBE_MAP); } @@ -2048,7 +2047,7 @@ void updateTextureBoundary( break; case javax_media_j3d_Texture_CLAMP_TO_EDGE: glTexParameteri(target, GL_TEXTURE_WRAP_S, - ctxProperties->texture_clamp_to_edge_enum); + GL_CLAMP_TO_EDGE); break; case javax_media_j3d_Texture_CLAMP_TO_BOUNDARY: glTexParameteri(target, GL_TEXTURE_WRAP_S, @@ -2065,7 +2064,7 @@ void updateTextureBoundary( break; case javax_media_j3d_Texture_CLAMP_TO_EDGE: glTexParameteri(target, GL_TEXTURE_WRAP_T, - ctxProperties->texture_clamp_to_edge_enum); + GL_CLAMP_TO_EDGE); break; case javax_media_j3d_Texture_CLAMP_TO_BOUNDARY: glTexParameteri(target, GL_TEXTURE_WRAP_T, @@ -2078,21 +2077,21 @@ void updateTextureBoundary( switch (boundaryModeR) { case javax_media_j3d_Texture_WRAP: glTexParameteri(target, - ctxProperties->texture_wrap_r_ext_enum, GL_REPEAT); + GL_TEXTURE_WRAP_R, GL_REPEAT); break; case javax_media_j3d_Texture_CLAMP: glTexParameteri(target, - ctxProperties->texture_wrap_r_ext_enum, GL_CLAMP); + GL_TEXTURE_WRAP_R, GL_CLAMP); break; case javax_media_j3d_Texture_CLAMP_TO_EDGE: glTexParameteri(target, - ctxProperties->texture_wrap_r_ext_enum, - ctxProperties->texture_clamp_to_edge_enum); + GL_TEXTURE_WRAP_R, + GL_CLAMP_TO_EDGE); break; case javax_media_j3d_Texture_CLAMP_TO_BOUNDARY: glTexParameteri(target, - ctxProperties->texture_wrap_r_ext_enum, + GL_TEXTURE_WRAP_R, ctxProperties->texture_clamp_to_border_enum); break; } @@ -2181,6 +2180,21 @@ void updateTextureAnisotropicFilter( degree); } +static int +isPowerOfTwo(int size) +{ + int i; + if (size == 0) { + return 1; + } else { + for (i = 0; i < 32; i++) { + if (size == (1 << i)) { + return 1; + } + } + return 0; + } +} /* * common function to define 2D texture image for different target @@ -2191,130 +2205,159 @@ void updateTexture2DImage( jint target, jint numLevels, jint level, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint width, jint height, jint boundaryWidth, - jbyteArray imageYup) + jint dataType, + jobject data) { - GLenum oglFormat = 0, oglInternalFormat=0; + void *imageObjPtr; + GLenum format = 0, internalFormat = 0, type = GL_UNSIGNED_INT_8_8_8_8; JNIEnv table = *env; - jbyte *byteData; - jshort *shortData; + GLboolean forceAlphaToOne = GL_FALSE; - switch (internalFormat) { + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *)(*(table->GetPrimitiveArrayCritical))(env, (jarray)data, NULL); + } + else { + imageObjPtr = (void *)(*(table->GetDirectBufferAddress))(env, data); + } + + /* check if we are trying to draw NPOT on a system that doesn't support it */ + if ((!ctxProperties->textureNonPowerOfTwoAvailable) && + (!isPowerOfTwo(width) || !isPowerOfTwo(height))) { + /* disable texture by setting width and height to 0 */ + width = height = 0; + } + + switch (textureFormat) { case INTENSITY: - oglInternalFormat = GL_INTENSITY; + internalFormat = GL_INTENSITY; break; case LUMINANCE: - oglInternalFormat = GL_LUMINANCE; + internalFormat = GL_LUMINANCE; break; case ALPHA: - oglInternalFormat = GL_ALPHA; + internalFormat = GL_ALPHA; break; case LUMINANCE_ALPHA: - oglInternalFormat = GL_LUMINANCE_ALPHA; + internalFormat = GL_LUMINANCE_ALPHA; break; case J3D_RGB: - oglInternalFormat = GL_RGB; + internalFormat = GL_RGB; break; case J3D_RGBA: - oglInternalFormat = GL_RGBA; + internalFormat = GL_RGBA; break; + default: + throwAssert(env, "updateTexture2DImage : textureFormat illegal format"); + return; } - switch (format) { - case FORMAT_BYTE_RGBA: - /* all RGB types are stored as RGBA */ - oglFormat = GL_RGBA; - break; - case FORMAT_BYTE_RGB: - oglFormat = GL_RGB; - break; - - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - oglFormat = GL_ABGR_EXT; - } - break; - - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - oglFormat = ctxProperties->bgr_ext_enum; - } - break; - - case FORMAT_BYTE_LA: + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_BYTE_BUFFER)) { + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_BYTE_BGR: + format = GL_BGR; + break; + case IMAGE_FORMAT_BYTE_RGB: + format = GL_RGB; + break; + /* GL_ABGR_EXT */ + case IMAGE_FORMAT_BYTE_ABGR: + if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ + format = GL_ABGR_EXT; + } + else { + throwAssert(env, "updateTexture2DImage : GL_ABGR_EXT format is unsupported"); + return; + } + break; + case IMAGE_FORMAT_BYTE_RGBA: + format = GL_RGBA; + break; + case IMAGE_FORMAT_BYTE_LA: /* all LA types are stored as LA8 */ - oglFormat = GL_LUMINANCE_ALPHA; + format = GL_LUMINANCE_ALPHA; break; - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: - if (oglInternalFormat == GL_ALPHA) { - oglFormat = GL_ALPHA; + case IMAGE_FORMAT_BYTE_GRAY: + if (internalFormat == GL_ALPHA) { + format = GL_ALPHA; } else { - oglFormat = GL_LUMINANCE; + format = GL_LUMINANCE; } break; + + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_INT_BGR: + case IMAGE_FORMAT_INT_RGB: + case IMAGE_FORMAT_INT_ARGB: + default: + throwAssert(env, "updateTexture2DImage : imageFormat illegal format"); + return; + } + + glTexImage2D(target, level, internalFormat, + width, height, boundaryWidth, + format, GL_UNSIGNED_BYTE, imageObjPtr); + } - /* - fprintf(stderr,"native updateTextureImage\n"); - fprintf(stderr,"internalFormat = %x\n",internalFormat); - fprintf(stderr,"format = %x\n",format); - fprintf(stderr,"oglFormat = %x\n",oglFormat); - fprintf(stderr,"oglInternalFormat = %x\n",oglInternalFormat); - fprintf(stderr,"boundaryWidth= %d\n", boundaryWidth); - */ - if (imageYup != NULL) { - if (format != FORMAT_USHORT_GRAY) { - byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, - imageYup, - NULL); - /* - { - jbyte *c = byteData; - int i, j; - for (i = 0; i < 1; i++) { - for (j = 0; j < 8; j++, c++) { - fprintf(stderr, "%x ",*c); - } - fprintf(stderr, "\n"); - } - } - */ - } - else { /* unsigned short */ - shortData = (jshort *)(*(table->GetPrimitiveArrayCritical))(env, - imageYup, - NULL); + else if((dataType == IMAGE_DATA_TYPE_INT_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_BUFFER)) { + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_INT_BGR: /* Assume XBGR format */ + format = GL_RGBA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + forceAlphaToOne = GL_TRUE; + break; + case IMAGE_FORMAT_INT_RGB: /* Assume XRGB format */ + forceAlphaToOne = GL_TRUE; + /* Fall through to next case */ + case IMAGE_FORMAT_INT_ARGB: + format = GL_BGRA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + /* This method only supports 3 and 4 components formats and INT types. */ + case IMAGE_FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_ABGR: + default: + throwAssert(env, "updateTexture2DImage : imageFormat illegal format"); + return; + } + + /* Force Alpha to 1.0 if needed */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 0.0f); + glPixelTransferf(GL_ALPHA_BIAS, 1.0f); } - } - else { - byteData = NULL; - shortData = NULL; - } - if (format != FORMAT_USHORT_GRAY) { - glTexImage2D(target, level, oglInternalFormat, + + glTexImage2D(target, level, internalFormat, width, height, boundaryWidth, - oglFormat, GL_UNSIGNED_BYTE, (GLvoid *)byteData); + format, type, imageObjPtr); + + /* Restore Alpha scale and bias */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + glPixelTransferf(GL_ALPHA_BIAS, 0.0f); + } } else { - glTexImage2D(target, level, oglInternalFormat, - width, height, boundaryWidth, - oglFormat, GL_UNSIGNED_SHORT, (GLvoid *)shortData); + throwAssert(env, "updateTexture2DImage : illegal image data type"); + return; } - if (imageYup != NULL) { - if (format != FORMAT_USHORT_GRAY) { - (*(table->ReleasePrimitiveArrayCritical))(env, imageYup, byteData, 0); - } - else { - (*(table->ReleasePrimitiveArrayCritical))(env, imageYup, shortData, 0); - } - } - /* No idea why we need following call. */ - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + (*(table->ReleasePrimitiveArrayCritical))(env, data, imageObjPtr, 0); + } + } @@ -2329,158 +2372,210 @@ void updateTexture2DSubImage( jint level, jint xoffset, jint yoffset, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint imgXOffset, jint imgYOffset, jint tilew, jint width, jint height, - jbyteArray image) { + jint dataType, + jobject data) { - GLenum oglFormat = 0, oglInternalFormat=0; + void *imageObjPtr; + GLenum format = 0, internalFormat = 0, type = GL_UNSIGNED_INT_8_8_8_8; JNIEnv table = *env; - jbyte *byteData, *tmpByte; - jshort *shortData, *tmpShort; + GLboolean forceAlphaToOne = GL_FALSE; + jbyte *tmpByte; + jint *tmpInt; jint numBytes = 0; jboolean pixelStore = JNI_FALSE; + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *)(*(table->GetPrimitiveArrayCritical))(env, (jarray)data, NULL); + } + else { + imageObjPtr = (void *)(*(table->GetDirectBufferAddress))(env, data); + } + + if (imgXOffset > 0 || (width < tilew)) { + pixelStore = JNI_TRUE; + glPixelStorei(GL_UNPACK_ROW_LENGTH, tilew); + } + /* if NPOT textures are not supported, check if h=w=0, if so we have been + * disabled due to a NPOT texture being sent to a context that doesn't + * support it: disable the glTexSubImage as well + */ + if (!ctxProperties->textureNonPowerOfTwoAvailable) { + int texWidth, texHeight; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &texWidth); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &texHeight); + if ((texWidth == 0) && (texHeight == 0)) { + /* disable the sub-image by setting it's width and height to 0 */ + width = height = 0; + } + } - switch (internalFormat) { + switch (textureFormat) { case INTENSITY: - oglInternalFormat = GL_INTENSITY; + internalFormat = GL_INTENSITY; break; case LUMINANCE: - oglInternalFormat = GL_LUMINANCE; + internalFormat = GL_LUMINANCE; break; case ALPHA: - oglInternalFormat = GL_ALPHA; + internalFormat = GL_ALPHA; break; case LUMINANCE_ALPHA: - oglInternalFormat = GL_LUMINANCE_ALPHA; + internalFormat = GL_LUMINANCE_ALPHA; break; case J3D_RGB: - oglInternalFormat = GL_RGB; + internalFormat = GL_RGB; break; case J3D_RGBA: - oglInternalFormat = GL_RGBA; + internalFormat = GL_RGBA; break; + default: + throwAssert(env, "updateTexture2DSubImage : textureFormat illegal format"); + return; } - - switch (format) { - case FORMAT_BYTE_RGBA: - /* all RGB types are stored as RGBA */ - oglFormat = GL_RGBA; - numBytes = 4; - break; - case FORMAT_BYTE_RGB: - oglFormat = GL_RGB; - numBytes = 3; - break; - - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - oglFormat = GL_ABGR_EXT; + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_BYTE_BUFFER)) { + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_BYTE_BGR: + format = GL_BGR; + numBytes = 3; + break; + case IMAGE_FORMAT_BYTE_RGB: + format = GL_RGB; + numBytes = 3; + break; + /* GL_ABGR_EXT */ + case IMAGE_FORMAT_BYTE_ABGR: + if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ + format = GL_ABGR_EXT; numBytes = 4; - } - break; - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - oglFormat = ctxProperties->bgr_ext_enum; - numBytes = 3; - } - break; - - case FORMAT_BYTE_LA: + } + else { + throwAssert(env, "updateTexture2DSubImage : GL_ABGR_EXT format is unsupported"); + return; + } + break; + case IMAGE_FORMAT_BYTE_RGBA: + format = GL_RGBA; + numBytes = 4; + break; + case IMAGE_FORMAT_BYTE_LA: /* all LA types are stored as LA8 */ - oglFormat = GL_LUMINANCE_ALPHA; - numBytes = 2; - break; - case FORMAT_BYTE_GRAY: - if (oglInternalFormat == GL_ALPHA) { - oglFormat = GL_ALPHA; - } else { - oglFormat = GL_LUMINANCE; - } - numBytes = 1; - case FORMAT_USHORT_GRAY: - if (oglInternalFormat == GL_ALPHA) { - oglFormat = GL_ALPHA; - } else { - oglFormat = GL_LUMINANCE; + numBytes = 2; + format = GL_LUMINANCE_ALPHA; + break; + case IMAGE_FORMAT_BYTE_GRAY: + if (internalFormat == GL_ALPHA) { + format = GL_ALPHA; + numBytes = 1; + } else { + format = GL_LUMINANCE; + numBytes = 1; } - numBytes = 2; break; - } - /* - fprintf(stderr,"format = %x\n",format); - fprintf(stderr,"oglFormat = %x\n",oglFormat); - fprintf(stderr, "imgXOffset = %d\n",imgXOffset); - fprintf(stderr, "imgYOffset = %d\n",imgYOffset); - fprintf(stderr, "xoffset = %d\n",xoffset); - fprintf(stderr, "yoffset = %d\n",yoffset); - fprintf(stderr, "tilew = %d\n",tilew); - fprintf(stderr, "numBytes = %d\n",numBytes); - fprintf(stderr, "width = %d\n",width); - fprintf(stderr, "height = %d\n",height); - */ - if (imgXOffset > 0 || (width < tilew)) { - pixelStore = JNI_TRUE; - glPixelStorei(GL_UNPACK_ROW_LENGTH, tilew); - } - - if (format != FORMAT_USHORT_GRAY) { - int off = 0; - byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, - image, - NULL); - /* offset by the imageOffset */ - off = (tilew * imgYOffset + imgXOffset) * numBytes; - tmpByte = byteData+(off); -/* -printf("tmpByte: %x %x %x %x\n", *(tmpByte), *(tmpByte+1), - *(tmpByte+2), *(tmpByte+3)); -*/ + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_INT_BGR: + case IMAGE_FORMAT_INT_RGB: + case IMAGE_FORMAT_INT_ARGB: + default: + throwAssert(env, "updateTexture2DSubImage : imageFormat illegal format"); + return; + } + tmpByte = (jbyte*)imageObjPtr + + (tilew * imgYOffset + imgXOffset) * numBytes; + + glTexSubImage2D(target, level, xoffset, yoffset, width, height, - oglFormat, GL_UNSIGNED_BYTE, (GLvoid *)tmpByte); - (*(table->ReleasePrimitiveArrayCritical))(env, image, byteData, 0); - } else { /* unsigned short */ - shortData = (jshort *)(*(table->GetPrimitiveArrayCritical))(env, - image, - NULL); - tmpShort = (jshort*)((jbyte*)shortData+ - (tilew * imgYOffset + imgXOffset)*numBytes); + format, GL_UNSIGNED_BYTE, (GLvoid *)tmpByte); + + } + else if((dataType == IMAGE_DATA_TYPE_INT_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_BUFFER)) { + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_INT_BGR: /* Assume XBGR format */ + format = GL_RGBA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + forceAlphaToOne = GL_TRUE; + break; + case IMAGE_FORMAT_INT_RGB: /* Assume XRGB format */ + forceAlphaToOne = GL_TRUE; + /* Fall through to next case */ + case IMAGE_FORMAT_INT_ARGB: + format = GL_BGRA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + /* This method only supports 3 and 4 components formats and INT types. */ + case IMAGE_FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_ABGR: + default: + throwAssert(env, "updateTexture2DSubImage : imageFormat illegal format"); + return; + } + + numBytes = 4; + + tmpInt = (jint*)((jbyte*)imageObjPtr + + (tilew * imgYOffset + imgXOffset)*numBytes); + + /* Force Alpha to 1.0 if needed */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 0.0f); + glPixelTransferf(GL_ALPHA_BIAS, 1.0f); + } + glTexSubImage2D(target, level, xoffset, yoffset, width, height, - oglFormat, GL_UNSIGNED_SHORT, (GLvoid *)tmpShort); - (*(table->ReleasePrimitiveArrayCritical))(env, image, shortData, 0); + format, type, (GLvoid *)tmpInt); + + /* Restore Alpha scale and bias */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + glPixelTransferf(GL_ALPHA_BIAS, 0.0f); + } } + else { + throwAssert(env, "updateTexture2DImage : illegal image data type"); + return; + } + + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + (*(table->ReleasePrimitiveArrayCritical))(env, data, imageObjPtr, 0); + } + if (pixelStore) { - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); } } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_bindTexture( +void JNICALL Java_javax_media_j3d_NativePipeline_bindTexture2D( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint objectId, jboolean enable) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if (ctxProperties->textureCubeMapAvailable) { - glDisable(ctxProperties->texture_cube_map_ext_enum); - } - if (ctxProperties->texture3DAvailable) { - glDisable(ctxProperties->texture_3D_ext_enum); - } + glDisable(GL_TEXTURE_CUBE_MAP); + glDisable(GL_TEXTURE_3D); if (enable == JNI_FALSE) { glDisable(GL_TEXTURE_2D); - } else { glBindTexture(GL_TEXTURE_2D, objectId); glEnable(GL_TEXTURE_2D); @@ -2488,9 +2583,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_bindTexture( } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilterModes( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DFilterModes( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint minFilter, jint magFilter) @@ -2502,16 +2597,15 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilterModes( } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureLodRange( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DLodRange( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint baseLevel, jint maximumLevel, jfloat minimumLOD, jfloat maximumLOD) { - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; updateTextureLodRange(ctxProperties, GL_TEXTURE_2D, @@ -2519,10 +2613,11 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureLodRange( minimumLOD, maximumLOD); } + JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureLodOffset( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DLodOffset( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jfloat lodOffsetS, jfloat lodOffsetT, @@ -2536,9 +2631,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureLodOffset( JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureBoundary( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DBoundary( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint boundaryModeS, jint boundaryModeT, @@ -2556,9 +2651,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureBoundary( } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureSharpenFunc( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DSharpenFunc( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint numPts, jfloatArray pts) @@ -2569,9 +2664,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureSharpenFunc( } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilter4Func( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DFilter4Func( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint numPts, jfloatArray pts) @@ -2582,9 +2677,9 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureFilter4Func( } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureAnisotropicFilter( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DAnisotropicFilter( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jfloat degree) { @@ -2594,193 +2689,81 @@ void JNICALL Java_javax_media_j3d_TextureRetained_updateTextureAnisotropicFilter } JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture2DRetained_updateTextureSubImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DSubImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint level, jint xoffset, jint yoffset, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint imgXOffset, jint imgYOffset, jint tilew, jint width, jint height, - jbyteArray image) { + jint dataType, + jobject data) +{ GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; updateTexture2DSubImage(env, ctxProperties, GL_TEXTURE_2D, - level, xoffset, yoffset, - internalFormat, format, - imgXOffset, imgYOffset, tilew, width, height, - image); + level, xoffset, yoffset, + textureFormat, imageFormat, + imgXOffset, imgYOffset, tilew, width, height, + dataType, data); } JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture2DRetained_updateTextureImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture2DImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint numLevels, jint level, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint width, jint height, jint boundaryWidth, - jbyteArray imageYup) + jint dataType, + jobject data) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; updateTexture2DImage(env, ctxProperties, GL_TEXTURE_2D, - numLevels, level, internalFormat, format, - width, height, boundaryWidth, imageYup); -} - -JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture2DRetained_updateDetailTextureParameters( - JNIEnv *env, - jobject texture, - jlong ctxInfo, - jint mode, - jint level, - jint nPts, - jfloatArray funcPts) -{ - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - float *pts = NULL; - JNIEnv table = *env; - - if (ctxProperties->textureDetailAvailable) { - switch (mode) { - case javax_media_j3d_Texture2D_DETAIL_ADD: - glTexParameterf(GL_TEXTURE_2D, - ctxProperties->texture_detail_mode_enum, GL_ADD); - break; - case javax_media_j3d_Texture2D_DETAIL_MODULATE: - glTexParameterf(GL_TEXTURE_2D, - ctxProperties->texture_detail_mode_enum, GL_MODULATE); - break; - } - - glTexParameteri(GL_TEXTURE_2D, - ctxProperties->texture_detail_level_enum, -level); - - if (nPts > 0) { - pts = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, - funcPts, NULL); - } - ctxProperties->glDetailTexFuncSGIS(GL_TEXTURE_2D, nPts, pts); - - if (pts != NULL) { - (*(table->ReleasePrimitiveArrayCritical))(env, funcPts, pts, 0); - } - } -} - -JNIEXPORT -void JNICALL Java_javax_media_j3d_DetailTextureImage_bindTexture( - JNIEnv *env, - jobject texture, - jlong ctxInfo, - jint objectId) -{ - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - if (ctxProperties->textureDetailAvailable) { - glBindTexture(ctxProperties->texture_detail_ext_enum, objectId); - } -} - -JNIEXPORT -void JNICALL Java_javax_media_j3d_DetailTextureImage_updateTextureSubImage( - JNIEnv *env, - jobject texture, - jlong ctxInfo, - jint level, - jint xoffset, - jint yoffset, - jint internalFormat, - jint format, - jint imgXOffset, - jint imgYOffset, - jint tilew, - jint width, - jint height, - jbyteArray image) { - - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - if (ctxProperties->textureDetailAvailable) { - updateTexture2DSubImage(env, ctxProperties, - ctxProperties->texture_detail_ext_enum, - level, xoffset, yoffset, - internalFormat, format, - imgXOffset, imgYOffset, tilew, width, height, - image); - } + numLevels, level, textureFormat, imageFormat, + width, height, boundaryWidth, dataType, data); } JNIEXPORT -void JNICALL Java_javax_media_j3d_DetailTextureImage_updateTextureImage( +void JNICALL Java_javax_media_j3d_NativePipeline_bindTexture3D( JNIEnv *env, - jobject texture, - jlong ctxInfo, - jint numLevels, - jint level, - jint internalFormat, - jint format, - jint width, - jint height, - jint boundaryWidth, - jbyteArray imageYup) -{ - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - if (ctxProperties->textureDetailAvailable) { - updateTexture2DImage(env, ctxProperties, - ctxProperties->texture_detail_ext_enum, - numLevels, level, internalFormat, format, - width, height, boundaryWidth, imageYup); - } -} - -JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_bindTexture( - JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint objectId, jboolean enable) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if (ctxProperties->textureCubeMapAvailable) { - /* textureCubeMap will take precedure over 3D Texture */ - glDisable(ctxProperties->texture_cube_map_ext_enum); - } + /* textureCubeMap will take precedure over 3D Texture */ + glDisable(GL_TEXTURE_CUBE_MAP); if (enable == JNI_FALSE) { - if(ctxProperties->texture3DAvailable) { - glDisable(ctxProperties->texture_3D_ext_enum); - } - + glDisable(GL_TEXTURE_3D); } else { - if(ctxProperties->texture3DAvailable){ - glBindTexture(ctxProperties->texture_3D_ext_enum, objectId); - glEnable(ctxProperties->texture_3D_ext_enum); - } + glBindTexture(GL_TEXTURE_3D, objectId); + glEnable(GL_TEXTURE_3D); } } JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureFilterModes( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DFilterModes( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint minFilter, jint magFilter) @@ -2794,9 +2777,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureFilterModes( JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureLodRange( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DLodRange( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint baseLevel, jint maximumLevel, @@ -2812,9 +2795,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureLodRange( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureLodOffset( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DLodOffset( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jfloat lodOffsetS, jfloat lodOffsetT, @@ -2828,9 +2811,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureLodOffset( JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureBoundary( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DBoundary( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint boundaryModeS, jint boundaryModeT, @@ -2849,9 +2832,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureBoundary( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSharpenFunc( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DSharpenFunc( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint numPts, jfloatArray pts) @@ -2862,9 +2845,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSharpenFunc( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureFilter4Func( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DFilter4Func( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint numPts, jfloatArray pts) @@ -2875,9 +2858,9 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureFilter4Func( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureAnisotropicFilter( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DAnisotropicFilter( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jfloat degree) { @@ -2888,147 +2871,184 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureAnisotropicFilt JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint numLevels, jint level, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint width, jint height, jint depth, jint boundaryWidth, - jbyteArray imageYup) + jint dataType, + jobject data) { - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - if(ctxProperties->texture3DAvailable) { + void *imageObjPtr; + GLenum format = 0, internalFormat = 0, type = GL_UNSIGNED_INT_8_8_8_8; + JNIEnv table = *env; + GLboolean forceAlphaToOne = GL_FALSE; - GLenum oglFormat = 0, oglInternalFormat=0; - JNIEnv table = *env; - jbyte *byteData; - jshort *shortData; + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *)(*(table->GetPrimitiveArrayCritical))(env, (jarray)data, NULL); + } + else { + imageObjPtr = (void *)(*(table->GetDirectBufferAddress))(env, data); + } - switch (internalFormat) { + /* check if we are trying to draw NPOT on a system that doesn't support it */ + if ((!ctxProperties->textureNonPowerOfTwoAvailable) && + (!isPowerOfTwo(width) || !isPowerOfTwo(height) || !isPowerOfTwo(depth))) { + /* disable texture by setting width, height and depth to 0 */ + width = height = depth = 0; + } + + switch (textureFormat) { case INTENSITY: - oglInternalFormat = GL_INTENSITY; + internalFormat = GL_INTENSITY; break; case LUMINANCE: - oglInternalFormat = GL_LUMINANCE; + internalFormat = GL_LUMINANCE; break; case ALPHA: - oglInternalFormat = GL_ALPHA; + internalFormat = GL_ALPHA; break; case LUMINANCE_ALPHA: - oglInternalFormat = GL_LUMINANCE_ALPHA; + internalFormat = GL_LUMINANCE_ALPHA; break; case J3D_RGB: - oglInternalFormat = GL_RGB; + internalFormat = GL_RGB; break; case J3D_RGBA: - oglInternalFormat = GL_RGBA; - break; - } - - switch (format) { - case FORMAT_BYTE_RGBA: - /* all RGB types are stored as RGBA */ - oglFormat = GL_RGBA; - break; - case FORMAT_BYTE_RGB: - oglFormat = GL_RGB; + internalFormat = GL_RGBA; break; + default: + throwAssert(env, "updateTexture3DImage : textureFormat illegal format"); + return; + } - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - oglFormat = GL_ABGR_EXT; - } - break; - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - oglFormat = ctxProperties->bgr_ext_enum; - } - break; - case FORMAT_BYTE_LA: + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_BYTE_BUFFER)) { + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_BYTE_BGR: + format = GL_BGR; + break; + case IMAGE_FORMAT_BYTE_RGB: + format = GL_RGB; + break; + /* GL_ABGR_EXT */ + case IMAGE_FORMAT_BYTE_ABGR: + if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ + format = GL_ABGR_EXT; + } + else { + throwAssert(env, "updateTexture3DImage : GL_ABGR_EXT format is unsupported"); + return; + } + break; + case IMAGE_FORMAT_BYTE_RGBA: + format = GL_RGBA; + break; + case IMAGE_FORMAT_BYTE_LA: /* all LA types are stored as LA8 */ - oglFormat = GL_LUMINANCE_ALPHA; + format = GL_LUMINANCE_ALPHA; break; - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: - if (oglInternalFormat == GL_ALPHA) { - oglFormat = GL_ALPHA; + case IMAGE_FORMAT_BYTE_GRAY: + if (internalFormat == GL_ALPHA) { + format = GL_ALPHA; } else { - oglFormat = GL_LUMINANCE; + format = GL_LUMINANCE; } break; - } - /* - fprintf(stderr,"internalFormat = %x\n",internalFormat); - fprintf(stderr,"format = %x\n",format); - fprintf(stderr,"oglFormat = %x\n",oglFormat); - fprintf(stderr,"oglInternalFormat = %x\n",oglInternalFormat); - */ - if (imageYup != NULL) { - if (format != FORMAT_USHORT_GRAY) { - byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, - imageYup, - NULL); - } - else { /* unsigned short */ - shortData = (jshort *)(*(table->GetPrimitiveArrayCritical))(env, - imageYup, - NULL); + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_INT_BGR: + case IMAGE_FORMAT_INT_RGB: + case IMAGE_FORMAT_INT_ARGB: + default: + throwAssert(env, "updateTexture3DImage : imageFormat illegal format"); + return; + } - } - } else { - byteData = NULL; - shortData = NULL; + ctxProperties->glTexImage3DEXT(GL_TEXTURE_3D, + level, internalFormat, + width, height, depth, boundaryWidth, + format, GL_UNSIGNED_BYTE, + imageObjPtr); + + } + else if((dataType == IMAGE_DATA_TYPE_INT_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_BUFFER)) { + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_INT_BGR: /* Assume XBGR format */ + format = GL_RGBA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + forceAlphaToOne = GL_TRUE; + break; + case IMAGE_FORMAT_INT_RGB: /* Assume XRGB format */ + forceAlphaToOne = GL_TRUE; + /* Fall through to next case */ + case IMAGE_FORMAT_INT_ARGB: + format = GL_BGRA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + /* This method only supports 3 and 4 components formats and INT types. */ + case IMAGE_FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_ABGR: + default: + throwAssert(env, "updateTexture3DImage : imageFormat illegal format"); + return; + } + + /* Force Alpha to 1.0 if needed */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 0.0f); + glPixelTransferf(GL_ALPHA_BIAS, 1.0f); + } + + ctxProperties->glTexImage3DEXT(GL_TEXTURE_3D, + level, internalFormat, + width, height, depth, boundaryWidth, + format, type, imageObjPtr); + + /* Restore Alpha scale and bias */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + glPixelTransferf(GL_ALPHA_BIAS, 0.0f); } + } + else { + throwAssert(env, "updateTexture3DImage : illegal image data type"); + } - if (format != FORMAT_USHORT_GRAY) { - ctxProperties->glTexImage3DEXT(ctxProperties->texture_3D_ext_enum, - level, oglInternalFormat, - width, height, depth, boundaryWidth, - oglFormat, GL_UNSIGNED_BYTE, - (GLvoid *)byteData); - } - else { - ctxProperties->glTexImage3DEXT(ctxProperties->texture_3D_ext_enum, - level, oglInternalFormat, - width, height, depth, boundaryWidth, - oglFormat, GL_UNSIGNED_SHORT, - (GLvoid *)shortData); - } - if (imageYup != NULL) { - if (format != FORMAT_USHORT_GRAY) { - (*(table->ReleasePrimitiveArrayCritical))(env, imageYup, byteData, 0); - } else { /* unsigned short */ - (*(table->ReleasePrimitiveArrayCritical))(env, imageYup, shortData, 0); - - } - } - - /* No idea why we need following call. */ - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + (*(table->ReleasePrimitiveArrayCritical))(env, data, imageObjPtr, 0); } } JNIEXPORT -void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSubImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTexture3DSubImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint level, jint xoffset, jint yoffset, jint zoffset, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint imgXOffset, jint imgYOffset, jint imgZOffset, @@ -3037,139 +3057,195 @@ void JNICALL Java_javax_media_j3d_Texture3DRetained_updateTextureSubImage( jint width, jint height, jint depth, - jbyteArray image) { + jint dataType, + jobject data) { + void *imageObjPtr; + GLenum format = 0, internalFormat = 0, type = GL_UNSIGNED_INT_8_8_8_8; + JNIEnv table = *env; + GLboolean forceAlphaToOne = GL_FALSE; + jbyte *tmpByte; + jint *tmpInt; + jint numBytes = 0; + jboolean pixelStore = JNI_FALSE; + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - if (ctxProperties->texture3DAvailable) { - GLenum oglFormat = 0, oglInternalFormat=0; - JNIEnv table = *env; - jbyte *byteData, *tmpByte; - jshort *shortData, *tmpShort; - jint numBytes = 0; - jboolean pixelStore = JNI_FALSE; - - switch (internalFormat) { - case INTENSITY: - oglInternalFormat = GL_INTENSITY; - break; - case LUMINANCE: - oglInternalFormat = GL_LUMINANCE; - break; - case ALPHA: - oglInternalFormat = GL_ALPHA; - break; - case LUMINANCE_ALPHA: - oglInternalFormat = GL_LUMINANCE_ALPHA; - break; - case J3D_RGB: - oglInternalFormat = GL_RGB; - break; - case J3D_RGBA: - oglInternalFormat = GL_RGBA; - break; - } - - switch (format) { - case FORMAT_BYTE_RGBA: - /* all RGB types are stored as RGBA */ - oglFormat = GL_RGBA; - numBytes = 4; - break; - case FORMAT_BYTE_RGB: - oglFormat = GL_RGB; - numBytes = 3; - break; + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *)(*(table->GetPrimitiveArrayCritical))(env, (jarray)data, NULL); + } + else { + imageObjPtr = (void *)(*(table->GetDirectBufferAddress))(env, data); + } - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - oglFormat = GL_ABGR_EXT; - numBytes = 4; - } - break; - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - oglFormat = ctxProperties->bgr_ext_enum; - numBytes = 3; - } - break; + if (imgXOffset > 0 || (width < tilew)) { + pixelStore = JNI_TRUE; + glPixelStorei(GL_UNPACK_ROW_LENGTH, tilew); + } + + /* if NPOT textures are not supported, check if h=w=0, if so we have been + * disabled due to a NPOT texture being sent to a context that doesn't + * support it: disable the glTexSubImage as well + */ + if (!ctxProperties->textureNonPowerOfTwoAvailable) { + int texWidth, texHeight, texDepth; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &texWidth); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &texHeight); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_DEPTH, &texDepth); + if ((texWidth == 0) && (texHeight == 0) && (texDepth == 0)) { + /* disable the sub-image by setting it's width, height and depth to 0 */ + width = height = depth = 0; + } + } + + switch (textureFormat) { + case INTENSITY: + internalFormat = GL_INTENSITY; + break; + case LUMINANCE: + internalFormat = GL_LUMINANCE; + break; + case ALPHA: + internalFormat = GL_ALPHA; + break; + case LUMINANCE_ALPHA: + internalFormat = GL_LUMINANCE_ALPHA; + break; + case J3D_RGB: + internalFormat = GL_RGB; + break; + case J3D_RGBA: + internalFormat = GL_RGBA; + break; + default: + throwAssert(env, "updateTexture3DSubImage : textureFormat illegal format"); + break; + } - case FORMAT_BYTE_LA: - /* all LA types are stored as LA8 */ - oglFormat = GL_LUMINANCE_ALPHA; - numBytes = 2; - break; - case FORMAT_BYTE_GRAY: - if (oglInternalFormat == GL_ALPHA) { - oglFormat = GL_ALPHA; - } else { - oglFormat = GL_LUMINANCE; - } - numBytes = 1; - case FORMAT_USHORT_GRAY: - if (oglInternalFormat == GL_ALPHA) { - oglFormat = GL_ALPHA; - } else { - oglFormat = GL_LUMINANCE; - } - numBytes = 2; - break; - } - /* - fprintf(stderr,"format = %x\n",format); - fprintf(stderr,"oglFormat = %x\n",oglFormat); - fprintf(stderr, "imgXOffset = %d\n",imgXOffset); - fprintf(stderr, "imgYOffset = %d\n",imgYOffset); - fprintf(stderr, "imgZOffset = %d\n",imgZOffset); - fprintf(stderr, "xoffset = %d\n",xoffset); - fprintf(stderr, "yoffset = %d\n",yoffset); - fprintf(stderr, "zoffset = %d\n",zoffset); - fprintf(stderr, "tilew = %d\n",tilew); - fprintf(stderr, "tileh = %d\n",tilew); - fprintf(stderr, "numBytes = %d\n",numBytes); - fprintf(stderr, "width = %d\n",width); - fprintf(stderr, "height = %d\n",height); - fprintf(stderr, "depth = %d\n",depth); - */ - if (imgXOffset > 0 || (width < tilew)) { - pixelStore = JNI_TRUE; - glPixelStorei(GL_UNPACK_ROW_LENGTH, tilew); + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_BYTE_BUFFER)) { + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_BYTE_BGR: + format = GL_BGR; + numBytes = 3; + break; + case IMAGE_FORMAT_BYTE_RGB: + format = GL_RGB; + numBytes = 3; + break; + /* GL_ABGR_EXT */ + case IMAGE_FORMAT_BYTE_ABGR: + if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ + format = GL_ABGR_EXT; + numBytes = 4; + } + else { + throwAssert(env, "updateTexture3DSubImage : GL_ABGR_EXT format is unsupported"); + } + break; + case IMAGE_FORMAT_BYTE_RGBA: + format = GL_RGBA; + numBytes = 4; + break; + case IMAGE_FORMAT_BYTE_LA: + /* all LA types are stored as LA8 */ + format = GL_LUMINANCE_ALPHA; + numBytes = 2; + break; + case IMAGE_FORMAT_BYTE_GRAY: + if (internalFormat == GL_ALPHA) { + format = GL_ALPHA; + numBytes = 1; + } else { + format = GL_LUMINANCE; + numBytes = 1; + } + break; + + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_INT_BGR: + case IMAGE_FORMAT_INT_RGB: + case IMAGE_FORMAT_INT_ARGB: + default: + throwAssert(env, "updateTexture3DSubImage : imageFormat illegal format"); + break; } - - if (format != FORMAT_USHORT_GRAY) { - byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, - image, NULL); - - tmpByte = byteData + - (tilew * tileh * imgZOffset + - tilew * imgYOffset + imgXOffset) * numBytes; - - ctxProperties->glTexSubImage3DEXT( - ctxProperties->texture_3D_ext_enum, - level, xoffset, yoffset, zoffset, - width, height, depth, - oglFormat, GL_UNSIGNED_BYTE, - (GLvoid *)tmpByte); - - (*(table->ReleasePrimitiveArrayCritical))(env, image, byteData, 0); - } else { /* unsigned short */ - shortData = (jshort *)(*(table->GetPrimitiveArrayCritical))(env, - image, NULL); - tmpShort = (jshort*)((jbyte*)shortData+ - (tilew * tileh * imgZOffset + - tilew * imgYOffset + imgXOffset)*numBytes); + + tmpByte = (jbyte*)imageObjPtr + + (tilew * tileh * imgZOffset + tilew * imgYOffset + imgXOffset) * + numBytes; + + ctxProperties->glTexSubImage3DEXT(GL_TEXTURE_3D, + level, xoffset, yoffset, zoffset, + width, height, depth, + format, GL_UNSIGNED_BYTE, + (GLvoid *)tmpByte); + + + } + else if((dataType == IMAGE_DATA_TYPE_INT_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_BUFFER)) { + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_INT_BGR: /* Assume XBGR format */ + format = GL_RGBA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + forceAlphaToOne = GL_TRUE; + break; + case IMAGE_FORMAT_INT_RGB: /* Assume XRGB format */ + forceAlphaToOne = GL_TRUE; + /* Fall through to next case */ + case IMAGE_FORMAT_INT_ARGB: + format = GL_BGRA; + type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + /* This method only supports 3 and 4 components formats and INT types. */ + case IMAGE_FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_ABGR: + default: + throwAssert(env, "updateTexture3DSubImage : imageFormat illegal format"); + break; + } + + numBytes = 4; + + tmpInt = (jint*)((jbyte*)imageObjPtr + + (tilew * tileh * imgZOffset + + tilew * imgYOffset + imgXOffset)*numBytes); + + /* Force Alpha to 1.0 if needed */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 0.0f); + glPixelTransferf(GL_ALPHA_BIAS, 1.0f); + } + + ctxProperties->glTexSubImage3DEXT(GL_TEXTURE_3D, + level, xoffset, yoffset, zoffset, + width, height, depth, + format, type, + (GLvoid *)tmpInt); + + /* Restore Alpha scale and bias */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + glPixelTransferf(GL_ALPHA_BIAS, 0.0f); + } + } + else { + throwAssert(env, "updateTexture3DImage : illegal image data type"); + return; + } + + + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + (*(table->ReleasePrimitiveArrayCritical))(env, data, imageObjPtr, 0); + } - ctxProperties->glTexSubImage3DEXT( - ctxProperties->texture_3D_ext_enum, - level, xoffset, yoffset, zoffset, - width, height, depth, - oglFormat, GL_UNSIGNED_SHORT, - (GLvoid *)tmpShort); - (*(table->ReleasePrimitiveArrayCritical))(env, image, shortData, 0); - } - if (pixelStore) { - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - } + if (pixelStore) { + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); } } @@ -3189,9 +3265,9 @@ jint _gl_textureCubeMapFace[] = { JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_bindTexture( +void JNICALL Java_javax_media_j3d_NativePipeline_bindTextureCubeMap( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint objectId, jboolean enable) @@ -3202,39 +3278,33 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_bindTexture( * TextureCubeMap will take precedure over 3D Texture so * there is no need to disable 3D Texture here. */ - if (ctxProperties->textureCubeMapAvailable) { - if (enable == JNI_FALSE) { - glDisable(ctxProperties->texture_cube_map_ext_enum); - } else { - glBindTexture(ctxProperties->texture_cube_map_ext_enum, objectId); - glEnable(ctxProperties->texture_cube_map_ext_enum); - } + if (enable == JNI_FALSE) { + glDisable(GL_TEXTURE_CUBE_MAP); + } else { + glBindTexture(GL_TEXTURE_CUBE_MAP, objectId); + glEnable(GL_TEXTURE_CUBE_MAP); } } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureFilterModes( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapFilterModes( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint minFilter, jint magFilter) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if (ctxProperties->textureCubeMapAvailable) { - updateTextureFilterModes(ctxProperties, - ctxProperties->texture_cube_map_ext_enum, - minFilter, magFilter); - } + updateTextureFilterModes(ctxProperties, + GL_TEXTURE_CUBE_MAP, + minFilter, magFilter); } - - JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureLodRange( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapLodRange( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint baseLevel, jint maximumLevel, @@ -3245,15 +3315,15 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureLodRange( GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; updateTextureLodRange(ctxProperties, - ctxProperties->texture_cube_map_ext_enum, + GL_TEXTURE_CUBE_MAP, baseLevel, maximumLevel, minimumLOD, maximumLOD); } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureLodOffset( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapLodOffset( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jfloat lodOffsetS, jfloat lodOffsetT, @@ -3262,15 +3332,15 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureLodOffset( GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; updateTextureLodOffset(ctxProperties, - ctxProperties->texture_cube_map_ext_enum, + GL_TEXTURE_CUBE_MAP, lodOffsetS, lodOffsetT, lodOffsetR); } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureBoundary( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapBoundary( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint boundaryModeS, jint boundaryModeT, @@ -3281,117 +3351,110 @@ void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureBoundary( { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if (ctxProperties->textureCubeMapAvailable) { - updateTextureBoundary(ctxProperties, - ctxProperties->texture_cube_map_ext_enum, - boundaryModeS, boundaryModeT, -1, - boundaryRed, boundaryGreen, - boundaryBlue, boundaryAlpha); - } + updateTextureBoundary(ctxProperties, + GL_TEXTURE_CUBE_MAP, + boundaryModeS, boundaryModeT, -1, + boundaryRed, boundaryGreen, + boundaryBlue, boundaryAlpha); } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureSharpenFunc( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapSharpenFunc( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint numPts, jfloatArray pts) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if (ctxProperties->textureCubeMapAvailable) { - updateTextureSharpenFunc(env, ctxProperties, - ctxProperties->texture_cube_map_ext_enum, - numPts, pts); - } + updateTextureSharpenFunc(env, ctxProperties, + GL_TEXTURE_CUBE_MAP, + numPts, pts); } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureFilter4Func( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapFilter4Func( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint numPts, jfloatArray pts) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if (ctxProperties->textureCubeMapAvailable) { - updateTextureFilter4Func(env, ctxProperties, - ctxProperties->texture_cube_map_ext_enum, - numPts, pts); - } + updateTextureFilter4Func(env, ctxProperties, + GL_TEXTURE_CUBE_MAP, + numPts, pts); } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureAnisotropicFilter( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapAnisotropicFilter( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jfloat degree) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if (ctxProperties->textureCubeMapAvailable) { - updateTextureAnisotropicFilter(env, ctxProperties, - ctxProperties->texture_cube_map_ext_enum, - degree); - } + updateTextureAnisotropicFilter(env, ctxProperties, + GL_TEXTURE_CUBE_MAP, + degree); } - + JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureSubImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapSubImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint face, jint level, jint xoffset, jint yoffset, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint imgXOffset, jint imgYOffset, jint tilew, jint width, jint height, - jbyteArray image) { - + jint dataType, + jobject data) +{ GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; updateTexture2DSubImage(env, ctxProperties, _gl_textureCubeMapFace[face], - level, xoffset, yoffset, internalFormat, - format, imgXOffset, imgYOffset, tilew, - width, height, image); + level, xoffset, yoffset, textureFormat, + imageFormat, imgXOffset, imgYOffset, tilew, + width, height, dataType, data); } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureCubeMapRetained_updateTextureImage( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureCubeMapImage( JNIEnv *env, - jobject texture, + jobject obj, jlong ctxInfo, jint face, jint numLevels, jint level, - jint internalFormat, - jint format, + jint textureFormat, + jint imageFormat, jint width, jint height, jint boundaryWidth, - jbyteArray imageYup) + jint dataType, + jobject data) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; updateTexture2DImage(env, ctxProperties, _gl_textureCubeMapFace[face], - numLevels, level, internalFormat, format, - width, height, boundaryWidth, imageYup); + numLevels, level, textureFormat, imageFormat, + width, height, boundaryWidth, dataType, data); } - JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_decal1stChildSetup( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_decal1stChildSetup( JNIEnv *env, jobject obj, jlong ctxInfo) @@ -3408,7 +3471,7 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_decal1stChildSetup( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_decalNthChildSetup( +void JNICALL Java_javax_media_j3d_NativePipeline_decalNthChildSetup( JNIEnv *env, jobject obj, jlong ctxInfo) @@ -3419,7 +3482,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_decalNthChildSetup( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_decalReset( +void JNICALL Java_javax_media_j3d_NativePipeline_decalReset( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -3431,7 +3494,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_decalReset( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_ctxUpdateEyeLightingEnable( +void JNICALL Java_javax_media_j3d_NativePipeline_ctxUpdateEyeLightingEnable( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -3445,69 +3508,50 @@ void JNICALL Java_javax_media_j3d_Canvas3D_ctxUpdateEyeLightingEnable( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_updateSeparateSpecularColorEnable( +void JNICALL Java_javax_media_j3d_NativePipeline_updateSeparateSpecularColorEnable( JNIEnv *env, jobject obj, jlong ctxInfo, jboolean enable) { - /* - * This method will not be called if the rendering layer does not support - * separate specular color control. The checking of the availability - * of the functionality is done in Renderer at rendering time - */ - - /* 1.2 feature only */ - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - if(ctxProperties->seperate_specular_color) { - if (enable == JNI_TRUE) { - glLightModeli(ctxProperties->light_model_color_control_enum, - ctxProperties->seperate_specular_color_enum); - } else { - glLightModeli(ctxProperties->light_model_color_control_enum, ctxProperties->single_color_enum); - } + if (enable) { + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); + } else { + glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); } } JNIEXPORT -void JNICALL Java_javax_media_j3d_TextureUnitStateRetained_updateTextureUnitState( +void JNICALL Java_javax_media_j3d_NativePipeline_updateTextureUnitState( JNIEnv *env, - jobject cv, + jobject obj, jlong ctxInfo, jint index, jboolean enable) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - - if(ctxProperties->arb_multitexture) { - if (index >= 0) { - ctxProperties->glActiveTextureARB(index + GL_TEXTURE0_ARB); - ctxProperties->glClientActiveTextureARB(GL_TEXTURE0_ARB + index); - if (ctxProperties->textureRegisterCombinersAvailable) { - ctxProperties->currentTextureUnit = index + GL_TEXTURE0_ARB; - ctxProperties->currentCombinerUnit = index + GL_COMBINER0_NV; - if (ctxProperties->glCombinerParameteriNV!=NULL) - ctxProperties->glCombinerParameteriNV( - GL_NUM_GENERAL_COMBINERS_NV, index + 1); - } - } - } /* GL_ARB_multitexture */ + if (ctxProperties->gl13 && index >= 0) { + ctxProperties->glActiveTexture(index + GL_TEXTURE0); + ctxProperties->glClientActiveTexture(GL_TEXTURE0 + index); + if (ctxProperties->textureRegisterCombinersAvailable) { + ctxProperties->currentTextureUnit = index + GL_TEXTURE0; + ctxProperties->currentCombinerUnit = index + GL_COMBINER0_NV; + if (ctxProperties->glCombinerParameteriNV != NULL) + ctxProperties->glCombinerParameteriNV( + GL_NUM_GENERAL_COMBINERS_NV, index + 1); + } + } if (enable == JNI_FALSE) { /* if not enabled, then don't enable any tex mapping */ glDisable(GL_TEXTURE_1D); glDisable(GL_TEXTURE_2D); - - if(ctxProperties->texture3DAvailable) - glDisable(ctxProperties->texture_3D_ext_enum); - - if(ctxProperties->textureCubeMapAvailable) - glDisable(ctxProperties->texture_cube_map_ext_enum); - } + glDisable(GL_TEXTURE_3D); + glDisable(GL_TEXTURE_CUBE_MAP); + } /* * if it is enabled, the enable flag will be taken care of @@ -3517,7 +3561,7 @@ void JNICALL Java_javax_media_j3d_TextureUnitStateRetained_updateTextureUnitStat JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setBlendColor( +void JNICALL Java_javax_media_j3d_NativePipeline_setBlendColor( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -3541,7 +3585,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setBlendColor( JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setBlendFunc( +void JNICALL Java_javax_media_j3d_NativePipeline_setBlendFunc( JNIEnv * env, jobject obj, jlong ctxInfo, @@ -3555,7 +3599,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setBlendFunc( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setFogEnableFlag( +void JNICALL Java_javax_media_j3d_NativePipeline_setFogEnableFlag( JNIEnv * env, jobject obj, jlong ctxInfo, @@ -3568,7 +3612,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setFogEnableFlag( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_activeTextureUnit( +void JNICALL Java_javax_media_j3d_NativePipeline_activeTextureUnit( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -3576,28 +3620,12 @@ void JNICALL Java_javax_media_j3d_Canvas3D_activeTextureUnit( { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if(ctxProperties->arb_multitexture){ - ctxProperties->glActiveTextureARB(GL_TEXTURE0_ARB + index); - ctxProperties->glClientActiveTextureARB(GL_TEXTURE0_ARB + index); - /* GL_ARB_multitexture */ + if (ctxProperties->gl13) { + ctxProperties->glActiveTexture(GL_TEXTURE0 + index); + ctxProperties->glClientActiveTexture(GL_TEXTURE0 + index); } } -JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_updateTexUnitStateMap( - JNIEnv *env, - jobject obj, - jlong ctxInfo, - jint numActiveTexUnit, - jintArray texUnitStateMapArray) -{ - /* - * texture unit state map is explicitly handled in - * execute; for display list, texture unit has to match - * texture unit state. - */ -} - /* * strJavaToC @@ -3699,13 +3727,3 @@ createShaderError( return shaderError; } - - -void -throwAssert(JNIEnv *env, char *str) -{ - jclass rte; - if ((rte = (*env)->FindClass(env, "java/lang/AssertionError")) != NULL) { - (*env)->ThrowNew(env, rte, str); - } -} diff --git a/src/native/ogl/Canvas3D.c b/src/native/ogl/Canvas3D.c index 9c15e92..b6cb469 100644 --- a/src/native/ogl/Canvas3D.c +++ b/src/native/ogl/Canvas3D.c @@ -43,19 +43,18 @@ extern void throwAssert(JNIEnv *env, char *str); static void initializeCtxInfo(JNIEnv *env, GraphicsContextPropertiesInfo* ctxInfo); static void cleanupCtxInfo(GraphicsContextPropertiesInfo* ctxInfo); static void disableAttribFor2D(GraphicsContextPropertiesInfo *ctxProperties); +static void disableAttribForRaster(GraphicsContextPropertiesInfo *ctxProperties); /* * Class: javax_media_j3d_Canvas3D * Method: getTextureColorTableSize * Signature: ()I */ -extern int getTextureColorTableSize( +static int getTextureColorTableSize( JNIEnv *env, jobject obj, - jlong ctxInfo, - char *extensionStr, - int minorVersion); - + GraphicsContextPropertiesInfo *ctxInfo, + char *extensionStr); extern void checkGLSLShaderExtensions( JNIEnv *env, @@ -138,26 +137,25 @@ checkTextureExtensions( JNIEnv *env, jobject obj, char *tmpExtensionStr, - int versionNumber, GraphicsContextPropertiesInfo* ctxInfo) { - if (isExtensionSupported(tmpExtensionStr, "GL_ARB_multitexture")) { - ctxInfo->arb_multitexture = JNI_TRUE; + if (ctxInfo->gl13) { ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_MULTI_TEXTURE; - glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &ctxInfo->maxTextureUnits); + glGetIntegerv(GL_MAX_TEXTURE_UNITS, &ctxInfo->maxTextureUnits); ctxInfo->maxTexCoordSets = ctxInfo->maxTextureUnits; if (isExtensionSupported(tmpExtensionStr, "GL_ARB_vertex_shader")) { glGetIntegerv(GL_MAX_TEXTURE_COORDS_ARB, &ctxInfo->maxTexCoordSets); } } - + if(isExtensionSupported(tmpExtensionStr,"GL_SGI_texture_color_table" )){ ctxInfo->textureColorTableAvailable = JNI_TRUE; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_COLOR_TABLE; /* get texture color table size */ /* need to check later */ - ctxInfo->textureColorTableSize = getTextureColorTableSize(env, obj, (jlong)ctxInfo, tmpExtensionStr, versionNumber); + ctxInfo->textureColorTableSize = getTextureColorTableSize(env, obj, + ctxInfo, tmpExtensionStr); if (ctxInfo->textureColorTableSize <= 0) { ctxInfo->textureColorTableAvailable = JNI_FALSE; ctxInfo->textureExtMask &= ~javax_media_j3d_Canvas3D_TEXTURE_COLOR_TABLE; @@ -289,13 +287,7 @@ checkTextureExtensions( ctxInfo->combine_dot3_rgba_enum = GL_DOT3_RGBA_EXT; } - if (isExtensionSupported(tmpExtensionStr, "GL_ARB_texture_cube_map")) { - ctxInfo->texture_cube_map_ext_enum = GL_TEXTURE_CUBE_MAP_ARB; - ctxInfo->textureCubeMapAvailable = JNI_TRUE; - ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_CUBE_MAP; - } else if (isExtensionSupported(tmpExtensionStr, "GL_EXT_texture_cube_map")) { - ctxInfo->texture_cube_map_ext_enum = GL_TEXTURE_CUBE_MAP_EXT; - ctxInfo->textureCubeMapAvailable = JNI_TRUE; + if (ctxInfo->gl13) { ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_CUBE_MAP; } @@ -374,22 +366,26 @@ checkTextureExtensions( javax_media_j3d_Canvas3D_TEXTURE_ANISOTROPIC_FILTER; } - if (isExtensionSupported(tmpExtensionStr, - "GL_ARB_texture_border_clamp")) { - ctxInfo->texture_clamp_to_border_enum = GL_CLAMP_TO_BORDER_ARB; - } else if (isExtensionSupported(tmpExtensionStr, - "GL_SGIS_texture_border_clamp")) { - ctxInfo->texture_clamp_to_border_enum = GL_CLAMP_TO_BORDER_SGIS; + if (ctxInfo->gl13) { + ctxInfo->texture_clamp_to_border_enum = GL_CLAMP_TO_BORDER; } else { ctxInfo->texture_clamp_to_border_enum = GL_CLAMP; } - + if (isExtensionSupported(tmpExtensionStr, "GL_SGIX_texture_lod_bias")) { ctxInfo->textureLodBiasAvailable = JNI_TRUE; ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_LOD_OFFSET; } + + if (isExtensionSupported(tmpExtensionStr, + "GL_ARB_texture_non_power_of_two")) { + ctxInfo->textureNonPowerOfTwoAvailable = JNI_TRUE; + ctxInfo->textureExtMask |= + javax_media_j3d_Canvas3D_TEXTURE_NON_POWER_OF_TWO; + } + } jboolean @@ -433,6 +429,47 @@ getJavaBoolEnv(JNIEnv *env, char* envStr) return (*(table->GetBooleanField))(env, obj, fieldID); } +jint +getJavaIntEnv(JNIEnv *env, char* envStr) +{ + JNIEnv table = *env; + jclass cls; + jfieldID fieldID; + jobject obj; + + cls = (jclass) (*(table->FindClass))(env, "javax/media/j3d/VirtualUniverse"); + + if (cls == NULL) { + return JNI_FALSE; + } + + fieldID = (jfieldID) (*(table->GetStaticFieldID))(env, cls, "mc", + "Ljavax/media/j3d/MasterControl;"); + if (fieldID == NULL) { + return JNI_FALSE; + } + + obj = (*(table->GetStaticObjectField))(env, cls, fieldID); + + if (obj == NULL) { + return JNI_FALSE; + } + + cls = (jclass) (*(table->FindClass))(env, "javax/media/j3d/MasterControl"); + + if (cls == NULL) { + return JNI_FALSE; + } + + fieldID = (jfieldID) (*(table->GetFieldID))(env, cls, envStr, "I"); + + if (fieldID == NULL ) { + return JNI_FALSE; + } + + return (*(table->GetIntField))(env, obj, fieldID); +} + /* * Dummy functions for language-independent vertex attribute functions */ @@ -536,88 +573,96 @@ getPropertiesFromCurrentContext( /* find out the version, major and minor version number */ extractVersionInfo(tmpVersionStr, versionNumbers); + /* *********************************************************/ /* setup the graphics context properties */ - /* NOTE : At some point we will want to require OpenGL 1.3 */ - /* Check for OpenGL 1.2 core or better */ - if ((versionNumbers[0] > 1) || - (versionNumbers[0] == 1 && versionNumbers[1] >= 2)) { + /* + * NOTE: Java 3D now requires OpenGL 1.3 for full functionality. + * For backwards compatibility with certain older graphics cards and + * drivers (e.g., the Linux DRI driver for older ATI cards), + * we will try to run on OpenGL 1.2 in an unsupported manner. However, + * we will not attempt to use OpenGL extensions for any features that + * are available in OpenGL 1.3, specifically multitexture, multisample, + * and cube map textures. + */ + if (versionNumbers[0] < 1 || + (versionNumbers[0] == 1 && versionNumbers[1] < 2)) { + jclass rte; - if (versionNumbers[0] == 1 && versionNumbers[1] == 2) { - fprintf(stderr, - "Java 3D WARNING : OpenGL 1.3 will be required in the near future (GL_VERSION=%d.%d)\n", + fprintf(stderr, + "Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=%d.%d)\n", versionNumbers[0], versionNumbers[1]); + if ((rte = (*(table->FindClass))(env, "javax/media/j3d/IllegalRenderingStateException")) != NULL) { + (*(table->ThrowNew))(env, rte, "GL_VERSION"); } + return JNI_FALSE; + } + + if (versionNumbers[0] > 1) { + /* OpenGL 2.x -- set flags for 1.3 and 2.0 or greater */ + ctxInfo->gl20 = JNI_TRUE; + ctxInfo->gl13 = JNI_TRUE; + } + else { + if (versionNumbers[1] == 2) { + fprintf(stderr, + "*********************************************************\n"); + fprintf(stderr, + "*** JAVA 3D: WARNING OpenGL 1.2 is no longer supported.\n"); + fprintf(stderr, + "*** Will attempt to run with reduced functionality.\n"); + fprintf(stderr, + "*********************************************************\n"); + } else { + // OpenGL 1.x (1.3 or greater) + ctxInfo->gl13 = JNI_TRUE; + } + } + - ctxInfo->rescale_normal_ext = JNI_TRUE; - ctxInfo->rescale_normal_ext_enum = GL_RESCALE_NORMAL; - ctxInfo->bgr_ext = JNI_TRUE; - ctxInfo->bgr_ext_enum = GL_BGR; - ctxInfo->texture3DAvailable = JNI_TRUE; - ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_3D; + /* Setup function pointers for core OpenGL 1.3 features */ + + ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_3D; #if defined(UNIX) - ctxInfo->glTexImage3DEXT = (MYPFNGLTEXIMAGE3DPROC )dlsym(RTLD_DEFAULT, "glTexImage3D"); - ctxInfo->glTexSubImage3DEXT = (MYPFNGLTEXSUBIMAGE3DPROC )dlsym(RTLD_DEFAULT, "glTexSubImage3D"); + ctxInfo->glTexImage3DEXT = (MYPFNGLTEXIMAGE3DPROC )dlsym(RTLD_DEFAULT, "glTexImage3D"); + ctxInfo->glTexSubImage3DEXT = (MYPFNGLTEXSUBIMAGE3DPROC )dlsym(RTLD_DEFAULT, "glTexSubImage3D"); #endif #ifdef WIN32 - ctxInfo->glTexImage3DEXT = (MYPFNGLTEXIMAGE3DPROC )wglGetProcAddress("glTexImage3D"); - ctxInfo->glTexSubImage3DEXT = (MYPFNGLTEXSUBIMAGE3DPROC )wglGetProcAddress("glTexSubImage3D"); - if ((ctxInfo->glTexImage3DEXT == NULL) || (ctxInfo->glTexSubImage3DEXT == NULL)) { - ctxInfo->textureExtMask &= ~javax_media_j3d_Canvas3D_TEXTURE_3D; - ctxInfo->texture3DAvailable = JNI_FALSE; - } + ctxInfo->glTexImage3DEXT = (MYPFNGLTEXIMAGE3DPROC )wglGetProcAddress("glTexImage3D"); + ctxInfo->glTexSubImage3DEXT = (MYPFNGLTEXSUBIMAGE3DPROC )wglGetProcAddress("glTexSubImage3D"); #endif - ctxInfo->texture_3D_ext_enum = GL_TEXTURE_3D; - ctxInfo->texture_wrap_r_ext_enum = GL_TEXTURE_WRAP_R; - ctxInfo->texture_clamp_to_edge_enum = GL_CLAMP_TO_EDGE; - if(isExtensionSupported(tmpExtensionStr, "GL_ARB_imaging")){ - ctxInfo->blend_color_ext = JNI_TRUE; - - ctxInfo->blendFunctionTable[BLEND_CONSTANT_COLOR] = GL_CONSTANT_COLOR; + if(isExtensionSupported(tmpExtensionStr, "GL_ARB_imaging")){ + ctxInfo->blend_color_ext = JNI_TRUE; + + ctxInfo->blendFunctionTable[BLEND_CONSTANT_COLOR] = GL_CONSTANT_COLOR; #if defined(UNIX) - ctxInfo->glBlendColor = (MYPFNGLBLENDCOLORPROC )dlsym(RTLD_DEFAULT, "glBlendColor"); + ctxInfo->glBlendColor = (MYPFNGLBLENDCOLORPROC )dlsym(RTLD_DEFAULT, "glBlendColor"); #endif #ifdef WIN32 - ctxInfo->glBlendColor = (MYPFNGLBLENDCOLORPROC )wglGetProcAddress("glBlendColor"); - if (ctxInfo->glBlendColor == NULL) { - ctxInfo->blend_color_ext = JNI_FALSE; - } + ctxInfo->glBlendColor = (MYPFNGLBLENDCOLORPROC )wglGetProcAddress("glBlendColor"); + if (ctxInfo->glBlendColor == NULL) { + ctxInfo->blend_color_ext = JNI_FALSE; + } #endif - } - - ctxInfo->seperate_specular_color = JNI_TRUE; - ctxInfo->light_model_color_control_enum = GL_LIGHT_MODEL_COLOR_CONTROL; - ctxInfo->single_color_enum = GL_SINGLE_COLOR; - ctxInfo->seperate_specular_color_enum = GL_SEPARATE_SPECULAR_COLOR; + } - ctxInfo->textureLodAvailable = JNI_TRUE; - ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_LOD_RANGE; - ctxInfo->texture_min_lod_enum = GL_TEXTURE_MIN_LOD; - ctxInfo->texture_max_lod_enum = GL_TEXTURE_MAX_LOD; - ctxInfo->texture_base_level_enum = GL_TEXTURE_BASE_LEVEL; - ctxInfo->texture_max_level_enum = GL_TEXTURE_MAX_LEVEL; + ctxInfo->textureLodAvailable = JNI_TRUE; + ctxInfo->textureExtMask |= javax_media_j3d_Canvas3D_TEXTURE_LOD_RANGE; + ctxInfo->texture_min_lod_enum = GL_TEXTURE_MIN_LOD; + ctxInfo->texture_max_lod_enum = GL_TEXTURE_MAX_LOD; + ctxInfo->texture_base_level_enum = GL_TEXTURE_BASE_LEVEL; + ctxInfo->texture_max_level_enum = GL_TEXTURE_MAX_LEVEL; - /* ... */ - } - else { - jclass rte; - fprintf(stderr, - "Java 3D ERROR : OpenGL 1.2 or better is required (GL_VERSION=%d.%d)\n", - versionNumbers[0], versionNumbers[1]); - if ((rte = (*(table->FindClass))(env, "java/lang/IllegalStateException")) != NULL) { - (*(table->ThrowNew))(env, rte, "GL_VERSION"); - } - return JNI_FALSE; + /* look for OpenGL 2.0 features */ + if (ctxInfo->gl20) { + ctxInfo->textureNonPowerOfTwoAvailable = JNI_TRUE; + ctxInfo->textureExtMask |= + javax_media_j3d_Canvas3D_TEXTURE_NON_POWER_OF_TWO; } - /* - * TODO: Remove extension checks for those features that are core - * in OpenGL 1.2 and just use the core feature. - */ - /* check extensions for remaining of 1.1 and 1.2 */ if(isExtensionSupported(tmpExtensionStr, "GL_EXT_multi_draw_arrays")){ ctxInfo->multi_draw_arrays_ext = JNI_TRUE; @@ -632,45 +677,29 @@ getPropertiesFromCurrentContext( ctxInfo->compiled_vertex_array_ext = JNI_TRUE; } - - if(isExtensionSupported(tmpExtensionStr, "GLX_SUN_video_resize")){ - ctxInfo->videoResizeAvailable = JNI_TRUE; - ctxInfo->extMask |= javax_media_j3d_Canvas3D_SUN_VIDEO_RESIZE; - } - if(isExtensionSupported(tmpExtensionStr, "GL_SUN_global_alpha")){ ctxInfo->global_alpha_sun = JNI_TRUE; } - if(isExtensionSupported(tmpExtensionStr, "GL_SUNX_constant_data")){ - ctxInfo->constant_data_sun = JNI_TRUE; - } - if(isExtensionSupported(tmpExtensionStr, "GL_EXT_abgr")) { ctxInfo->abgr_ext = JNI_TRUE; } - - if(isExtensionSupported(tmpExtensionStr, "GL_ARB_transpose_matrix")) { - ctxInfo->arb_transpose_matrix = JNI_TRUE; - } -#if defined(UNIX) /* - * setup ARB_multisample, under windows this is setup in + * Setup ctxInfo->multisample; under windows this is setup in * NativeConfigTemplate when pixel format is choose */ - if (isExtensionSupported(tmpExtensionStr, "GL_ARB_multisample")){ - ctxInfo->arb_multisample = JNI_TRUE; - } +#if defined(UNIX) + ctxInfo->multisample = ctxInfo->gl13; #endif #ifdef WIN32 if(offScreen) { - ctxInfo->arb_multisample = PixelFormatInfoPtr->offScreenHasMultisample; + ctxInfo->multisample = PixelFormatInfoPtr->offScreenHasMultisample; } else { - ctxInfo->arb_multisample = PixelFormatInfoPtr->onScreenHasMultisample; + ctxInfo->multisample = PixelFormatInfoPtr->onScreenHasMultisample; } /* @@ -678,8 +707,8 @@ getPropertiesFromCurrentContext( PixelFormatInfoPtr->onScreenHasMultisample, PixelFormatInfoPtr->offScreenHasMultisample); - fprintf(stderr, "Canvas3D - ctxInfo->arb_multisample = %d, offScreen = %d\n", - ctxInfo->arb_multisample, offScreen); + fprintf(stderr, "Canvas3D - ctxInfo->multisample = %d, offScreen = %d\n", + ctxInfo->multisample, offScreen); */ #endif @@ -688,75 +717,43 @@ getPropertiesFromCurrentContext( * Disable multisample by default since OpenGL will enable * it by default if the surface is multisample capable. */ - if (ctxInfo->arb_multisample && !ctxInfo->implicit_multisample) { - glDisable(GL_MULTISAMPLE_ARB); + if (ctxInfo->multisample && !ctxInfo->implicit_multisample) { + glDisable(GL_MULTISAMPLE); } /* Check texture extensions */ - checkTextureExtensions(env, obj, tmpExtensionStr, versionNumbers[1], - ctxInfo); + checkTextureExtensions(env, obj, tmpExtensionStr, ctxInfo); /* Check shader extensions */ - checkGLSLShaderExtensions(env, obj, tmpExtensionStr, ctxInfo, glslLibraryAvailable); - checkCgShaderExtensions(env, obj, tmpExtensionStr, ctxInfo, cgLibraryAvailable); - - /* ... */ - - /* *********************************************************/ - /* Set up rescale_normal if extension supported */ - if (ctxInfo->rescale_normal_ext ) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_EXT_RESCALE_NORMAL; + if (ctxInfo->gl13) { + checkGLSLShaderExtensions(env, obj, tmpExtensionStr, ctxInfo, glslLibraryAvailable); + checkCgShaderExtensions(env, obj, tmpExtensionStr, ctxInfo, cgLibraryAvailable); + } else { + /* Force shaders to be disabled, since no multitexture support */ + char *emptyExtStr = " "; + checkGLSLShaderExtensions(env, obj, emptyExtStr, ctxInfo, JNI_FALSE); + checkCgShaderExtensions(env, obj, emptyExtStr, ctxInfo, JNI_FALSE); } - /* Setup the multi_draw_array */ - if(ctxInfo->multi_draw_arrays_ext) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_EXT_MULTI_DRAW_ARRAYS; - } else if (ctxInfo->multi_draw_arrays_sun) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_SUN_MULTI_DRAW_ARRAYS; - } - if(ctxInfo->compiled_vertex_array_ext) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_EXT_COMPILED_VERTEX_ARRAYS; - } - + /* *********************************************************/ /* Setup GL_SUN_gloabl_alpha */ if (ctxInfo->global_alpha_sun) { ctxInfo->extMask |= javax_media_j3d_Canvas3D_SUN_GLOBAL_ALPHA; } - /* Setup GL_SUNX_constant_data */ - if (ctxInfo->constant_data_sun) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_SUN_CONSTANT_DATA; - } - /* Setup GL_EXT_abgr */ if (ctxInfo->abgr_ext) { ctxInfo->extMask |= javax_media_j3d_Canvas3D_EXT_ABGR; } - /* Setup GL_BGR_EXT */ - if (ctxInfo->bgr_ext) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_EXT_BGR; - } + /* GL_BGR is always supported */ + ctxInfo->extMask |= javax_media_j3d_Canvas3D_EXT_BGR; - /* Setup GL_ARB_transpose_matrix */ - if (ctxInfo->arb_transpose_matrix) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_ARB_TRANSPOSE_MATRIX; - } - - /* Setup GL_EXT_separate_specular_color */ - if(ctxInfo->seperate_specular_color) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_EXT_SEPARATE_SPECULAR_COLOR; - } - - if (ctxInfo->constant_data_sun) { - /* glPixelStorei(GL_UNPACK_CONSTANT_DATA_SUNX, GL_TRUE); */ + if(ctxInfo->multisample) { + ctxInfo->extMask |= javax_media_j3d_Canvas3D_MULTISAMPLE; } - - if(ctxInfo->arb_multisample) { - ctxInfo->extMask |= javax_media_j3d_Canvas3D_ARB_MULTISAMPLE; - } - + /* setup those functions pointers */ #ifdef WIN32 @@ -786,53 +783,15 @@ getPropertiesFromCurrentContext( } } - if (ctxInfo->arb_multitexture) { - ctxInfo->glClientActiveTextureARB = (MYPFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress("glClientActiveTextureARB"); - ctxInfo->glMultiTexCoord2fvARB = (MYPFNGLMULTITEXCOORD2FVARBPROC)wglGetProcAddress("glMultiTexCoord2fvARB"); - ctxInfo->glMultiTexCoord3fvARB = (MYPFNGLMULTITEXCOORD3FVARBPROC)wglGetProcAddress("glMultiTexCoord3fvARB"); - ctxInfo->glMultiTexCoord4fvARB = (MYPFNGLMULTITEXCOORD4FVARBPROC)wglGetProcAddress("glMultiTexCoord4fvARB"); - ctxInfo->glActiveTextureARB = (MYPFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB"); - /* - if (ctxInfo->glClientActiveTextureARB == NULL) { - printf("ctxInfo->glClientActiveTextureARB == NULL\n"); - } - if (ctxInfo->glMultiTexCoord2fvARB == NULL) { - printf("ctxInfo->glMultiTexCoord2fvARB == NULL\n"); - } - if (ctxInfo->glMultiTexCoord3fvARB == NULL) { - printf("ctxInfo->glMultiTexCoord3fvARB == NULL\n"); - } - if (ctxInfo->glMultiTexCoord4fvARB == NULL) { - printf("ctxInfo->glMultiTexCoord4fvARB == NULL\n"); - } - if (ctxInfo->glActiveTextureARB == NULL) { - printf("ctxInfo->glActiveTextureARB == NULL\n"); - } - */ - if ((ctxInfo->glClientActiveTextureARB == NULL) || - (ctxInfo->glMultiTexCoord2fvARB == NULL) || - (ctxInfo->glMultiTexCoord3fvARB == NULL) || - (ctxInfo->glMultiTexCoord4fvARB == NULL) || - (ctxInfo->glActiveTextureARB == NULL)) { - ctxInfo->arb_multitexture = JNI_FALSE; - } - } - - if(ctxInfo->arb_transpose_matrix) { - ctxInfo->glLoadTransposeMatrixdARB = (MYPFNGLLOADTRANSPOSEMATRIXDARBPROC)wglGetProcAddress("glLoadTransposeMatrixdARB"); - ctxInfo->glMultTransposeMatrixdARB = (MYPFNGLMULTTRANSPOSEMATRIXDARBPROC)wglGetProcAddress("glMultTransposeMatrixdARB"); - /* - if (ctxInfo->glLoadTransposeMatrixdARB == NULL) { - printf("ctxInfo->glLoadTransposeMatrixdARB == NULL\n"); - } - if (ctxInfo->glMultTransposeMatrixdARB == NULL) { - printf("ctxInfo->glMultTransposeMatrixdARB == NULL\n"); - } - */ - if ((ctxInfo->glLoadTransposeMatrixdARB == NULL) || - (ctxInfo->glMultTransposeMatrixdARB == NULL)) { - ctxInfo->arb_transpose_matrix = JNI_FALSE; - } + if (ctxInfo->gl13) { + ctxInfo->glClientActiveTexture = (MYPFNGLCLIENTACTIVETEXTUREPROC)wglGetProcAddress("glClientActiveTexture"); + ctxInfo->glActiveTexture = (MYPFNGLACTIVETEXTUREPROC) wglGetProcAddress("glActiveTexture"); + ctxInfo->glMultiTexCoord2fv = (MYPFNGLMULTITEXCOORD2FVPROC)wglGetProcAddress("glMultiTexCoord2fv"); + ctxInfo->glMultiTexCoord3fv = (MYPFNGLMULTITEXCOORD3FVPROC)wglGetProcAddress("glMultiTexCoord3fv"); + ctxInfo->glMultiTexCoord4fv = (MYPFNGLMULTITEXCOORD4FVPROC)wglGetProcAddress("glMultiTexCoord4fv"); + + ctxInfo->glLoadTransposeMatrixd = (MYPFNGLLOADTRANSPOSEMATRIXDPROC)wglGetProcAddress("glLoadTransposeMatrixd"); + ctxInfo->glMultTransposeMatrixd = (MYPFNGLMULTTRANSPOSEMATRIXDPROC)wglGetProcAddress("glMultTransposeMatrixd"); } if (ctxInfo->global_alpha_sun) { @@ -878,35 +837,24 @@ getPropertiesFromCurrentContext( } } - if(ctxInfo->arb_multitexture){ - ctxInfo->glClientActiveTextureARB = - (MYPFNGLCLIENTACTIVETEXTUREARBPROC)dlsym(RTLD_DEFAULT, "glClientActiveTextureARB"); - ctxInfo->glMultiTexCoord2fvARB = - (MYPFNGLMULTITEXCOORD2FVARBPROC)dlsym(RTLD_DEFAULT, "glMultiTexCoord2fvARB"); - ctxInfo->glMultiTexCoord3fvARB = - (MYPFNGLMULTITEXCOORD3FVARBPROC)dlsym(RTLD_DEFAULT, "glMultiTexCoord3fvARB"); - ctxInfo->glMultiTexCoord4fvARB = - (MYPFNGLMULTITEXCOORD4FVARBPROC)dlsym(RTLD_DEFAULT, "glMultiTexCoord4fvARB"); - ctxInfo->glActiveTextureARB = - (MYPFNGLACTIVETEXTUREARBPROC)dlsym(RTLD_DEFAULT, "glActiveTextureARB"); - if ((ctxInfo->glClientActiveTextureARB == NULL) || - (ctxInfo->glMultiTexCoord2fvARB == NULL) || - (ctxInfo->glMultiTexCoord3fvARB == NULL) || - (ctxInfo->glMultiTexCoord4fvARB == NULL) || - (ctxInfo->glActiveTextureARB == NULL)) { - ctxInfo->arb_multitexture = JNI_FALSE; - } - } - if(ctxInfo->arb_transpose_matrix) { - ctxInfo->glLoadTransposeMatrixdARB = - (MYPFNGLLOADTRANSPOSEMATRIXDARBPROC)dlsym(RTLD_DEFAULT, "glLoadTransposeMatrixdARB"); - ctxInfo->glMultTransposeMatrixdARB = - (MYPFNGLMULTTRANSPOSEMATRIXDARBPROC)dlsym(RTLD_DEFAULT, "glMultTransposeMatrixdARB"); - if ((ctxInfo->glLoadTransposeMatrixdARB == NULL) || - (ctxInfo->glMultTransposeMatrixdARB == NULL)) { - ctxInfo->arb_transpose_matrix = JNI_FALSE; - } + if(ctxInfo->gl13){ + ctxInfo->glClientActiveTexture = + (MYPFNGLCLIENTACTIVETEXTUREPROC)dlsym(RTLD_DEFAULT, "glClientActiveTexture"); + ctxInfo->glMultiTexCoord2fv = + (MYPFNGLMULTITEXCOORD2FVPROC)dlsym(RTLD_DEFAULT, "glMultiTexCoord2fv"); + ctxInfo->glMultiTexCoord3fv = + (MYPFNGLMULTITEXCOORD3FVPROC)dlsym(RTLD_DEFAULT, "glMultiTexCoord3fv"); + ctxInfo->glMultiTexCoord4fv = + (MYPFNGLMULTITEXCOORD4FVPROC)dlsym(RTLD_DEFAULT, "glMultiTexCoord4fv"); + ctxInfo->glActiveTexture = + (MYPFNGLACTIVETEXTUREPROC)dlsym(RTLD_DEFAULT, "glActiveTexture"); + + ctxInfo->glLoadTransposeMatrixd = + (MYPFNGLLOADTRANSPOSEMATRIXDPROC)dlsym(RTLD_DEFAULT, "glLoadTransposeMatrixd"); + ctxInfo->glMultTransposeMatrixd = + (MYPFNGLMULTTRANSPOSEMATRIXDPROC)dlsym(RTLD_DEFAULT, "glMultTransposeMatrixd"); } + if(ctxInfo->global_alpha_sun) { ctxInfo->glGlobalAlphaFactorfSUN = (MYPFNGLGLOBALALPHAFACTORFSUNPROC)dlsym(RTLD_DEFAULT, "glGlobalAlphaFactorfSUN"); @@ -914,15 +862,6 @@ getPropertiesFromCurrentContext( ctxInfo->global_alpha_sun = JNI_FALSE; } } - - if(ctxInfo->videoResizeAvailable) { - ctxInfo->glXVideoResizeSUN = - (MYPFNGLXVIDEORESIZESUN)dlsym(RTLD_DEFAULT, "glXVideoResizeSUN"); - if (ctxInfo->glXVideoResizeSUN == NULL) { - ctxInfo->videoResizeAvailable = JNI_FALSE; - ctxInfo->extMask &= ~javax_media_j3d_Canvas3D_SUN_VIDEO_RESIZE; - } - } #endif /* UNIX */ @@ -950,22 +889,20 @@ void setupCanvasProperties( /* set the canvas.multiTexAccelerated flag */ rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "multiTexAccelerated", "Z"); - (*(table->SetBooleanField))(env, obj, rsc_field, ctxInfo->arb_multitexture); - - if (ctxInfo->arb_multitexture) { - rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTextureUnits", "I"); - (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTextureUnits); - rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTexCoordSets", "I"); - (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTexCoordSets); - rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTextureImageUnits", "I"); - (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTextureImageUnits); - rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxVertexTextureImageUnits", "I"); - (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxVertexTextureImageUnits); - rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxCombinedTextureImageUnits", "I"); - (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxCombinedTextureImageUnits); - rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxVertexAttrs", "I"); - (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxVertexAttrs); - } + (*(table->SetBooleanField))(env, obj, rsc_field, ctxInfo->gl13); + + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTextureUnits", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTextureUnits); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTexCoordSets", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTexCoordSets); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxTextureImageUnits", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxTextureImageUnits); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxVertexTextureImageUnits", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxVertexTextureImageUnits); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxCombinedTextureImageUnits", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxCombinedTextureImageUnits); + rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "maxVertexAttrs", "I"); + (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->maxVertexAttrs); rsc_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "extensionsSupported", "I"); (*(table->SetIntField))(env, obj, rsc_field, ctxInfo->extMask); @@ -1025,11 +962,11 @@ void setupCanvasProperties( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_destroyContext( +void JNICALL Java_javax_media_j3d_NativePipeline_destroyContext( JNIEnv *env, - jclass cl, + jobject obj, jlong display, - jint window, + jlong window, jlong ctxInfo) { GraphicsContextPropertiesInfo* s = (GraphicsContextPropertiesInfo* )ctxInfo; @@ -1075,12 +1012,12 @@ LONG WINAPI WndProc( HWND hWnd, UINT msg, JNIEXPORT -jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( +jlong JNICALL Java_javax_media_j3d_NativePipeline_createNewContext( JNIEnv *env, jobject obj, + jobject cv, jlong display, - jint window, - jint vid, + jlong window, jlong fbConfigListPtr, jlong sharedCtxInfo, jboolean isSharedCtx, @@ -1092,9 +1029,6 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( jlong sharedCtx; int stencilSize=0; - static GLboolean first_time = GL_TRUE; - static GLboolean force_normalize = GL_FALSE; - GraphicsContextPropertiesInfo *ctxInfo = NULL; GraphicsContextPropertiesInfo *sharedCtxStructure; int PixelFormatID=0; @@ -1133,7 +1067,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( else if((fbConfigList == NULL) || (fbConfigList[0] == NULL)) { /* * fbConfig must be a valid pointer to an GLXFBConfig struct returned - * by glXChooseFBConfig() for a physical screen. The visual id in vid + * by glXChooseFBConfig() for a physical screen. The visual id * is not sufficient for handling OpenGL with Xinerama mode disabled: * it doesn't distinguish between the physical screens making up the * virtual screen when the X server is running in Xinerama mode. @@ -1186,7 +1120,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( /* fprintf(stderr, "Canvas3D_createNewContext: \n"); - fprintf(stderr, "vid %d window 0x%x\n", vid, window); + fprintf(stderr, "window 0x%x\n", window); */ if(sharedCtxInfo == 0) sharedCtx = 0; @@ -1198,11 +1132,7 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( hdc = (HDC) window; /* Need to handle onScreen and offScreen differently */ - /* vid is for onScreen and fbConfigListPtr is for offScreen */ - /* - * vid must be a PixelFormat returned - * by wglChoosePixelFormat() or wglChoosePixelFormatARB. - */ + /* fbConfigListPtr has both an on-screen and off-screen pixel format */ if(!offScreen) { /* Fix to issue 104 */ if ((PixelFormatInfoPtr == NULL) || (PixelFormatInfoPtr->onScreenPFormat <= 0)) { @@ -1268,53 +1198,41 @@ jlong JNICALL Java_javax_media_j3d_Canvas3D_createNewContext( initializeCtxInfo(env, ctxInfo); ctxInfo->context = gctx; - if (!getPropertiesFromCurrentContext(env, obj, ctxInfo, (jlong) hdc, PixelFormatID, + if (!getPropertiesFromCurrentContext(env, cv, ctxInfo, (jlong) hdc, PixelFormatID, fbConfigListPtr, offScreen, glslLibraryAvailable, cgLibraryAvailable)) { return 0; } - /* setup structure */ if(!isSharedCtx){ /* Setup field in Java side */ - setupCanvasProperties(env, obj, ctxInfo); - } - - /* Set up rescale_normal if extension supported */ - if (first_time && getJavaBoolEnv(env, "isForceNormalized")) { - force_normalize = GL_TRUE; - first_time = GL_FALSE; + setupCanvasProperties(env, cv, ctxInfo); } - if (force_normalize) { - /* Disable rescale normal */ - ctxInfo->rescale_normal_ext = GL_FALSE; - } - - if (ctxInfo->rescale_normal_ext ) { - glEnable(ctxInfo->rescale_normal_ext_enum); - } - else { - glEnable(GL_NORMALIZE); - } + /* Enable rescale normal */ + glEnable(GL_RESCALE_NORMAL); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); glDepthFunc(GL_LEQUAL); glEnable(GL_COLOR_MATERIAL); glReadBuffer(GL_FRONT); + + /* Java 3D images are aligned to 1 byte */ + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + return ((jlong)ctxInfo); } JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_useCtx( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_useCtx( JNIEnv *env, - jclass cl, + jobject obj, jlong ctxInfo, jlong display, - jint window) + jlong window) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; @@ -1351,7 +1269,7 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_useCtx( } JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_getNumCtxLights( +jint JNICALL Java_javax_media_j3d_NativePipeline_getNumCtxLights( JNIEnv *env, jobject obj, jlong ctxInfo) @@ -1362,112 +1280,8 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_getNumCtxLights( return((jint)nlights); } - - JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_composite( - JNIEnv *env, - jobject obj, - jlong ctxInfo, - jint px, - jint py, - jint minX, - jint minY, - jint maxX, - jint maxY, - jint rasWidth, - jbyteArray imageYdown, - jint winWidth, - jint winHeight) -{ - GLenum gltype; - JNIEnv table; - jbyte *byteData; - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - jlong ctx = ctxProperties->context; - - table = *env; - -#ifdef VERBOSE - fprintf(stderr, "Canvas3D.composite()\n"); -#endif - /* Temporarily disable fragment and most 3D operations */ - /* XXXX: the GL_TEXTURE_BIT may not be necessary here */ - glPushAttrib(GL_ENABLE_BIT|GL_TEXTURE_BIT|GL_DEPTH_BUFFER_BIT); - disableAttribFor2D(ctxProperties); - - glEnable(GL_BLEND); - glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - /* loaded identity modelview and projection matrix */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0, (double)winWidth, 0.0, (double)winHeight, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - /* start from upper left corner */ - glRasterPos2i(px + minX, winHeight-(py + minY)); - - glPixelZoom(1.0, -1.0); - - byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, - imageYdown, - NULL); - /* if abgr_ext is supported then the data will be in that format */ - if (ctxProperties->abgr_ext) { - gltype = GL_ABGR_EXT; - } else { - gltype = GL_RGBA; - } - - /* - * set the actual width of data which is the width of the canvas - * because what needs to be drawn may be smaller than the canvas - */ - glPixelStorei(GL_UNPACK_ROW_LENGTH, rasWidth); - - /* - * we only need to skip pixels if width of the area to draw is smaller - * than the width of the raster - */ - - /* - * skip this many rows in the data because the size of what - * needs to be drawn may be smaller than the canvas - */ - glPixelStorei(GL_UNPACK_SKIP_ROWS, minY); - /* - * skip this many pixels in the data before drawing because - * the size of what needs to be drawn may be smaller than the - * canvas - */ - glPixelStorei(GL_UNPACK_SKIP_PIXELS, minX); - - - glDrawPixels(maxX - minX, maxY - minY, - gltype, GL_UNSIGNED_BYTE, byteData); - - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - - glMatrixMode(GL_PROJECTION); - - glLoadIdentity(); - - (*(table->ReleasePrimitiveArrayCritical))(env, imageYdown, byteData, 0); - - /* Java 3D always clears the Z-buffer */ - glDepthMask(GL_TRUE); - glClear(GL_DEPTH_BUFFER_BIT); - - glPopAttrib(); -} - - -JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_initTexturemapping( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_initTexturemapping( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1505,7 +1319,7 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_initTexturemapping( JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( +void JNICALL Java_javax_media_j3d_NativePipeline_texturemapping( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1545,7 +1359,6 @@ void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( /* glGetIntegerv(GL_TEXTURE_BINDING_2D,&binding); */ glDepthMask(GL_FALSE); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, objectId); /* set up texture parameter */ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -1581,10 +1394,10 @@ void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( gltype = GL_ABGR_EXT; } else { switch (format) { - case FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_RGBA: gltype = GL_RGBA; break; - case FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGB: gltype = GL_RGB; break; } @@ -1637,522 +1450,277 @@ void JNICALL Java_javax_media_j3d_Canvas3D_texturemapping( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_clear( - JNIEnv *env, - jobject obj, - jlong ctxInfo, - jfloat r, - jfloat g, - jfloat b, - jint winWidth, - jint winHeight, - jobject pa2d, - jint imageScaleMode, - jbyteArray pixels_obj) - -{ - jclass pa2d_class; - jfieldID format_field, width_field, height_field; - int format, width, height; - GLubyte * pixels; - JNIEnv table; - GLenum gltype; - float xzoom, yzoom, zoom; - float rasterX, rasterY; - int repeatX, repeatY, i, j; - int row_length, skip_pixels, skip_rows, subwidth, subheight; +void JNICALL Java_javax_media_j3d_NativePipeline_clear(JNIEnv *env, + jobject obj, + jlong ctxInfo, + jfloat r, + jfloat g, + jfloat b) +{ GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - jlong ctx = ctxProperties->context; - table = *env; - -#ifdef VERBOSE - fprintf(stderr, "Canvas3D.clear()\n"); -#endif + jlong ctx = ctxProperties->context; - if(!pa2d) { - glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_COLOR_BUFFER_BIT); - } - else { - /* Do a cool image blit */ - pa2d_class = (jclass) (*(table->GetObjectClass))(env, pa2d); - format_field = (jfieldID) (*(table->GetFieldID))(env, pa2d_class, - "storedYdownFormat", "I"); - width_field = (jfieldID) (*(table->GetFieldID))(env, pa2d_class, - "width", "I"); - height_field = (jfieldID) (*(table->GetFieldID))(env, pa2d_class, - "height", "I"); - - format = (int) (*(table->GetIntField))(env, pa2d, format_field); - width = (int) (*(table->GetIntField))(env, pa2d, width_field); - height = (int) (*(table->GetIntField))(env, pa2d, height_field); - - pixels = (GLubyte *) (*(table->GetPrimitiveArrayCritical))(env, - pixels_obj, NULL); - - /* Temporarily disable fragment and most 3D operations */ - /* XXXX: the GL_TEXTURE_BIT may not be necessary */ - glPushAttrib(GL_ENABLE_BIT|GL_TEXTURE_BIT); - disableAttribFor2D(ctxProperties); - - /* loaded identity modelview and projection matrix */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - switch (format) { - case FORMAT_BYTE_RGBA: - gltype = GL_RGBA; - break; - case FORMAT_BYTE_RGB: - gltype = GL_RGB; - break; - - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - gltype = GL_ABGR_EXT; - } - break; - - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - gltype = ctxProperties->bgr_ext_enum ; - } - break; - - case FORMAT_BYTE_LA: - gltype = GL_LUMINANCE_ALPHA; - break; - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: - default: - throwAssert(env, "illegal format"); - break; - } - - /* start from upper left corner */ - glRasterPos3f(-1.0, 1.0, 0.0); - - /* setup the pixel zoom */ - xzoom = (float)winWidth/width; - yzoom = (float)winHeight/height; - switch(imageScaleMode){ - case javax_media_j3d_Background_SCALE_NONE: - if(xzoom > 1.0f || yzoom > 1.0f) - { - /* else don't need to clear the background with background color */ - glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_COLOR_BUFFER_BIT); - } - glPixelZoom(1.0, -1.0); - glDrawPixels(width, height, gltype, GL_UNSIGNED_BYTE, - pixels); - - break; - case javax_media_j3d_Background_SCALE_FIT_MIN: - if(xzoom != yzoom ) { - glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_COLOR_BUFFER_BIT); - } - zoom = xzoom < yzoom? xzoom:yzoom; - glPixelZoom(zoom, -zoom); - glDrawPixels(width, height, gltype, GL_UNSIGNED_BYTE, - pixels); - break; - case javax_media_j3d_Background_SCALE_FIT_MAX: - zoom = xzoom > yzoom? xzoom:yzoom; - glPixelZoom(zoom, -zoom); - glDrawPixels(width, height, gltype, GL_UNSIGNED_BYTE, - pixels); - - break; - case javax_media_j3d_Background_SCALE_FIT_ALL: - glPixelZoom(xzoom, -yzoom); - glDrawPixels(width, height, gltype, GL_UNSIGNED_BYTE, - pixels); - break; - case javax_media_j3d_Background_SCALE_REPEAT: - glPixelZoom(1.0, -1.0); - /* get those raster positions */ - repeatX = winWidth/width; - if(repeatX * width < winWidth) - repeatX++; - repeatY = winHeight/height; - if(repeatY * height < winHeight) - repeatY++; - for(i = 0; i < repeatX; i++) - for(j = 0; j < repeatY; j++) { - rasterX = -1.0f + (float)width/winWidth * i * 2; - rasterY = 1.0f - (float)height/winHeight * j * 2; - glRasterPos3f(rasterX, rasterY, 0.0); - glDrawPixels(width, height, gltype, GL_UNSIGNED_BYTE, - pixels); - } - break; - - case javax_media_j3d_Background_SCALE_NONE_CENTER: - if(xzoom > 1.0f || yzoom > 1.0f){ - glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_COLOR_BUFFER_BIT); - } - if(xzoom >= 1.0f){ - rasterX = -(float)width/winWidth; - subwidth = width; - } - else { - rasterX = -1.0; - row_length = width; - glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); - skip_pixels = (width-winWidth)/2; - glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); - subwidth = winWidth; - } - if(yzoom >= 1.0f){ - rasterY = (float)height/winHeight; - subheight = height; - } - else { - rasterY = 1.0f; - skip_rows = (height-winHeight)/2; - glPixelStorei(GL_UNPACK_SKIP_ROWS, skip_rows); - subheight = winHeight; - } - glRasterPos3f(rasterX, rasterY, 0.0); - glPixelZoom(1.0, -1.0); - glDrawPixels(subwidth, subheight, gltype, GL_UNSIGNED_BYTE, - pixels); - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - break; - } +#ifdef VERBOSE + fprintf(stderr, "Canvas3D.clear()\n"); +#endif + + glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); + glClear(GL_COLOR_BUFFER_BIT); - /* Restore attributes */ - glPopAttrib(); - - (*(table->ReleasePrimitiveArrayCritical))(env, pixels_obj, - (jbyte *)pixels, 0); - } /* Java 3D always clears the Z-buffer */ glPushAttrib(GL_DEPTH_BUFFER_BIT); glDepthMask(GL_TRUE); glClear(GL_DEPTH_BUFFER_BIT); glPopAttrib(); + +#if 0 + + /* Java 3D always clears the Z-buffer */ + glPushAttrib(GL_DEPTH_BUFFER_BIT); + glDepthMask(GL_TRUE); + glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); + glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); + glPopAttrib(); +#endif + + } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_textureclear(JNIEnv *env, +void JNICALL Java_javax_media_j3d_NativePipeline_textureFillBackground(JNIEnv *env, jobject obj, jlong ctxInfo, - jint maxX, - jint maxY, - jfloat r, - jfloat g, - jfloat b, - jint winWidth, - jint winHeight, - jint objectId, - jint imageScaleMode, - jobject pa2d, - jboolean update) + jfloat texMinU, + jfloat texMaxU, + jfloat texMinV, + jfloat texMaxV, + jfloat mapMinX, + jfloat mapMaxX, + jfloat mapMinY, + jfloat mapMaxY) { - jclass pa2d_class; - jfieldID pixels_field, format_field, width_field, height_field; - jbyteArray pixels_obj; - int format, width, height; - GLubyte * pixels; JNIEnv table; - GLenum gltype; - GLfloat texMinU, texMinV, texMaxU, texMaxV, adjustV; - GLfloat mapMinX, mapMinY, mapMaxX, mapMaxY; - GLfloat halfWidth, halfHeight; - float xzoom, yzoom, zoom; - int i, j; GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; - table = *env; - - /* update = 1; */ + table = *env; #ifdef VERBOSE - fprintf(stderr, "Canvas3D.textureclear()\n"); -#endif - if(!pa2d){ - glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_COLOR_BUFFER_BIT); - } - /* glPushAttrib(GL_DEPTH_BUFFER_BIT); */ - if (pa2d) { - /* Do a cool image blit */ - pa2d_class = (jclass) (*(table->GetObjectClass))(env, pa2d); - - pixels_field = (jfieldID) (*(table->GetFieldID))(env, pa2d_class, - "imageYup", "[B"); - format_field = (jfieldID) (*(table->GetFieldID))(env, pa2d_class, - "storedYupFormat", "I"); - pixels_obj = (jbyteArray)(*(table->GetObjectField))(env, pa2d, - pixels_field); - - width_field = (jfieldID) (*(table->GetFieldID))(env, pa2d_class, - "width", "I"); - height_field = (jfieldID) (*(table->GetFieldID))(env, pa2d_class, - "height", "I"); + fprintf(stderr, "Canvas3D.textureFillBackground()\n"); +#endif + /* Temporarily disable fragment and most 3D operations */ + glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_POLYGON_BIT); - format = (int) (*(table->GetIntField))(env, pa2d, format_field); - width = (int) (*(table->GetIntField))(env, pa2d, width_field); - height = (int) (*(table->GetIntField))(env, pa2d, height_field); - pixels = (GLubyte *) (*(table->GetPrimitiveArrayCritical))(env, - pixels_obj, NULL); + disableAttribFor2D(ctxProperties); + glDepthMask(GL_FALSE); + glEnable(GL_TEXTURE_2D); -#ifdef VERBOSE - fprintf(stderr, "width = %d height = %d \n", width, height); -#endif - - /* Temporarily disable fragment and most 3D operations */ - glPushAttrib(GL_ENABLE_BIT|GL_TEXTURE_BIT|GL_POLYGON_BIT); - disableAttribFor2D(ctxProperties); + /* reset the polygon mode */ + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - Java_javax_media_j3d_Canvas3D_resetTexCoordGeneration(env, obj, ctxInfo); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glEnable(GL_TEXTURE_2D); + /* loaded identity modelview and projection matrix */ + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glMatrixMode(GL_TEXTURE); + glPushMatrix(); + glLoadIdentity(); + +#ifdef VERBOSE + printf("(texMinU,texMinV,texMaxU,texMaxV) = (%3.2f,%3.2f,%3.2f,%3.2f)\n", + texMinU,texMinV,texMaxU,texMaxV); + printf("(mapMinX,mapMinY,mapMaxX,mapMaxY) = (%3.2f,%3.2f,%3.2f,%3.2f)\n", + mapMinX,mapMinY,mapMaxX,mapMaxY); +#endif + + glBegin(GL_QUADS); + glTexCoord2f((float) texMinU, (float) texMinV); + glVertex2f((float) mapMinX, (float) mapMinY); + glTexCoord2f((float) texMaxU, (float) texMinV); + glVertex2f((float) mapMaxX, (float) mapMinY); + glTexCoord2f((float) texMaxU, (float) texMaxV); + glVertex2f((float) mapMaxX, (float) mapMaxY); + glTexCoord2f((float) texMinU, (float) texMaxV); + glVertex2f((float) mapMinX, (float) mapMaxY); + glEnd(); + + /* Restore texture Matrix transform */ + glPopMatrix(); + + glMatrixMode(GL_MODELVIEW); + /* Restore attributes */ + glPopAttrib(); +} + +JNIEXPORT +void JNICALL Java_javax_media_j3d_NativePipeline_textureFillRaster(JNIEnv *env, + jobject obj, + jlong ctxInfo, + jfloat texMinU, + jfloat texMaxU, + jfloat texMinV, + jfloat texMaxV, + jfloat mapMinX, + jfloat mapMaxX, + jfloat mapMinY, + jfloat mapMaxY, + jfloat mapZ, + jfloat alpha) +{ + JNIEnv table; + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; + jlong ctx = ctxProperties->context; + + table = *env; + +#ifdef VERBOSE + fprintf(stderr, "Canvas3D.textureFillRaster()\n"); +#endif + /* Temporarily disable fragment and most 3D operations */ + glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_POLYGON_BIT | + GL_CURRENT_BIT); + + disableAttribForRaster(ctxProperties); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glColor4f(1.0f, 1.0f, 1.0f, (float) alpha); - /* reset the polygon mode */ - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + /* reset the polygon mode */ + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - glDepthMask(GL_FALSE); - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glBindTexture(GL_TEXTURE_2D, objectId); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - /* set up texture parameter */ - if(update){ - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } + /* loaded identity modelview and projection matrix */ + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glPushMatrix(); + glLoadIdentity(); + glOrtho(0.0, 1.0, 0.0, 1.0, 0.0, 1.0); + #ifdef VERBOSE - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); -#endif - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - - - if(update){ - switch (format) { - case FORMAT_BYTE_RGBA: - gltype = GL_RGBA; -#ifdef VERBOSE - fprintf(stderr, "FORMAT_BYTE_RGBA\n"); + printf("(texMinU,texMinV,texMaxU,texMaxV) = (%3.2f,%3.2f,%3.2f,%3.2f)\n", + texMinU,texMinV,texMaxU,texMaxV); + printf("(mapMinX,mapMinY,mapMaxX,mapMaxY) = (%3.2f,%3.2f,%3.2f,%3.2f)\n", + mapMinX,mapMinY,mapMaxX,mapMaxY); #endif - break; - case FORMAT_BYTE_RGB: - gltype = GL_RGB; -#ifdef VERBOSE - fprintf(stderr, "FORMAT_BYTE_RGB\n"); + + glBegin(GL_QUADS); + + glTexCoord2f((float) texMinU, (float) texMinV); + glVertex3f((float) mapMinX, (float) mapMinY, (float) mapZ); + glTexCoord2f((float) texMaxU, (float) texMinV); + glVertex3f((float) mapMaxX, (float) mapMinY, (float) mapZ); + glTexCoord2f((float) texMaxU, (float) texMaxV); + glVertex3f((float) mapMaxX, (float) mapMaxY, (float) mapZ); + glTexCoord2f((float) texMinU, (float) texMaxV); + glVertex3f((float) mapMinX, (float) mapMaxY, (float) mapZ); + + glEnd(); + + /* Restore matrices */ + glPopMatrix(); + glMatrixMode(GL_MODELVIEW); + glPopMatrix(); + /* Restore attributes */ + glPopAttrib(); +} + +JNIEXPORT +void JNICALL Java_javax_media_j3d_NativePipeline_executeRasterDepth(JNIEnv *env, + jobject obj, + jlong ctxInfo, + jfloat posX, + jfloat posY, + jfloat posZ, + jint srcOffsetX, + jint srcOffsetY, + jint rasterWidth, + jint rasterHeight, + jint depthWidth, + jint depthHeight, + jint depthFormat, + jobject depthData) +{ + GLint drawBuf; + void *depthObjPtr; + + JNIEnv table; + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; + jlong ctx = ctxProperties->context; + + table = *env; + +#ifdef VERBOSE + fprintf(stderr, "Canvas3D.executeRasterDepth()\n"); #endif - break; - - /* GL_ABGR_EXT */ - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - gltype = GL_ABGR_EXT; - } - break; - - /* GL_BGR_EXT or GL_BGR */ - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - gltype = ctxProperties->bgr_ext_enum; - } - break; - - case FORMAT_BYTE_LA: - gltype = GL_LUMINANCE_ALPHA; - break; - - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: - default: - throwAssert(env, "illegal format"); - break; - } - - /* texture map here! */ - glTexImage2D(GL_TEXTURE_2D, 0, gltype, width, - height, 0, gltype, GL_UNSIGNED_BYTE, - pixels); - } - /* loaded identity modelview and projection matrix */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glMatrixMode(GL_TEXTURE); - glPushMatrix(); - glLoadIdentity(); - - xzoom = (float)winWidth/maxX; - yzoom = (float)winHeight/maxY; - switch(imageScaleMode) { - case javax_media_j3d_Background_SCALE_NONE: - if(xzoom > 1.0f || yzoom > 1.0f){ - glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_COLOR_BUFFER_BIT); - } - texMinU = 0.0f; - texMinV = 0.0f; - texMaxU = 1.0f; - texMaxV = 1.0f; - halfWidth = (GLfloat)winWidth/2.0f; - halfHeight = (GLfloat)winHeight/2.0f; - mapMinX = (float) ((0 - halfWidth)/halfWidth); - mapMinY = (float) ((0 - halfHeight)/halfHeight); - mapMaxX = (float) ((maxX - halfWidth)/halfWidth); - mapMaxY = (float) ((maxY - halfHeight)/halfHeight); - adjustV = ((float)winHeight - (float)maxY)/halfHeight; - mapMinY += adjustV; - mapMaxY += adjustV; - break; - case javax_media_j3d_Background_SCALE_FIT_MIN: - if(xzoom != yzoom){ - glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_COLOR_BUFFER_BIT); - } + glRasterPos3f(posX, posY, posZ); - zoom = xzoom < yzoom? xzoom: yzoom; - texMinU = 0.0f; - texMinV = 0.0f; - texMaxU = 1.0f; - texMaxV = 1.0f; - mapMinX = -1.0f; - mapMaxY = 1.0f; - if(xzoom < yzoom){ - mapMaxX = 1.0f; - mapMinY = -1.0f + 2.0f * ( 1.0f - zoom * (float)maxY/(float) winHeight ); - } else { - mapMaxX = -1.0f + zoom * (float)maxX/winWidth * 2; - mapMinY = -1.0f; - } - break; - case javax_media_j3d_Background_SCALE_FIT_MAX: - zoom = xzoom > yzoom? xzoom: yzoom; - /*fprintf(stderr, "zoom: %f, xzoom: %f, yzoom: %f\n", zoom, xzoom, yzoom);*/ - mapMinX = -1.0f; - mapMinY = -1.0f; - mapMaxX = 1.0f; - mapMaxY = 1.0f; - if(xzoom < yzoom) { - texMinU = 0.0f; - texMinV = 0.0f; - texMaxU = (float)winWidth/maxX/zoom; - texMaxV = 1.0f; - } else { - texMinU = 0.0f; - texMinV = 1.0f - (float)winHeight/maxY/zoom; - texMaxU = 1.0f; - texMaxV = 1.0f; + glGetIntegerv(GL_DRAW_BUFFER, &drawBuf); + /* disable draw buffer */ + glDrawBuffer(GL_NONE); + + /* + * raster position is upper left corner, default for Java3D + * ImageComponent currently has the data reverse in Y + */ + glPixelZoom(1.0, -1.0); + glPixelStorei(GL_UNPACK_ROW_LENGTH, depthWidth); + if (srcOffsetX >= 0) { + glPixelStorei(GL_UNPACK_SKIP_PIXELS, srcOffsetX); + if (srcOffsetX + rasterWidth > depthWidth) { + rasterWidth = depthWidth - srcOffsetX; } - break; - case javax_media_j3d_Background_SCALE_FIT_ALL: - texMinU = 0.0f; - texMinV = 0.0f; - texMaxU = 1.0f; - texMaxV = 1.0f; - mapMinX = -1.0f; - mapMinY = -1.0f; - mapMaxX = 1.0f; - mapMaxY = 1.0f; - break; - case javax_media_j3d_Background_SCALE_REPEAT: - /* glScalef(1.0f, -1.0f, 1.0f); */ - i = winWidth/width; - j = winHeight/height; - texMinU = 0.0f; - texMinV = (float)(j + 1) - yzoom; - texMaxU = xzoom; - texMaxV = (float)(j + 1); - mapMinX = -1.0f; - mapMinY = -1.0f; - mapMaxX = 1.0f; - mapMaxY = 1.0f; - break; - case javax_media_j3d_Background_SCALE_NONE_CENTER: - if(xzoom > 1.0f || yzoom > 1.0f){ - glClearColor((float)r, (float)g, (float)b, ctxProperties->alphaClearValue); - glClear(GL_COLOR_BUFFER_BIT); + } else { + rasterWidth += srcOffsetX; + if (rasterWidth > depthWidth) { + rasterWidth = depthWidth; } - if(xzoom >= 1.0f){ - texMinU = 0.0f; - texMaxU = 1.0f; - mapMinX = -(float)maxX/winWidth; - mapMaxX = (float)maxX/winWidth; - } else { - texMinU = 0.5f - (float)winWidth/maxX/2; - texMaxU = 0.5f + (float)winWidth/maxX/2; - mapMinX = -1.0f; - mapMaxX = 1.0f; + } + if (srcOffsetY >= 0) { + glPixelStorei(GL_UNPACK_SKIP_ROWS, srcOffsetY); + if (srcOffsetY + rasterHeight > depthHeight) { + rasterHeight = depthHeight - srcOffsetY; } - if(yzoom >= 1.0f) { - texMinV = 0.0f; - texMaxV = 1.0f; - mapMinY = -(float)maxY/winHeight; - mapMaxY = (float)maxY/winHeight; - }else { - texMinV = 0.5f - (float)winHeight/maxY/2; - texMaxV = 0.5f + (float)winHeight/maxY/2; - mapMinY = -1.0f; - mapMaxY = 1.0f; + } else { + rasterHeight += srcOffsetY; + if (rasterHeight > depthHeight) { + rasterHeight = depthHeight; } - break; } -#ifdef VERBOSE - printf("adjustV = %3.2f\n",adjustV); - printf("(texMinU,texMinV,texMaxU,texMaxV) = (%3.2f,%3.2f,%3.2f,%3.2f)\n", - texMinU,texMinV,texMaxU,texMaxV); - printf("(mapMinX,mapMinY,mapMaxX,mapMaxY) = (%3.2f,%3.2f,%3.2f,%3.2f)\n", - mapMinX,mapMinY,mapMaxX,mapMaxY); -#endif + + depthObjPtr = + (void *)(*(table->GetPrimitiveArrayCritical))(env, (jarray)depthData, NULL); + + if (depthFormat == javax_media_j3d_DepthComponentRetained_DEPTH_COMPONENT_TYPE_INT) { + glDrawPixels(rasterWidth, rasterHeight, GL_DEPTH_COMPONENT, + GL_UNSIGNED_INT, depthObjPtr); + } else { /* javax_media_j3d_DepthComponentRetained_DEPTH_COMPONENT_TYPE_FLOAT */ + glDrawPixels(rasterWidth, rasterHeight, GL_DEPTH_COMPONENT, + GL_FLOAT, depthObjPtr); + } - glBegin(GL_QUADS); -#ifdef VERBOSE - /* glTexCoord2f(0.2, 0.2); glVertex2f(0.0,0.0); */ - /* glTexCoord2f(0.4, 0.2); glVertex2f(0.2,0.0); */ - /* glTexCoord2f(0.4, 0.4); glVertex2f(0.2,0.2); */ - /* glTexCoord2f(0.2, 0.4); glVertex2f(0.0,0.2); */ - glColor3f(1.0, 0.0, 0.0); -#endif - glTexCoord2f(texMinU, texMinV); glVertex2f(mapMinX,mapMinY); - glTexCoord2f(texMaxU, texMinV); glVertex2f(mapMaxX,mapMinY); - glTexCoord2f(texMaxU, texMaxV); glVertex2f(mapMaxX,mapMaxY); - glTexCoord2f(texMinU, texMaxV); glVertex2f(mapMinX,mapMaxY); - glEnd(); - - /* Restore texture Matrix transform */ - glPopMatrix(); + (*(table->ReleasePrimitiveArrayCritical))(env, depthData, depthObjPtr, 0); + + + /* re-enable draw buffer */ + glDrawBuffer(drawBuf); - glMatrixMode(GL_MODELVIEW); - /* Restore attributes */ - glPopAttrib(); - (*(table->ReleasePrimitiveArrayCritical))(env, pixels_obj, - (jbyte *)pixels, 0); - } - - /* Java 3D always clears the Z-buffer */ - glPushAttrib(GL_DEPTH_BUFFER_BIT); - glDepthMask(GL_TRUE); - glClear(GL_DEPTH_BUFFER_BIT); - glPopAttrib(); - + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); + } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setRenderMode( +void JNICALL Java_javax_media_j3d_NativePipeline_setRenderMode( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2221,7 +1789,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setRenderMode( JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_clearAccum( +void JNICALL Java_javax_media_j3d_NativePipeline_clearAccum( JNIEnv *env, jobject obj, jlong ctxInfo) @@ -2232,7 +1800,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_clearAccum( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_accum( +void JNICALL Java_javax_media_j3d_NativePipeline_accum( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2248,7 +1816,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_accum( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_accumReturn( +void JNICALL Java_javax_media_j3d_NativePipeline_accumReturn( JNIEnv *env, jobject obj, jlong ctxInfo) @@ -2259,7 +1827,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_accumReturn( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setDepthBufferWriteEnable( +void JNICALL Java_javax_media_j3d_NativePipeline_setDepthBufferWriteEnable( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2274,23 +1842,24 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setDepthBufferWriteEnable( JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers( +jint JNICALL Java_javax_media_j3d_NativePipeline_swapBuffers( JNIEnv *env, jobject obj, + jobject cv, jlong ctxInfo, jlong display, - jint win) + jlong window) { #if defined(UNIX) - glXSwapBuffers((Display *)display, (Window)win); + glXSwapBuffers((Display *)display, (Window)window); #endif #ifdef WIN32 HDC hdc; - hdc = (HDC) win; + hdc = (HDC) window; SwapBuffers(hdc); #endif @@ -2306,7 +1875,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_swapBuffers( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_syncRender( +void JNICALL Java_javax_media_j3d_NativePipeline_syncRender( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2321,7 +1890,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_syncRender( JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_newDisplayList( +void JNICALL Java_javax_media_j3d_NativePipeline_newDisplayList( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2336,7 +1905,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_newDisplayList( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_endDisplayList( +void JNICALL Java_javax_media_j3d_NativePipeline_endDisplayList( JNIEnv *env, jobject obj, jlong ctxInfo) @@ -2346,7 +1915,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_endDisplayList( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_setGlobalAlpha( +void JNICALL Java_javax_media_j3d_NativePipeline_setGlobalAlpha( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2363,23 +1932,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_setGlobalAlpha( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_disableGlobalAlpha( - JNIEnv *env, - jobject obj, - jlong ctxInfo) -{ - - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - jlong ctx = ctxProperties->context; - - /* GL_GLOBAL_ALPHA_SUN */ - if(ctxProperties->global_alpha_sun){ - glDisable(GL_GLOBAL_ALPHA_SUN); - } -} - -JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_callDisplayList( +void JNICALL Java_javax_media_j3d_NativePipeline_callDisplayList( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2402,22 +1955,23 @@ void JNICALL Java_javax_media_j3d_Canvas3D_callDisplayList( return; } - /* resale_normal_ext */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + /* Set normalization if non-uniform scale */ + if (isNonUniformScale) { glEnable(GL_NORMALIZE); } glCallList(id); - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + /* Turn normalization back off */ + if (isNonUniformScale) { glDisable(GL_NORMALIZE); } } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_freeDisplayList( +void JNICALL Java_javax_media_j3d_NativePipeline_freeDisplayList( JNIEnv *env, - jclass cl, + jobject obj, jlong ctxInfo, jint id) { @@ -2431,9 +1985,9 @@ void JNICALL Java_javax_media_j3d_Canvas3D_freeDisplayList( } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_freeTexture( +void JNICALL Java_javax_media_j3d_NativePipeline_freeTexture( JNIEnv *env, - jclass cl, + jobject obj, jlong ctxInfo, jint id) { @@ -2455,15 +2009,14 @@ void JNICALL Java_javax_media_j3d_Canvas3D_freeTexture( int getTextureColorTableSize( JNIEnv *env, jobject obj, - jlong ctxInfo, - char *extensionStr, - int minorVersion) + GraphicsContextPropertiesInfo *ctxInfo, + char *extensionStr) { - GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; + GraphicsContextPropertiesInfo* ctxProperties = ctxInfo; int size; - - if(minorVersion >= 2 && isExtensionSupported(extensionStr, "GL_ARB_imaging")){ - + + if (isExtensionSupported(extensionStr, "GL_ARB_imaging")) { + #ifdef WIN32 ctxProperties->glColorTable = (MYPFNGLCOLORTABLEPROC)wglGetProcAddress("glColorTable"); ctxProperties->glGetColorTableParameteriv = @@ -2477,6 +2030,7 @@ int getTextureColorTableSize( #endif } else if(isExtensionSupported(extensionStr, "GL_SGI_color_table")) { + #ifdef WIN32 ctxProperties->glColorTable = (MYPFNGLCOLORTABLEPROC)wglGetProcAddress("glColorTableSGI"); ctxProperties->glGetColorTableParameteriv = @@ -2488,16 +2042,16 @@ int getTextureColorTableSize( ctxProperties->glGetColorTableParameteriv = (MYPFNGLGETCOLORTABLEPARAMETERIVPROC)dlsym(RTLD_DEFAULT, "glGetColorTableParameterivSGI"); #endif - + } else { return 0; } if ((ctxProperties->glColorTable == NULL) || - (ctxProperties->glGetColorTableParameteriv == NULL)) { + (ctxProperties->glGetColorTableParameteriv == NULL)) { return 0; } - + ctxProperties->glColorTable(GL_PROXY_TEXTURE_COLOR_TABLE_SGI, GL_RGBA, 256, GL_RGB, GL_INT, NULL); ctxProperties->glGetColorTableParameteriv(GL_PROXY_TEXTURE_COLOR_TABLE_SGI, @@ -2505,62 +2059,13 @@ int getTextureColorTableSize( return size; } -/* For dvr support */ -JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_videoResize( - JNIEnv *env, - jobject obj, - jlong ctxInfo, - jlong display, - jint win, - jfloat dvrFactor) -{ -#if defined(UNIX) - - GraphicsContextPropertiesInfo* ctxProperties = (GraphicsContextPropertiesInfo* )ctxInfo; - - /* Not need to do ext. supported checking. This check is done in java. */ - - /* fprintf(stderr, "Canvas3D.c -- glXVideoResize -- %d %f\n", win, dvrFactor); */ - ctxProperties->glXVideoResizeSUN((Display *)display, (Window)win, (float) dvrFactor); -#endif - -} - JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_videoResizeCompensation( - JNIEnv *env, - jobject obj, - jlong ctxInfo, - jboolean enable) -{ - -#if defined(UNIX) - GraphicsContextPropertiesInfo *ctxProperties = - (GraphicsContextPropertiesInfo *)ctxInfo; - - if (ctxProperties->videoResizeAvailable) { - if(enable == JNI_TRUE) { - /* fprintf(stderr, "videoResizeCompensation - glEnable"); */ - glEnable(GL_VIDEO_RESIZE_COMPENSATION_SUN); - } - else { - /* fprintf(stderr, "videoResizeCompensation - glDisable"); */ - glDisable(GL_VIDEO_RESIZE_COMPENSATION_SUN); - } - } - -#endif - -} - -JNIEXPORT -jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( +jlong JNICALL Java_javax_media_j3d_NativePipeline_createOffScreenBuffer( JNIEnv *env, jobject obj, + jobject cv, jlong ctxInfo, jlong display, - jint vid, jlong fbConfigListPtr, jint width, jint height) @@ -2586,7 +2091,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( */ - + /* Query DRAWABLE_TYPE. Will use Pbuffer if fbConfig support it, else will try for Pixmap. If neither one exists, flag error message and return None */ @@ -2616,7 +2121,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( fprintf(stderr, "Java 3D ERROR : glXCreateGLXPbuffer() returns None\n"); } - return pbuff; + return (jlong)pbuff; } else if((val & GLX_PIXMAP_BIT) != 0) { Pixmap pixmap; @@ -2666,11 +2171,11 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( } /* fprintf(stderr, "glxpixmap %d\n",(int) glxpixmap); */ - return glxpixmap; + return (jlong)glxpixmap; } else { fprintf(stderr, "Java 3D ERROR : FBConfig doesn't support pbuffer or pixmap returns None\n"); - return None; + return (jlong)None; } @@ -2710,7 +2215,7 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( (int) display, pFormatInfoPtr->offScreenPFormat, width, height); */ - cv_class = (jclass) (*(table->GetObjectClass))(env, obj); + cv_class = (jclass) (*(table->GetObjectClass))(env, cv); offScreenBuffer_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "offScreenBufferInfo", "J"); @@ -2801,9 +2306,9 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( offScreenBufferInfo->isPbuffer = GL_TRUE; offScreenBufferInfo->hpbuf = hpbuf; - (*(table->SetLongField))(env, obj, offScreenBuffer_field, (jlong)offScreenBufferInfo); + (*(table->SetLongField))(env, cv, offScreenBuffer_field, (jlong)offScreenBufferInfo); - return (jint) hpbufdc; + return (jlong) hpbufdc; } /* fprintf(stderr, "***** Use Bitmap for offscreen ******\n"); */ @@ -2856,21 +2361,23 @@ jint JNICALL Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( offScreenBufferInfo->isPbuffer = GL_FALSE; offScreenBufferInfo->hpbuf = 0; - (*(table->SetLongField))(env, obj, offScreenBuffer_field, (jlong)offScreenBufferInfo); + (*(table->SetLongField))(env, cv, offScreenBuffer_field, (jlong)offScreenBufferInfo); + + return ((jlong)bitmapHdc); - return ((jint)bitmapHdc); - #endif /* WIN32 */ } + JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_destroyOffScreenBuffer( JNIEnv *env, jobject obj, + jobject cv, jlong ctxInfo, jlong display, jlong fbConfigListPtr, - jint window) + jlong window) { jclass cv_class; jfieldID offScreenBuffer_field; @@ -2900,12 +2407,12 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer( OffScreenBufferInfo *offScreenBufferInfo = NULL; HDC hpbufdc = (HDC) window; - cv_class = (jclass) (*(table->GetObjectClass))(env, obj); + cv_class = (jclass) (*(table->GetObjectClass))(env, cv); offScreenBuffer_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, "offScreenBufferInfo", "J"); offScreenBufferInfo = - (OffScreenBufferInfo *) (*(table->GetLongField))(env, obj, offScreenBuffer_field); + (OffScreenBufferInfo *) (*(table->GetLongField))(env, cv, offScreenBuffer_field); /* fprintf(stderr,"Canvas3D_destroyOffScreenBuffer : offScreenBufferInfo 0x%x\n", @@ -2935,81 +2442,131 @@ void JNICALL Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer( } free(offScreenBufferInfo); - (*(table->SetLongField))(env, obj, offScreenBuffer_field, (jlong)0); + (*(table->SetLongField))(env, cv, offScreenBuffer_field, (jlong)0); #endif /* WIN32 */ } - JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_readOffScreenBuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_readOffScreenBuffer( JNIEnv *env, jobject obj, + jobject cv, jlong ctxInfo, jint format, + jint dataType, + jobject data, jint width, jint height) { JNIEnv table = *env; - jclass cv_class; - jfieldID byteData_field; - jbyteArray byteData_array; - jbyte *byteData; int type; - + void *imageObjPtr; + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; glPixelStorei(GL_PACK_ROW_LENGTH, width); glPixelStorei(GL_PACK_ALIGNMENT, 1); - cv_class = (jclass) (*(table->GetObjectClass))(env, obj); - byteData_field = (jfieldID) (*(table->GetFieldID))(env, cv_class, - "byteBuffer", "[B"); - byteData_array = (jbyteArray)(*(table->GetObjectField))(env, obj, - byteData_field); - byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, - byteData_array, NULL); + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + imageObjPtr = (void *)(*(table->GetPrimitiveArrayCritical))(env, (jarray)data, NULL); + } + else { + imageObjPtr = (void *)(*(table->GetDirectBufferAddress))(env, data); + } - - switch (format) { - case FORMAT_BYTE_RGBA: - type = GL_RGBA; - break; - case FORMAT_BYTE_RGB: - type = GL_RGB; - break; - - /* GL_ABGR_EXT */ - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - type = GL_ABGR_EXT; - } - break; + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_BYTE_BUFFER)) { + switch (format) { + /* GL_BGR */ + case IMAGE_FORMAT_BYTE_BGR: + type = GL_BGR; + break; + case IMAGE_FORMAT_BYTE_RGB: + type = GL_RGB; + break; + /* GL_ABGR_EXT */ + case IMAGE_FORMAT_BYTE_ABGR: + if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ + type = GL_ABGR_EXT; + } + else { + throwAssert(env, "GL_ABGR_EXT format is unsupported"); + return; + } + break; + case IMAGE_FORMAT_BYTE_RGBA: + type = GL_RGBA; + break; + + /* This method only supports 3 and 4 components formats and BYTE types. */ + case IMAGE_FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_INT_BGR: + case IMAGE_FORMAT_INT_RGB: + case IMAGE_FORMAT_INT_ARGB: + default: + throwAssert(env, "illegal format"); + return; + } + + glReadPixels(0, 0, width, height, type, GL_UNSIGNED_BYTE, imageObjPtr); + + } + else if((dataType == IMAGE_DATA_TYPE_INT_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_BUFFER)) { + GLenum intType = GL_UNSIGNED_INT_8_8_8_8; + GLboolean forceAlphaToOne = GL_FALSE; - /* GL_BGR_EXT */ - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - type = ctxProperties->bgr_ext_enum; + switch (format) { + /* GL_BGR */ + case IMAGE_FORMAT_INT_BGR: /* Assume XBGR format */ + type = GL_RGBA; + intType = GL_UNSIGNED_INT_8_8_8_8_REV; + forceAlphaToOne = GL_TRUE; + break; + case IMAGE_FORMAT_INT_RGB: /* Assume XRGB format */ + forceAlphaToOne = GL_TRUE; + /* Fall through to next case */ + case IMAGE_FORMAT_INT_ARGB: + type = GL_BGRA; + intType = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + /* This method only supports 3 and 4 components formats and INT types. */ + case IMAGE_FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_ABGR: + default: + throwAssert(env, "illegal format"); + return; + } + + /* Force Alpha to 1.0 if needed */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 0.0f); + glPixelTransferf(GL_ALPHA_BIAS, 1.0f); } - break; - case FORMAT_BYTE_LA: - type = GL_LUMINANCE_ALPHA; - break; + glReadPixels(0, 0, width, height, type, intType, imageObjPtr); - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: - default: - throwAssert(env, "illegal format"); - break; + /* Restore Alpha scale and bias */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + glPixelTransferf(GL_ALPHA_BIAS, 0.0f); + } + } + else { + throwAssert(env, "illegal image data type"); } - - glReadPixels(0, 0, width, height, type, GL_UNSIGNED_BYTE, byteData); + if((dataType == IMAGE_DATA_TYPE_BYTE_ARRAY) || (dataType == IMAGE_DATA_TYPE_INT_ARRAY)) { + (*(table->ReleasePrimitiveArrayCritical))(env, data, imageObjPtr, 0); + } - (*(table->ReleasePrimitiveArrayCritical))(env, byteData_array, - byteData, 0); } static void @@ -3023,17 +2580,12 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->rendererStr = NULL; ctxInfo->extensionStr = NULL; ctxInfo->versionNumbers[0] = 1; - ctxInfo->versionNumbers[1] = 1; + ctxInfo->versionNumbers[1] = 1; + ctxInfo->gl13 = JNI_FALSE; + ctxInfo->gl20 = JNI_FALSE; - /* both in 1.2 core part and 1.1 extensions */ - ctxInfo->rescale_normal_ext = JNI_FALSE; - ctxInfo->bgr_ext = JNI_FALSE; - ctxInfo->texture3DAvailable = JNI_FALSE; - ctxInfo->seperate_specular_color = JNI_FALSE; - /* 1.2 and GL_ARB_imaging */ ctxInfo->blend_color_ext = JNI_FALSE; - ctxInfo->color_table_ext = JNI_FALSE; ctxInfo->blendFunctionTable[BLEND_ZERO] = GL_ZERO; ctxInfo->blendFunctionTable[BLEND_ONE] = GL_ONE; ctxInfo->blendFunctionTable[BLEND_SRC_ALPHA] = GL_SRC_ALPHA; @@ -3049,9 +2601,9 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->multi_draw_arrays_sun = JNI_FALSE; ctxInfo->compiled_vertex_array_ext = JNI_FALSE; - ctxInfo->videoResizeAvailable = JNI_FALSE; + ctxInfo->texture_clamp_to_border_enum = GL_CLAMP; + ctxInfo->global_alpha_sun = JNI_FALSE; - ctxInfo->constant_data_sun = JNI_FALSE; /* EXT extensions */ ctxInfo->abgr_ext = JNI_FALSE; @@ -3063,11 +2615,9 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) /* by MIK OF CLASSX */ ctxInfo->alphaClearValue = (getJavaBoolEnv(env, "transparentOffScreen") ? 0.0f : 1.0f); - /* ARB extensions */ - ctxInfo->arb_transpose_matrix = JNI_FALSE; - ctxInfo->arb_multitexture = JNI_FALSE; + ctxInfo->multisample = JNI_FALSE; - ctxInfo->arb_multisample = JNI_FALSE; + /* Multitexture support */ ctxInfo->maxTexCoordSets = 1; ctxInfo->maxTextureUnits = 1; ctxInfo->maxTextureImageUnits = 0; @@ -3077,7 +2627,6 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->textureEnvCombineAvailable = JNI_FALSE; ctxInfo->textureCombineDot3Available = JNI_FALSE; ctxInfo->textureCombineSubtractAvailable = JNI_FALSE; - ctxInfo->textureCubeMapAvailable = JNI_FALSE; /* NV extensions */ ctxInfo->textureRegisterCombinersAvailable = JNI_FALSE; @@ -3091,6 +2640,7 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->textureColorTableSize = 0; ctxInfo->textureLodAvailable = JNI_FALSE; ctxInfo->textureLodBiasAvailable = JNI_FALSE; + ctxInfo->textureNonPowerOfTwoAvailable = JNI_FALSE; /* extension mask */ ctxInfo->extMask = 0; @@ -3105,17 +2655,17 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) ctxInfo->glGetColorTableParameteriv = NULL; ctxInfo->glTexImage3DEXT = NULL; ctxInfo->glTexSubImage3DEXT = NULL; - ctxInfo->glClientActiveTextureARB = NULL; + ctxInfo->glClientActiveTexture = NULL; ctxInfo->glMultiDrawArraysEXT = NULL; ctxInfo->glMultiDrawElementsEXT = NULL; ctxInfo->glLockArraysEXT = NULL; ctxInfo->glUnlockArraysEXT = NULL; - ctxInfo->glMultiTexCoord2fvARB = NULL; - ctxInfo->glMultiTexCoord3fvARB = NULL; - ctxInfo->glMultiTexCoord4fvARB = NULL; - ctxInfo->glLoadTransposeMatrixdARB = NULL; - ctxInfo->glMultTransposeMatrixdARB = NULL; - ctxInfo->glActiveTextureARB = NULL; + ctxInfo->glMultiTexCoord2fv = NULL; + ctxInfo->glMultiTexCoord3fv = NULL; + ctxInfo->glMultiTexCoord4fv = NULL; + ctxInfo->glLoadTransposeMatrixd = NULL; + ctxInfo->glMultTransposeMatrixd = NULL; + ctxInfo->glActiveTexture = NULL; ctxInfo->glGlobalAlphaFactorfSUN = NULL; ctxInfo->glCombinerInputNV = NULL; @@ -3148,10 +2698,6 @@ initializeCtxInfo(JNIEnv *env , GraphicsContextPropertiesInfo* ctxInfo) /* Initialize shader info pointers */ ctxInfo->glslCtxInfo = NULL; ctxInfo->cgCtxInfo = NULL; - -#if defined(UNIX) - ctxInfo->glXVideoResizeSUN = NULL; -#endif /* UNIX */ } static void @@ -3231,12 +2777,12 @@ HWND createDummyWindow(const char* szAppName) { #endif JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( +void JNICALL Java_javax_media_j3d_NativePipeline_createQueryContext( JNIEnv *env, jobject obj, + jobject cv, jlong display, - jint window, - jint vid, + jlong window, jlong fbConfigListPtr, jboolean offScreen, jint width, @@ -3247,7 +2793,7 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( JNIEnv table = *env; jlong gctx; int stencilSize=0; - jint newWin; + jlong newWin; int PixelFormatID=0; GraphicsContextPropertiesInfo* ctxInfo = (GraphicsContextPropertiesInfo *)malloc(sizeof(GraphicsContextPropertiesInfo)); @@ -3309,14 +2855,14 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( glWin = XCreateWindow((Display *)display, root, 0, 0, width, height, 0, vinfo->depth, InputOutput, vinfo->visual, win_mask, &win_attrs); - newWin = (jint)glWin; + newWin = (jlong)glWin; } } else if(window == 0 && offScreen){ - newWin = Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( env, obj, 0, - display, window, - fbConfigListPtr, - width, height); + newWin = Java_javax_media_j3d_NativePipeline_createOffScreenBuffer(env, + obj, cv, 0, display, + fbConfigListPtr, + width, height); } else if(window != 0) { newWin = window; @@ -3350,11 +2896,6 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( fprintf(stderr, "Canvas3D_createQueryContext:\n"); fprintf(stderr, "window is 0x%x, offScreen %d\n", window, offScreen); */ - - /* - * vid must be valid PixelFormat returned - * by wglChoosePixelFormat() or wglChoosePixelFormatARB. - */ /* Fix to issue 104 */ if(!offScreen) { @@ -3387,16 +2928,17 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( } else if(window == 0 && offScreen){ /* fprintf(stderr, "CreateQueryContext : window == 0 && offScreen\n"); */ - hdc = (HDC)Java_javax_media_j3d_Canvas3D_createOffScreenBuffer( env, obj, 0, display, - vid, fbConfigListPtr, - width, height); + hdc = (HDC)Java_javax_media_j3d_NativePipeline_createOffScreenBuffer(env, + obj, cv, 0, display, + fbConfigListPtr, + width, height); } else if(window != 0){ /* fprintf(stderr, "CreateQueryContext : window != 0 0x%x\n", window); */ hdc = (HDC) window; } - newWin = (jint)hdc; + newWin = (jlong)hdc; SetPixelFormat(hdc, PixelFormatID, NULL); @@ -3430,18 +2972,18 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( ctxInfo->context = gctx; /* get current context properties */ - if (getPropertiesFromCurrentContext(env, obj, ctxInfo, (jlong) hdc, PixelFormatID, + if (getPropertiesFromCurrentContext(env, cv, ctxInfo, (jlong) hdc, PixelFormatID, fbConfigListPtr, offScreen, glslLibraryAvailable, cgLibraryAvailable)) { /* put the properties to the Java side */ - setupCanvasProperties(env, obj, ctxInfo); + setupCanvasProperties(env, cv, ctxInfo); } /* clear up the context , colormap and window if appropriate */ if(window == 0 && !offScreen){ #if defined(UNIX) - Java_javax_media_j3d_Canvas3D_destroyContext(env, obj, display, newWin, (jlong)ctxInfo); + Java_javax_media_j3d_NativePipeline_destroyContext(env, obj, display, newWin, (jlong)ctxInfo); XDestroyWindow((Display *)display, glWin); XFreeColormap((Display *)display, cmap); #endif /* UNIX */ @@ -3450,33 +2992,33 @@ void JNICALL Java_javax_media_j3d_Canvas3D_createQueryContext( ReleaseDC(hDummyWnd, hdc); /* Destroy context */ /* This will free ctxInfo also */ - Java_javax_media_j3d_Canvas3D_destroyContext(env, obj, display,newWin, (jlong)ctxInfo); + Java_javax_media_j3d_NativePipeline_destroyContext(env, obj, display,newWin, (jlong)ctxInfo); DestroyWindow(hDummyWnd); UnregisterClass(szAppName, (HINSTANCE)NULL); #endif /* WIN32 */ } else if(window == 0 && offScreen) { - Java_javax_media_j3d_Canvas3D_destroyOffScreenBuffer(env, obj, gctx, display, fbConfigListPtr, newWin); - Java_javax_media_j3d_Canvas3D_destroyContext(env, obj, display, newWin, (jlong)ctxInfo); + Java_javax_media_j3d_NativePipeline_destroyOffScreenBuffer(env, obj, cv, gctx, display, fbConfigListPtr, newWin); + Java_javax_media_j3d_NativePipeline_destroyContext(env, obj, display, newWin, (jlong)ctxInfo); } else if(window != 0){ - Java_javax_media_j3d_Canvas3D_destroyContext(env, obj, display, newWin, (jlong)ctxInfo); + Java_javax_media_j3d_NativePipeline_destroyContext(env, obj, display, newWin, (jlong)ctxInfo); } } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_beginScene( +void JNICALL Java_javax_media_j3d_NativePipeline_beginScene( JNIEnv *env, jobject obj, jlong ctxInfo) { - /* Not used by OGL version */ + /* Not used by OGL renderer */ } JNIEXPORT -void JNICALL Java_javax_media_j3d_Canvas3D_endScene( +void JNICALL Java_javax_media_j3d_NativePipeline_endScene( JNIEnv *env, jobject obj, jlong ctxInfo) @@ -3488,18 +3030,18 @@ void JNICALL Java_javax_media_j3d_Canvas3D_endScene( } /* Setup the multisampling for full scene antialiasing */ -JNIEXPORT void JNICALL Java_javax_media_j3d_Canvas3D_setFullSceneAntialiasing +JNIEXPORT void JNICALL Java_javax_media_j3d_NativePipeline_setFullSceneAntialiasing (JNIEnv *env, jobject obj, jlong ctxInfo, jboolean enable) { GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; - if (ctxProperties->arb_multisample && !ctxProperties->implicit_multisample) { + if (ctxProperties->multisample && !ctxProperties->implicit_multisample) { if(enable == JNI_TRUE) { - glEnable(GL_MULTISAMPLE_ARB); + glEnable(GL_MULTISAMPLE); } else { - glDisable(GL_MULTISAMPLE_ARB); + glDisable(GL_MULTISAMPLE); } } @@ -3511,7 +3053,7 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_Canvas3D_setFullSceneAntialiasing * Return false if <= 8 bit color under windows */ JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_Canvas3D_validGraphicsMode( +jboolean JNICALL Java_javax_media_j3d_NativePipeline_validGraphicsMode( JNIEnv *env, jobject obj) { @@ -3528,9 +3070,18 @@ jboolean JNICALL Java_javax_media_j3d_Canvas3D_validGraphicsMode( } +JNIEXPORT +void JNICALL Java_javax_media_j3d_NativePipeline_cleanupRenderer( + JNIEnv *env, + jobject obj) +{ + /* No-op for OGL pipeline */ +} + + /* * Function to disable most rendering attributes when doing a 2D - * clear, image copy, or image composite operation. Note that the + * clear, or image copy operation. Note that the * caller must save/restore the attributes with * pushAttrib(GL_ENABLE_BIT|...) and popAttrib() */ @@ -3560,13 +3111,8 @@ disableAttribFor2D(GraphicsContextPropertiesInfo *ctxProperties) glDisable(GL_CLIP_PLANE0 + i); } - if (ctxProperties->texture3DAvailable) { - glDisable(ctxProperties->texture_3D_ext_enum); - } - - if (ctxProperties->textureCubeMapAvailable) { - glDisable(ctxProperties->texture_cube_map_ext_enum); - } + glDisable(GL_TEXTURE_3D); + glDisable(GL_TEXTURE_CUBE_MAP); if (ctxProperties->textureRegisterCombinersAvailable) { glDisable(GL_REGISTER_COMBINERS_NV); @@ -3580,3 +3126,28 @@ disableAttribFor2D(GraphicsContextPropertiesInfo *ctxProperties) glDisable(GL_GLOBAL_ALPHA_SUN); } } + +/* + * Function to disable most rendering attributes when doing a Raster + * clear, or image copy operation. Note that the + * caller must save/restore the attributes with + * pushAttrib(GL_ENABLE_BIT|...) and popAttrib() + */ +static void +disableAttribForRaster(GraphicsContextPropertiesInfo *ctxProperties) +{ + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_CULL_FACE); + glDisable(GL_LIGHTING); + glDisable(GL_POLYGON_OFFSET_FILL); + glDisable(GL_POLYGON_STIPPLE); + + // TODO: Disable if Raster.CLIP_POSITION is true +// for (int i = 0; i < 6; i++) { +// glDisable(GL_CLIP_PLANE0 + i); +// } + + if (ctxProperties->global_alpha_sun) { + glDisable(GL_GLOBAL_ALPHA_SUN); + } +} diff --git a/src/native/ogl/CgShaderProgram.c b/src/native/ogl/CgShaderProgram.c index 04286e2..a4bfce0 100644 --- a/src/native/ogl/CgShaderProgram.c +++ b/src/native/ogl/CgShaderProgram.c @@ -56,14 +56,14 @@ static CgWrapperInfo *globalCgWrapperInfo = NULL; /* - * Class: javax_media_j3d_MasterControl + * Class: javax_media_j3d_NativePipeline * Method: loadNativeCgLibrary - * Signature: ()Z + * Signature: ([Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_javax_media_j3d_MasterControl_loadNativeCgLibrary( +Java_javax_media_j3d_NativePipeline_loadNativeCgLibrary( JNIEnv *env, - jclass clazz, + jobject thiz, jobjectArray libpath) { CgWrapperInfo *cgWrapperInfo; @@ -83,7 +83,7 @@ Java_javax_media_j3d_MasterControl_loadNativeCgLibrary( /* Assertion check that we don't get called more than once */ if (globalCgWrapperInfo != NULL) { - throwAssert(env, "MasterControl.loadNativeCgLibrary called more than once"); + throwAssert(env, "NativePipeline.loadNativeCgLibrary called more than once"); return JNI_FALSE; } @@ -403,12 +403,12 @@ checkCgShaderExtensions( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: createNativeShader + * Class: javax_media_j3d_NativePipeline + * Method: createCgShader * Signature: (JI[J)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_createNativeShader( +Java_javax_media_j3d_NativePipeline_createCgShader( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -427,7 +427,7 @@ Java_javax_media_j3d_CgShaderProgramRetained_createNativeShader( CgShaderInfo *cgShaderInfo; #ifdef VERBOSE - fprintf(stderr, "CgShaderProgramRetained.createNativeShader\n"); + fprintf(stderr, "CgShaderProgramRetained.createCgShader\n"); #endif /* VERBOSE */ cgShaderInfo = (CgShaderInfo*)malloc(sizeof(CgShaderInfo)); @@ -470,12 +470,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_createNativeShader( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: destroyNativeShader + * Class: javax_media_j3d_NativePipeline + * Method: destroyCgShader * Signature: (JJ)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_destroyNativeShader( +Java_javax_media_j3d_NativePipeline_destroyCgShader( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -492,7 +492,7 @@ Java_javax_media_j3d_CgShaderProgramRetained_destroyNativeShader( CgShaderInfo *cgShaderInfo = (CgShaderInfo *)shaderId; #ifdef VERBOSE - fprintf(stderr, "CgShaderProgramRetained.destroyNativeShader\n"); + fprintf(stderr, "CgShaderProgramRetained.destroyCgShader\n"); #endif /* VERBOSE */ if (cgShaderInfo != NULL) { @@ -517,12 +517,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_destroyNativeShader( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: compileNativeShader + * Class: javax_media_j3d_NativePipeline + * Method: compileCgShader * Signature: (JJLjava/lang/String;)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_compileNativeShader( +Java_javax_media_j3d_NativePipeline_compileCgShader( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -542,7 +542,7 @@ Java_javax_media_j3d_CgShaderProgramRetained_compileNativeShader( GLcharARB *shaderString = NULL; #ifdef VERBOSE - fprintf(stderr, "CgShaderProgramRetained.compileNativeShader\n"); + fprintf(stderr, "CgShaderProgramRetained.compileCgShader\n"); #endif /* VERBOSE */ /* Assertion check the cgShaderInfo pointer */ @@ -610,12 +610,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_compileNativeShader( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: createNativeShaderProgram + * Class: javax_media_j3d_NativePipeline + * Method: createCgShaderProgram * Signature: (J[J)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_createNativeShaderProgram( +Java_javax_media_j3d_NativePipeline_createCgShaderProgram( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -631,7 +631,7 @@ Java_javax_media_j3d_CgShaderProgramRetained_createNativeShaderProgram( (CgShaderProgramInfo*)malloc(sizeof(CgShaderProgramInfo)); #ifdef VERBOSE - fprintf(stderr, "CgShaderProgramRetained.createNativeShaderProgram\n"); + fprintf(stderr, "CgShaderProgramRetained.createCgShaderProgram\n"); #endif /* VERBOSE */ shaderProgramInfo->vShader = NULL; @@ -657,12 +657,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_createNativeShaderProgram( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: destroyNativeShaderProgram + * Class: javax_media_j3d_NativePipeline + * Method: destroyCgShaderProgram * Signature: (JJ)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_destroyNativeShaderProgram( +Java_javax_media_j3d_NativePipeline_destroyCgShaderProgram( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -675,7 +675,7 @@ Java_javax_media_j3d_CgShaderProgramRetained_destroyNativeShaderProgram( CgShaderProgramInfo *shaderProgramInfo = (CgShaderProgramInfo*)shaderProgramId; #ifdef VERBOSE - fprintf(stderr, "CgShaderProgramRetained.destroyNativeShaderProgram\n"); + fprintf(stderr, "CgShaderProgramRetained.destroyCgShaderProgram\n"); #endif /* VERBOSE */ if (shaderProgramInfo != NULL) { @@ -700,12 +700,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_destroyNativeShaderProgram( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: linkNativeShaderProgram + * Class: javax_media_j3d_NativePipeline + * Method: linkCgShaderProgram * Signature: (JJ[J)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_linkNativeShaderProgram( +Java_javax_media_j3d_NativePipeline_linkCgShaderProgram( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -729,7 +729,7 @@ Java_javax_media_j3d_CgShaderProgramRetained_linkNativeShaderProgram( CgShaderProgramInfo *shaderProgramInfo = (CgShaderProgramInfo*)shaderProgramId; #ifdef VERBOSE - fprintf(stderr, "CgShaderProgramRetained.linkNativeShaderProgram\n"); + fprintf(stderr, "CgShaderProgramRetained.linkCgShaderProgram\n"); #endif /* VERBOSE */ /* @@ -789,12 +789,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_linkNativeShaderProgram( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: lookupNativeVertexAttrNames + * Class: javax_media_j3d_NativePipeline + * Method: lookupCgVertexAttrNames * Signature: (JJI[Ljava/lang/String;[Z)V */ JNIEXPORT void JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_lookupNativeVertexAttrNames( +Java_javax_media_j3d_NativePipeline_lookupCgVertexAttrNames( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -831,7 +831,7 @@ Java_javax_media_j3d_CgShaderProgramRetained_lookupNativeVertexAttrNames( shaderProgramInfo->vtxAttrs = (CGparameter *)malloc(numAttrNames * sizeof(CGparameter)); #ifdef VERBOSE - fprintf(stderr, "CgShaderProgramRetained.lookupNativeVertexAttrNames()\n"); + fprintf(stderr, "CgShaderProgramRetained.lookupCgVertexAttrNames()\n"); #endif /* VERBOSE */ for (i = 0; i < numAttrNames; i++) { @@ -974,12 +974,12 @@ lookupParams( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: lookupNativeShaderAttrNames + * Class: javax_media_j3d_NativePipeline + * Method: lookupCgShaderAttrNames * Signature: (JJI[Ljava/lang/String;[J[I[I[Z)V */ JNIEXPORT void JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_lookupNativeShaderAttrNames( +Java_javax_media_j3d_NativePipeline_lookupCgShaderAttrNames( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1050,7 +1050,7 @@ Java_javax_media_j3d_CgShaderProgramRetained_lookupNativeShaderAttrNames( * same type and dimensionality, then a struct is allocated * containing the list of parameters. * - * When any of the setUniform methods are called, the attribute + * When any of the setCgUniform methods are called, the attribute * will be set for each parameter in the list. */ cgParamInfo = (CgParameterInfo *)malloc(sizeof(CgParameterInfo)); @@ -1150,12 +1150,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_lookupNativeShaderAttrNames( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: useShaderProgram + * Class: javax_media_j3d_NativePipeline + * Method: useCgShaderProgram * Signature: (JJ)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_useShaderProgram( +Java_javax_media_j3d_NativePipeline_useCgShaderProgram( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1201,12 +1201,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_useShaderProgram( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform1i + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform1i * Signature: (JJJI)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform1i( +Java_javax_media_j3d_NativePipeline_setCgUniform1i( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1245,12 +1245,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform1i( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform1f + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform1f * Signature: (JJJF)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform1f( +Java_javax_media_j3d_NativePipeline_setCgUniform1f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1289,12 +1289,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform1f( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform2i + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform2i * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform2i( +Java_javax_media_j3d_NativePipeline_setCgUniform2i( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1345,12 +1345,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform2i( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform2f + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform2f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform2f( +Java_javax_media_j3d_NativePipeline_setCgUniform2f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1401,12 +1401,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform2f( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform3i + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform3i * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform3i( +Java_javax_media_j3d_NativePipeline_setCgUniform3i( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1459,12 +1459,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform3i( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform3f + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform3f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform3f( +Java_javax_media_j3d_NativePipeline_setCgUniform3f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1517,12 +1517,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform3f( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform4i + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform4i * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform4i( +Java_javax_media_j3d_NativePipeline_setCgUniform4i( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1577,12 +1577,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform4i( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform4f + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform4f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform4f( +Java_javax_media_j3d_NativePipeline_setCgUniform4f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1637,12 +1637,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform4f( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniformMatrix3f + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniformMatrix3f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix3f( +Java_javax_media_j3d_NativePipeline_setCgUniformMatrix3f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1689,12 +1689,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix3f( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniformMatrix4f + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniformMatrix4f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix4f( +Java_javax_media_j3d_NativePipeline_setCgUniformMatrix4f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1741,12 +1741,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix4f( /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform1iArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform1iArray * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform1iArray( +Java_javax_media_j3d_NativePipeline_setCgUniform1iArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1802,12 +1802,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform1iArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform1fArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform1fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform1fArray( +Java_javax_media_j3d_NativePipeline_setCgUniform1fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1856,12 +1856,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform1fArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform2iArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform2iArray * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform2iArray( +Java_javax_media_j3d_NativePipeline_setCgUniform2iArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1917,12 +1917,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform2iArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform2fArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform2fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform2fArray( +Java_javax_media_j3d_NativePipeline_setCgUniform2fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1971,12 +1971,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform2fArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform3iArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform3iArray * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform3iArray( +Java_javax_media_j3d_NativePipeline_setCgUniform3iArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2032,12 +2032,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform3iArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform3fArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform3fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform3fArray( +Java_javax_media_j3d_NativePipeline_setCgUniform3fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2086,12 +2086,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform3fArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform4iArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform4iArray * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform4iArray( +Java_javax_media_j3d_NativePipeline_setCgUniform4iArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2147,12 +2147,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform4iArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniform4fArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniform4fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniform4fArray( +Java_javax_media_j3d_NativePipeline_setCgUniform4fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2201,12 +2201,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniform4fArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniformMatrix3fArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniformMatrix3fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix3fArray( +Java_javax_media_j3d_NativePipeline_setCgUniformMatrix3fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -2255,12 +2255,12 @@ Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix3fArray( } /* - * Class: javax_media_j3d_CgShaderProgramRetained - * Method: setUniformMatrix4fArray + * Class: javax_media_j3d_NativePipeline + * Method: setCgUniformMatrix4fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_CgShaderProgramRetained_setUniformMatrix4fArray( +Java_javax_media_j3d_NativePipeline_setCgUniformMatrix4fArray( JNIEnv *env, jobject obj, jlong ctxInfo, diff --git a/src/native/ogl/DrawingSurfaceObjectAWT.c b/src/native/ogl/DrawingSurfaceObjectAWT.c index 25f8bd1..867a78d 100644 --- a/src/native/ogl/DrawingSurfaceObjectAWT.c +++ b/src/native/ogl/DrawingSurfaceObjectAWT.c @@ -23,7 +23,7 @@ #include <math.h> #include <jawt_md.h> -#include "javax_media_j3d_MasterControl.h" +#include "javax_media_j3d_NativePipeline.h" #include "javax_media_j3d_DrawingSurfaceObjectAWT.h" #ifdef DEBUG @@ -47,7 +47,7 @@ JNIEXPORT jlong JNICALL -Java_javax_media_j3d_MasterControl_getAWT( +Java_javax_media_j3d_NativePipeline_getAWT( JNIEnv *env, jobject obj) { JAWT *awt; diff --git a/src/native/ogl/GLSLInfo.h b/src/native/ogl/GLSLInfo.h index 00b3368..e9accfa 100644 --- a/src/native/ogl/GLSLInfo.h +++ b/src/native/ogl/GLSLInfo.h @@ -17,6 +17,8 @@ /* Structure used to hold GLSL context information; stored in ctxInfo */ struct GLSLCtxInfoRec { + int vertexAttrOffset; + PFNGLATTACHOBJECTARBPROC pfnglAttachObjectARB; PFNGLCOMPILESHADERARBPROC pfnglCompileShaderARB; PFNGLCREATEPROGRAMOBJECTARBPROC pfnglCreateProgramObjectARB; diff --git a/src/native/ogl/GLSLShaderProgram.c b/src/native/ogl/GLSLShaderProgram.c index bbc29da..26c19f6 100644 --- a/src/native/ogl/GLSLShaderProgram.c +++ b/src/native/ogl/GLSLShaderProgram.c @@ -33,6 +33,7 @@ #endif /* DEBUG */ +extern jint getJavaIntEnv(JNIEnv *env, char* envStr); extern char *strJavaToC(JNIEnv *env, jstring str); extern void throwAssert(JNIEnv *env, char *str); extern jobject createShaderError(JNIEnv *env, @@ -265,10 +266,14 @@ checkGLSLShaderExtensions( glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &ctxInfo->maxTextureImageUnits); glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, &ctxInfo->maxVertexTextureImageUnits); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, &ctxInfo->maxCombinedTextureImageUnits); + + /* Initialize GLSL VertexAttr info */ + glslCtxInfo->vertexAttrOffset = getJavaIntEnv(env, "glslVertexAttrOffset"); glGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &ctxInfo->maxVertexAttrs); - if (ctxInfo->maxVertexAttrs > 0) { - /* decr count, since vertexAttr[0] is reserved for position */ - ctxInfo->maxVertexAttrs -= 1; + /* decr count to allow for reserved vertex attrs */ + ctxInfo->maxVertexAttrs -= glslCtxInfo->vertexAttrOffset; + if (ctxInfo->maxVertexAttrs < 0) { + ctxInfo->maxVertexAttrs = 0; } if (glslCtxInfo->pfnglCreateShaderObjectARB != NULL) { @@ -319,12 +324,12 @@ getInfoLog( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: createNativeShader + * Class: javax_media_j3d_NativePipeline + * Method: createGLSLShader * Signature: (JI[J)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_GLSLShaderProgramRetained_createNativeShader( +Java_javax_media_j3d_NativePipeline_createGLSLShader( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -369,12 +374,12 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_createNativeShader( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: destroyNativeShader + * Class: javax_media_j3d_NativePipeline + * Method: destroyGLSLShader * Signature: (JJ)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_GLSLShaderProgramRetained_destroyNativeShader( +Java_javax_media_j3d_NativePipeline_destroyGLSLShader( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -389,12 +394,12 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_destroyNativeShader( } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: compileNativeShader + * Class: javax_media_j3d_NativePipeline + * Method: compileGLSLShader * Signature: (JJLjava/lang/String;)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_GLSLShaderProgramRetained_compileNativeShader( +Java_javax_media_j3d_NativePipeline_compileGLSLShader( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -451,12 +456,12 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_compileNativeShader( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: createNativeShaderProgram + * Class: javax_media_j3d_NativePipeline + * Method: createGLSLShaderProgram * Signature: (J[J)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_GLSLShaderProgramRetained_createNativeShaderProgram( +Java_javax_media_j3d_NativePipeline_createGLSLShaderProgram( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -487,12 +492,12 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_createNativeShaderProgram( } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: destroyNativeShaderProgram + * Class: javax_media_j3d_NativePipeline + * Method: destroyGLSLShaderProgram * Signature: (JJ)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_GLSLShaderProgramRetained_destroyNativeShaderProgram( +Java_javax_media_j3d_NativePipeline_destroyGLSLShaderProgram( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -507,12 +512,12 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_destroyNativeShaderProgram( } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: linkNativeShaderProgram + * Class: javax_media_j3d_NativePipeline + * Method: linkGLSLShaderProgram * Signature: (JJ[J)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_GLSLShaderProgramRetained_linkNativeShaderProgram( +Java_javax_media_j3d_NativePipeline_linkGLSLShaderProgram( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -558,12 +563,12 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_linkNativeShaderProgram( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: bindNativeVertexAttrName + * Class: javax_media_j3d_NativePipeline + * Method: bindGLSLVertexAttrName * Signature: (JJLjava/lang/String;I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject JNICALL -Java_javax_media_j3d_GLSLShaderProgramRetained_bindNativeVertexAttrName( +Java_javax_media_j3d_NativePipeline_bindGLSLVertexAttrName( JNIEnv * env, jobject obj, jlong ctxInfo, @@ -578,12 +583,12 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_bindNativeVertexAttrName( /* fprintf(stderr, - "GLSLShaderProgramRetained.bindNativeVertexAttrName: %s\n", + "GLSLShaderProgramRetained.bindGLSLVertexAttrName: %s\n", attrNameString); */ glslCtxInfo->pfnglBindAttribLocationARB((GLhandleARB)shaderProgramId, - attrIndex + 1, + attrIndex + glslCtxInfo->vertexAttrOffset, attrNameString); /* No error checking needed, so just return */ @@ -651,12 +656,12 @@ glslToJ3dType(GLint type) /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: lookupNativeShaderAttrNames + * Class: javax_media_j3d_NativePipeline + * Method: lookupGLSLShaderAttrNames * Signature: (JJI[Ljava/lang/String;[J[I[I[Z)V */ JNIEXPORT void JNICALL -Java_javax_media_j3d_GLSLShaderProgramRetained_lookupNativeShaderAttrNames( +Java_javax_media_j3d_NativePipeline_lookupGLSLShaderAttrNames( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -686,7 +691,7 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_lookupNativeShaderAttrNames( JNIEnv table = *env; #ifdef VERBOSE - fprintf(stderr, "GLSLShaderProgramRetained.lookupNativeShaderAttrNames\n"); + fprintf(stderr, "GLSLShaderProgramRetained.lookupGLSLShaderAttrNames\n"); #endif locPtr = (*env)->GetLongArrayElements(env, locArr, NULL); @@ -736,6 +741,8 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_lookupNativeShaderAttrNames( #endif for (i = 0; i < numActiveUniforms; i++) { + int len; + glslCtxInfo->pfnglGetActiveUniformARB((GLhandleARB) shaderProgramId, i, maxStrLen, @@ -743,9 +750,27 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_lookupNativeShaderAttrNames( &size, &type, name); + + /* + * Issue 247 - we need to workaround an ATI bug where they erroneously + * report individual elements of arrays rather than the array itself + */ + len = strlen(name); + if (len >= 3 && name[len-1] == ']') { + if (strcmp(&name[len-3], "[0]") == 0) { + /* fprintf(stderr, "**** changing \"%s\" ", name); */ + name[len-3] = '\0'; + /* fprintf(stderr, "to \"%s\"\n", name); */ + } else { + /* Ignore this name */ + /* fprintf(stderr, "Uniform[%d] : %s ignored\n", i, name); */ + continue; + } + } + #ifdef VERBOSE fprintf(stderr, - "Uniform[%d] : name = %s, type = %d, size = %d\n", + "Uniform[%d] : name = %s ; type = %d ; size = %d\n", i, name, type, size); #endif @@ -794,12 +819,12 @@ Java_javax_media_j3d_GLSLShaderProgramRetained_lookupNativeShaderAttrNames( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: useShaderProgram + * Class: javax_media_j3d_NativePipeline + * Method: useGLSLShaderProgram * Signature: (JI)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_useShaderProgram( +JNICALL Java_javax_media_j3d_NativePipeline_useGLSLShaderProgram( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -816,12 +841,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_useShaderProgram( } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform1i + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform1i * Signature: (JJJI)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1i( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform1i( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -842,12 +867,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1i( } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform1f + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform1f * Signature: (JJJF)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1f( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform1f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -868,12 +893,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1f( } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform2i + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform2i * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2i( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform2i( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -904,12 +929,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2i( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform2f + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform2f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2f( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform2f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -942,12 +967,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2f( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform3i + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform3i * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3i( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform3i( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -978,12 +1003,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3i( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform3f + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform3f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3f( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform3f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1014,12 +1039,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3f( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform4i + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform4i * Signature: (JJJ[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4i( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform4i( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1048,12 +1073,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4i( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform4f + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform4f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4f( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform4f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1083,11 +1108,11 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4f( } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniformMatrix3f + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniformMatrix3f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ -JNIEXPORT jobject JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix3f( +JNIEXPORT jobject JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniformMatrix3f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1117,11 +1142,11 @@ JNIEXPORT jobject JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUnif } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniformMatrix4f + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniformMatrix4f * Signature: (JJJ[F)Ljavax/media/j3d/ShaderError; */ -JNIEXPORT jobject JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix4f( +JNIEXPORT jobject JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniformMatrix4f( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1151,12 +1176,12 @@ JNIEXPORT jobject JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUnif } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform1iArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform1iArray * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1iArray( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform1iArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1190,12 +1215,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1iArray( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform1fArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform1fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1fArray( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform1fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1228,12 +1253,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform1fArray( } /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform2iArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform2iArray * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2iArray( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform2iArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1268,12 +1293,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2iArray( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform2fArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform2fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2fArray( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform2fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1307,12 +1332,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform2fArray( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform3iArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform3iArray * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3iArray( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform3iArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1346,12 +1371,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3iArray( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform3fArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform3fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3fArray( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform3fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1385,12 +1410,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform3fArray( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform4iArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform4iArray * Signature: (JJJI[I)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4iArray( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform4iArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1424,12 +1449,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4iArray( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniform4fArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniform4fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4fArray( +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniform4fArray( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -1463,12 +1488,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniform4fArray( /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniformMatrix3fArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniformMatrix3fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix3fArray +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniformMatrix3fArray ( JNIEnv *env, jobject obj, @@ -1504,12 +1529,12 @@ JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix3fArray /* - * Class: javax_media_j3d_GLSLShaderProgramRetained - * Method: setUniformMatrix4fArray + * Class: javax_media_j3d_NativePipeline + * Method: setGLSLUniformMatrix4fArray * Signature: (JJJI[F)Ljavax/media/j3d/ShaderError; */ JNIEXPORT jobject -JNICALL Java_javax_media_j3d_GLSLShaderProgramRetained_setUniformMatrix4fArray +JNICALL Java_javax_media_j3d_NativePipeline_setGLSLUniformMatrix4fArray ( JNIEnv *env, jobject obj, @@ -1556,8 +1581,8 @@ glslVertexAttrPointer( { GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; - glslCtxInfo->pfnglVertexAttribPointerARB(index+1, size, type, - GL_FALSE, stride, pointer); + glslCtxInfo->pfnglVertexAttribPointerARB(index+glslCtxInfo->vertexAttrOffset, + size, type, GL_FALSE, stride, pointer); } static void @@ -1567,7 +1592,7 @@ glslEnableVertexAttrArray( { GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; - glslCtxInfo->pfnglEnableVertexAttribArrayARB(index+1); + glslCtxInfo->pfnglEnableVertexAttribArrayARB(index+glslCtxInfo->vertexAttrOffset); } static void @@ -1577,7 +1602,7 @@ glslDisableVertexAttrArray( { GLSLCtxInfo *glslCtxInfo = ctxProperties->glslCtxInfo; - glslCtxInfo->pfnglDisableVertexAttribArrayARB(index+1); + glslCtxInfo->pfnglDisableVertexAttribArrayARB(index+glslCtxInfo->vertexAttrOffset); } static void @@ -1590,7 +1615,7 @@ glslVertexAttr1fv( #ifdef VERBOSE fprintf(stderr, "glslVertexAttr1fv()\n"); #endif - glslCtxInfo->pfnglVertexAttrib1fvARB(index+1, v); + glslCtxInfo->pfnglVertexAttrib1fvARB(index+glslCtxInfo->vertexAttrOffset, v); } static void @@ -1603,7 +1628,7 @@ glslVertexAttr2fv( #ifdef VERBOSE fprintf(stderr, "glslVertexAttr2fv()\n"); #endif - glslCtxInfo->pfnglVertexAttrib2fvARB(index+1, v); + glslCtxInfo->pfnglVertexAttrib2fvARB(index+glslCtxInfo->vertexAttrOffset, v); } static void @@ -1616,7 +1641,7 @@ glslVertexAttr3fv( #ifdef VERBOSE fprintf(stderr, "glslVertexAttr3fv()\n"); #endif - glslCtxInfo->pfnglVertexAttrib3fvARB(index+1, v); + glslCtxInfo->pfnglVertexAttrib3fvARB(index+glslCtxInfo->vertexAttrOffset, v); } static void @@ -1629,6 +1654,6 @@ glslVertexAttr4fv( #ifdef VERBOSE fprintf(stderr, "glslVertexAttr4fv()\n"); #endif - glslCtxInfo->pfnglVertexAttrib4fvARB(index+1, v); + glslCtxInfo->pfnglVertexAttrib4fvARB(index+glslCtxInfo->vertexAttrOffset, v); } diff --git a/src/native/ogl/GeometryArrayRetained.c b/src/native/ogl/GeometryArrayRetained.c index fd638b7..c75ba72 100644 --- a/src/native/ogl/GeometryArrayRetained.c +++ b/src/native/ogl/GeometryArrayRetained.c @@ -55,16 +55,12 @@ static void enableTexCoordPointer(GraphicsContextPropertiesInfo *, int, int, static void disableTexCoordPointer(GraphicsContextPropertiesInfo *, int); static void clientActiveTextureUnit(GraphicsContextPropertiesInfo *, int); -/* - * texUnitIndex < 0 implies send all texture unit state info in one pass - * texUnitIndex >= 0 implies one texture unit state info in one pass using - * the underlying texture unit 0 - */ + static void -executeTexture(int texUnitIndex, int texCoordSetMapLen, +executeTexture(int texCoordSetMapLen, int texSize, int bstride, int texCoordoff, jint texCoordSetMapOffset[], - jint numActiveTexUnit, jint texUnitStateMap[], + jint numActiveTexUnit, float verts[], jlong ctxInfo) { int i; @@ -72,69 +68,24 @@ executeTexture(int texUnitIndex, int texCoordSetMapLen, GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; int tus; /* texture unit state index */ - - if (texUnitIndex < 0) { - if(ctxProperties->arb_multitexture) { - for (i = 0; i < numActiveTexUnit; i++) { - /* - * NULL texUnitStateMap means - * one to one mapping from texture unit to - * texture unit state. It is NULL in build display list, - * when the mapping is according to the texCoordSetMap - */ - if (texUnitStateMap != NULL) { - tus = texUnitStateMap[i]; - } else { - tus = i; - } - /* - * it's possible that texture unit state index (tus) - * is greater than the texCoordSetMapOffsetLen, in this - * case, just disable TexCoordPointer. - */ - if ((tus < texCoordSetMapLen) && - (texCoordSetMapOffset[tus] != -1)) { - enableTexCoordPointer(ctxProperties, i, - texSize, GL_FLOAT, bstride, - &(verts[texCoordoff + texCoordSetMapOffset[tus]])); - - } else { - disableTexCoordPointer(ctxProperties, i); - } - } - }/* GL_ARB_multitexture */ + for (i = 0; i < numActiveTexUnit; i++) { - else { + tus = i; -#ifdef VERBOSE - if (numActiveTexUnit > 1) { - fprintf(stderr, "No multi-texture support\n"); - } -#endif /* VERBOSE */ + /* + * it's possible that texture unit state index (tus) + * is greater than the texCoordSetMapOffsetLen, in this + * case, just disable TexCoordPointer. + */ + if ((tus < texCoordSetMapLen) && + (texCoordSetMapOffset[tus] != -1)) { + enableTexCoordPointer(ctxProperties, i, + texSize, GL_FLOAT, bstride, + &(verts[texCoordoff + texCoordSetMapOffset[tus]])); - if (texUnitStateMap != NULL) { - tus = texUnitStateMap[0]; - } else { - tus = 0; - } - if (texCoordSetMapOffset[tus] != -1) { - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glTexCoordPointer(texSize, GL_FLOAT, bstride, - &(verts[texCoordoff + texCoordSetMapOffset[tus]])); - - } else { - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - } - } - } else { - if ((texUnitIndex < texCoordSetMapLen) && - (texCoordSetMapOffset[texUnitIndex] != -1)) { - enableTexCoordPointer(ctxProperties, 0, - texSize, GL_FLOAT, bstride, - &(verts[texCoordoff + texCoordSetMapOffset[texUnitIndex]])); } else { - disableTexCoordPointer(ctxProperties, 0); + disableTexCoordPointer(ctxProperties, i); } } } @@ -146,16 +97,12 @@ resetTexture(jlong ctxInfo) GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - if(ctxProperties->arb_multitexture) { - /* Disable texture coordinate arrays for all texture units */ - for (i = 0; i < ctxProperties->maxTexCoordSets; i++) { - disableTexCoordPointer(ctxProperties, i); - } - /* Reset client active texture unit to 0 */ - clientActiveTextureUnit(ctxProperties, 0); - } else { - disableTexCoordPointer(ctxProperties, 0); + /* Disable texture coordinate arrays for all texture units */ + for (i = 0; i < ctxProperties->maxTexCoordSets; i++) { + disableTexCoordPointer(ctxProperties, i); } + /* Reset client active texture unit to 0 */ + clientActiveTextureUnit(ctxProperties, 0); } @@ -200,7 +147,6 @@ executeGeometryArray( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint startVIndex, jint vcount, jint vformat, @@ -208,10 +154,9 @@ executeGeometryArray( jintArray texCoordSetMap, jint texCoordSetMapLen, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray texUnitStateMapArray, jint vertexAttrCount, jintArray vertexAttrSizes, jfloatArray varray, jobject varrayBuffer, jfloatArray carray, - jint texUnitIndex, jint cDirty) + jint cDirty) { jclass geo_class; JNIEnv table; @@ -231,8 +176,7 @@ executeGeometryArray( jfieldID strip_field; jarray sarray; - jint texSize, texStride, *texCoordSetMapOffset = NULL, - *texUnitStateMap = NULL; + jint texSize, texStride, *texCoordSetMapOffset = NULL; GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; @@ -358,12 +302,8 @@ executeGeometryArray( texCoordSetMapOffset = (jint *) (*(table->GetPrimitiveArrayCritical))(env, texUnitOffset, NULL); } - if (texUnitStateMapArray != NULL) { - texUnitStateMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env, texUnitStateMapArray, NULL); - } - /* Enable normalize for non-uniform scale (which rescale can't handle) */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + if (isNonUniformScale) { glEnable(GL_NORMALIZE); } @@ -416,10 +356,10 @@ executeGeometryArray( if (vformat & GA_TEXTURE_COORDINATE) { - executeTexture(texUnitIndex, texCoordSetMapLen, + executeTexture(texCoordSetMapLen, texSize, bstride, texCoordoff, texCoordSetMapOffset, - numActiveTexUnit, texUnitStateMap, + numActiveTexUnit, startVertex, ctxInfo); } @@ -509,10 +449,10 @@ executeGeometryArray( if (vformat & GA_TEXTURE_COORDINATE) { - executeTexture(texUnitIndex, texCoordSetMapLen, + executeTexture(texCoordSetMapLen, texSize, bstride, texCoordoff, texCoordSetMapOffset, - numActiveTexUnit, texUnitStateMap, + numActiveTexUnit, startVertex, ctxInfo); } @@ -536,7 +476,7 @@ executeGeometryArray( } /* clean up if we turned on normalize */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + if (isNonUniformScale) { glDisable(GL_NORMALIZE); } @@ -555,9 +495,6 @@ executeGeometryArray( (*(table->ReleasePrimitiveArrayCritical))(env, texUnitOffset, texCoordSetMapOffset, 0); - if (texUnitStateMap != NULL) - (*(table->ReleasePrimitiveArrayCritical))(env, texUnitStateMapArray, - texUnitStateMap, 0); if(varray != NULL) (*(table->ReleasePrimitiveArrayCritical))(env, varray, verts, 0); @@ -568,15 +505,14 @@ executeGeometryArray( /* - * Class: javax_media_j3d_GeometryArrayRetained + * Class: javax_media_j3d_NativePipeline * Method: execute * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZZZIIII[II[II[II[I[F[FII)V */ JNIEXPORT void JNICALL -Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, +Java_javax_media_j3d_NativePipeline_execute(JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint startVIndex, jint vcount, jint vformat, @@ -584,10 +520,9 @@ Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, jintArray texCoordSetMap, jint texCoordSetMapLen, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray texUnitStateMapArray, jint vertexAttrCount, jintArray vertexAttrSizes, jfloatArray varray, jfloatArray carray, - jint texUnitIndex, jint cDirty) + jint cDirty) { #ifdef VERBOSE @@ -596,21 +531,20 @@ Java_javax_media_j3d_GeometryArrayRetained_execute(JNIEnv *env, /* call executeGeometryArray */ executeGeometryArray(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, useAlpha, - multiScreen, ignoreVertexColors, startVIndex, vcount, vformat, + ignoreVertexColors, startVIndex, vcount, vformat, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, - texUnitOffset, numActiveTexUnit, texUnitStateMapArray, + texUnitOffset, numActiveTexUnit, vertexAttrCount, vertexAttrSizes, - varray, NULL, carray, texUnitIndex, cDirty); + varray, NULL, carray, cDirty); } /* interleaved data with nio buffer as data format */ JNIEXPORT void JNICALL -Java_javax_media_j3d_GeometryArrayRetained_executeInterleavedBuffer( +Java_javax_media_j3d_NativePipeline_executeInterleavedBuffer( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, - jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, + jboolean isNonUniformScale, jboolean useAlpha, jboolean ignoreVertexColors, jint startVIndex, jint vcount, jint vformat, @@ -618,9 +552,8 @@ Java_javax_media_j3d_GeometryArrayRetained_executeInterleavedBuffer( jintArray texCoordSetMap, jint texCoordSetMapLen, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray texUnitStateMapArray, jobject varray, jfloatArray carray, - jint texUnitIndex, jint cDirty) + jint cDirty) { #ifdef VERBOSE @@ -629,22 +562,22 @@ Java_javax_media_j3d_GeometryArrayRetained_executeInterleavedBuffer( /* call executeGeometryArray */ executeGeometryArray(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, useAlpha, - multiScreen, ignoreVertexColors, startVIndex, vcount, vformat, + ignoreVertexColors, startVIndex, vcount, vformat, texCoordSetCount, texCoordSetMap, texCoordSetMapLen, - texUnitOffset, numActiveTexUnit, texUnitStateMapArray, + texUnitOffset, numActiveTexUnit, 0, NULL, - NULL, varray, carray, texUnitIndex, cDirty); + NULL, varray, carray, cDirty); } /* - * Class: javax_media_j3d_GeometryArrayRetained + * Class: javax_media_j3d_NativePipeline * Method: buildGA * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[II[II[I[D[D[F)V */ JNIEXPORT - void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGA(JNIEnv *env, + void JNICALL Java_javax_media_j3d_NativePipeline_buildGA(JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean updateAlpha, float alpha, @@ -911,12 +844,12 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", if (texCoordSetMapLen > 0) { - if (ctxProperties->arb_multitexture) { + if (ctxProperties->gl13) { if (vformat & GA_TEXTURE_COORDINATE_2) { for (k = 0; k < texCoordSetMapLen; k++) { if (texCoordSetMapOffset[k] != -1) { - ctxProperties->glMultiTexCoord2fvARB( - GL_TEXTURE0_ARB + k, + ctxProperties->glMultiTexCoord2fv( + GL_TEXTURE0 + k, &verts[texCoordoff + texCoordSetMapOffset[k]]); } @@ -924,8 +857,8 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", } else if (vformat & GA_TEXTURE_COORDINATE_3) { for (k = 0; k < texCoordSetMapLen; k++) { if (texCoordSetMapOffset[k] != -1) { - ctxProperties->glMultiTexCoord3fvARB( - GL_TEXTURE0_ARB + k, + ctxProperties->glMultiTexCoord3fv( + GL_TEXTURE0 + k, &verts[texCoordoff + texCoordSetMapOffset[k]]); } @@ -933,15 +866,15 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", } else { for (k = 0; k < texCoordSetMapLen; k++) { if (texCoordSetMapOffset[k] != -1) { - ctxProperties->glMultiTexCoord4fvARB( - GL_TEXTURE0_ARB + k, + ctxProperties->glMultiTexCoord4fv( + GL_TEXTURE0 + k, &verts[texCoordoff + texCoordSetMapOffset[k]]); } } } } - else { /* GL_ARB_multitexture */ + else { /* no multitexture */ if (texCoordSetMapOffset[0] != -1) { if (vformat & GA_TEXTURE_COORDINATE_2) { @@ -955,7 +888,7 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", texCoordSetMapOffset[0]]); } } - } /* GL_ARB_multitexture */ + } /* no multitexture */ } /* * texCoordSetMapLen can't be 0 if texture coordinates @@ -1121,12 +1054,12 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", if (texCoordSetMapLen > 0) { - if(ctxProperties->arb_multitexture) { + if(ctxProperties->gl13) { if (vformat & GA_TEXTURE_COORDINATE_2) { for (k = 0; k < texCoordSetMapLen; k++) { if (texCoordSetMapOffset[k] != -1) { - ctxProperties->glMultiTexCoord2fvARB( - GL_TEXTURE0_ARB + k, + ctxProperties->glMultiTexCoord2fv( + GL_TEXTURE0 + k, &verts[texCoordoff + texCoordSetMapOffset[k]]); } @@ -1134,8 +1067,8 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", } else if (vformat & GA_TEXTURE_COORDINATE_3) { for (k = 0; k < texCoordSetMapLen; k++) { if (texCoordSetMapOffset[k] != -1) { - ctxProperties->glMultiTexCoord3fvARB( - GL_TEXTURE0_ARB + k, + ctxProperties->glMultiTexCoord3fv( + GL_TEXTURE0 + k, &verts[texCoordoff + texCoordSetMapOffset[k]]); } @@ -1143,15 +1076,15 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", } else { for (k = 0; k < texCoordSetMapLen; k++) { if (texCoordSetMapOffset[k] != -1) { - ctxProperties->glMultiTexCoord4fvARB( - GL_TEXTURE0_ARB + k, + ctxProperties->glMultiTexCoord4fv( + GL_TEXTURE0 + k, &verts[texCoordoff + texCoordSetMapOffset[k]]); } } } } - else { /* GL_ARB_multitexture */ + else { /* no multitexture */ if (texCoordSetMapOffset[0] != -1) { if (vformat & GA_TEXTURE_COORDINATE_2) { @@ -1165,7 +1098,7 @@ printf("orig: < %g %g %g > transformed: < %g %g %g >\n", texCoordSetMapOffset[0]]); } } - } /* GL_ARB_multitexture */ + } /* no multitexture */ } /* @@ -1265,8 +1198,8 @@ clientActiveTextureUnit( GraphicsContextPropertiesInfo *ctxProperties, int texUnit) { - if (ctxProperties->arb_multitexture) { - ctxProperties->glClientActiveTextureARB(texUnit + GL_TEXTURE0_ARB); + if (ctxProperties->gl13) { + ctxProperties->glClientActiveTexture(texUnit + GL_TEXTURE0); } } @@ -1279,7 +1212,6 @@ executeGeometryArrayVA( jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint vcount, jint vformat, @@ -1295,12 +1227,10 @@ executeGeometryArrayVA( jint vertexAttrCount, jintArray vertexAttrSizes, jintArray vertexAttrIndices, - jfloat ** vertexAttrPointer, - jint pass, + jfloat ** vertexAttrPointer, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jint* texUnitStateMap, jintArray texindices, jint texStride, jfloat** texCoordPointer, @@ -1341,7 +1271,7 @@ executeGeometryArrayVA( #endif /* VERBOSE */ /* Enable normalize for non-uniform scale (which rescale can't handle) */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + if (isNonUniformScale) { glEnable(GL_NORMALIZE); } @@ -1405,42 +1335,21 @@ executeGeometryArrayVA( initialTexIndices = (jint *) (*(table->GetPrimitiveArrayCritical))(env,texindices, NULL); texCoordSetMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env,tcoordsetmap, NULL); - if (pass < 0) { - for (i = 0; i < numActiveTexUnit; i++) { - tus = texUnitStateMap[i]; - if ((tus < texCoordMapLength) && ( - ((texSet=texCoordSetMap[tus]) != -1))) { - - ptexCoords = texCoordPointer[texSet]; + for (i = 0; i < numActiveTexUnit; i++) { + if ((i < texCoordMapLength) && ( + ((texSet=texCoordSetMap[i]) != -1))) { - enableTexCoordPointer(ctxProperties, i, texStride, - GL_FLOAT, 0, - &ptexCoords[texStride * initialTexIndices[texSet]]); - - } else { - disableTexCoordPointer(ctxProperties, i); - } - } - } - else { - texUnitStateMap = NULL; - texSet = texCoordSetMap[pass]; - if (texSet != -1) { - ptexCoords = texCoordPointer[texSet]; - enableTexCoordPointer(ctxProperties, 0, texStride, - GL_FLOAT, 0, - &ptexCoords[texStride * initialTexIndices[texSet]]); + ptexCoords = texCoordPointer[texSet]; + + enableTexCoordPointer(ctxProperties, i, texStride, + GL_FLOAT, 0, + &ptexCoords[texStride * initialTexIndices[texSet]]); + + } else { + disableTexCoordPointer(ctxProperties, i); + } + } - /* - * in a non-multitexturing case, only the first texture - * unit is used, it will be the core library responsibility - * to disable all texture units before enabling "the" - * texture unit for multi-pass purpose - */ - } else { - disableTexCoordPointer(ctxProperties, 0); - } - } /* Reset client active texture unit to 0 */ clientActiveTextureUnit(ctxProperties, 0); } @@ -1494,7 +1403,7 @@ executeGeometryArrayVA( } } /* clean up if we turned on normalize */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + if (isNonUniformScale) { glDisable(GL_NORMALIZE); } @@ -1513,19 +1422,18 @@ executeGeometryArrayVA( /* execute geometry array with java array format */ /* - * Class: javax_media_j3d_GeometryArrayRetained + * Class: javax_media_j3d_NativePipeline * Method: executeVA * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZZIIII[F[DI[F[BI[FI[I[I[[FII[II[I[II[Ljava/lang/Object;I)V */ JNIEXPORT void JNICALL -Java_javax_media_j3d_GeometryArrayRetained_executeVA( +Java_javax_media_j3d_NativePipeline_executeVA( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint vcount, jint vformat, @@ -1541,12 +1449,10 @@ Java_javax_media_j3d_GeometryArrayRetained_executeVA( jint vertexAttrCount, jintArray vertexAttrSizes, jintArray vertexAttrIndices, - jobjectArray vertexAttrData, - jint pass, + jobjectArray vertexAttrData, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jintArray texindices, jint texStride, jobjectArray texCoords, @@ -1570,7 +1476,6 @@ Java_javax_media_j3d_GeometryArrayRetained_executeVA( jfloat **vertexAttrPointer = NULL; jfloat **texCoordPointer = NULL; jarray *texobjs = NULL; - jint* texUnitStateMap = NULL; int i; jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); @@ -1631,10 +1536,7 @@ Java_javax_media_j3d_GeometryArrayRetained_executeVA( else texCoordPointer[i] = NULL; } - if (pass < 0) { - texUnitStateMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env,tunitstatemap, NULL); - } - } + } /* get coordinate array */ if (floatCoordDefined) { @@ -1660,15 +1562,15 @@ Java_javax_media_j3d_GeometryArrayRetained_executeVA( #endif /* VERBOSE */ executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, - isNonUniformScale, multiScreen, ignoreVertexColors, + isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, norms, vertexAttrCount, vertexAttrSizes, vertexAttrIndices, vertexAttrPointer, - pass, texCoordMapLength, - tcoordsetmap,numActiveTexUnit, texUnitStateMap, + texCoordMapLength, + tcoordsetmap,numActiveTexUnit, texindices,texStride,texCoordPointer,cdirty, sarray, strip_len, start_array); @@ -1691,9 +1593,6 @@ Java_javax_media_j3d_GeometryArrayRetained_executeVA( (*(table->ReleasePrimitiveArrayCritical))(env, texobjs[i], texCoordPointer[i], 0); } } - if (texUnitStateMap != NULL) { - (*(table->ReleasePrimitiveArrayCritical))(env, tunitstatemap, texUnitStateMap, 0); - } } if (texobjs != NULL) { @@ -1726,18 +1625,17 @@ Java_javax_media_j3d_GeometryArrayRetained_executeVA( /* execute geometry array with java array format */ /* - * Class: javax_media_j3d_GeometryArrayRetained + * Class: javax_media_j3d_NativePipeline * Method: executeVABuffer * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZZIIIILjava/lang/Object;ILjava/lang/Object;[F[BILjava/lang/Object;I[I[I[Ljava/lang/Object;II[II[I[II[Ljava/lang/Object;I)V */ -JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffer( +JNIEXPORT void JNICALL Java_javax_media_j3d_NativePipeline_executeVABuffer( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint vcount, jint vformat, @@ -1753,12 +1651,10 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffe jint vertexAttrCount, jintArray vertexAttrSizes, jintArray vertexAttrIndices, - jobjectArray vertexAttrData, - jint pass, + jobjectArray vertexAttrData, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jintArray texindices, jint texStride, jobjectArray texCoords, @@ -1781,7 +1677,6 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffe jfloat **vertexAttrPointer = NULL; jfloat **texCoordPointer = NULL; jarray *texobjs = NULL; - jint* texUnitStateMap = NULL; int i; jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); @@ -1872,9 +1767,6 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffe else texCoordPointer[i] = NULL; } - if (pass < 0) { - texUnitStateMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env,tunitstatemap, NULL); - } } @@ -1883,15 +1775,15 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffe #endif /* VERBOSE */ executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, - isNonUniformScale, multiScreen, ignoreVertexColors, + isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fverts, dverts, initialColorIndex, fclrs, bclrs, initialNormalIndex, norms, vertexAttrCount, vertexAttrSizes, vertexAttrIndices, vertexAttrPointer, - pass, texCoordMapLength, - tcoordsetmap,numActiveTexUnit, texUnitStateMap, + texCoordMapLength, + tcoordsetmap,numActiveTexUnit, texindices,texStride,texCoordPointer,cdirty, sarray, strip_len, start_array); if (vaobjs != NULL) { @@ -1900,12 +1792,6 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffe if (vertexAttrPointer != NULL) { free(vertexAttrPointer); } - - if (textureDefined) { - if (texUnitStateMap != NULL) { - (*(table->ReleasePrimitiveArrayCritical))(env, tunitstatemap, texUnitStateMap, 0); - } - } if (texobjs != NULL) { free(texobjs); @@ -1923,10 +1809,11 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_executeVABuffe JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_disableGlobalAlpha( +void JNICALL Java_javax_media_j3d_NativePipeline_disableGlobalAlpha( JNIEnv *env, jobject obj, - jlong ctxInfo, + jlong ctxInfo, + jobject geo, jint vformat, jboolean useAlpha, jboolean ignoreVertexColors) @@ -1945,15 +1832,16 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_disableGlobalAlpha( /* - * Class: javax_media_j3d_GeometryArrayRetained + * Class: javax_media_j3d_NativePipeline * Method: setVertexFormat * Signature: (JIZZI[I)V */ JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setVertexFormat( +void JNICALL Java_javax_media_j3d_NativePipeline_setVertexFormat( JNIEnv *env, jobject obj, jlong ctxInfo, + jobject geo, jint vformat, jboolean useAlpha, jboolean ignoreVertexColors) @@ -1999,28 +1887,11 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_setVertexFormat( } } -JNIEXPORT jboolean JNICALL -Java_javax_media_j3d_GeometryArrayRetained_globalAlphaSUN( - JNIEnv *env, - jobject obj, - jlong ctxInfo) -{ - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - jlong ctx = ctxProperties->context; - - if (ctxProperties->global_alpha_sun == 1) - return JNI_TRUE ; - else - return JNI_FALSE ; -} - - static void executeIndexedGeometryArray( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint indexCount, @@ -2031,9 +1902,8 @@ executeIndexedGeometryArray( jintArray texCoordSetMap, jint texCoordSetMapLen, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray texUnitStateMapArray, jfloatArray varray, jobject varrayBuffer, jfloatArray carray, - jint texUnitIndex, jint cDirty, + jint cDirty, jintArray indexCoord) { jclass geo_class; @@ -2060,8 +1930,7 @@ executeIndexedGeometryArray( jint** multiDrawElementsIndices = NULL; jint allocated = 0; - jint texSize, texStride, *texCoordSetMapOffset = NULL, - *texUnitStateMap = NULL; + jint texSize, texStride, *texCoordSetMapOffset = NULL; GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; jlong ctx = ctxProperties->context; @@ -2178,12 +2047,8 @@ executeIndexedGeometryArray( texCoordSetMapOffset = (jint *) (*(table->GetPrimitiveArrayCritical))(env, texUnitOffset, NULL); } - if (texUnitStateMapArray != NULL) { - texUnitStateMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env, texUnitStateMapArray, NULL); - } - /* Enable normalize for non-uniform scale (which rescale can't handle) */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + if (isNonUniformScale) { glEnable(GL_NORMALIZE); } @@ -2233,10 +2098,10 @@ executeIndexedGeometryArray( if (vformat & GA_TEXTURE_COORDINATE) { /* XXXX: texCoordoff == 0 ???*/ - executeTexture(texUnitIndex, texCoordSetMapLen, + executeTexture(texCoordSetMapLen, texSize, bstride, texCoordoff, texCoordSetMapOffset, - numActiveTexUnit, texUnitStateMap, + numActiveTexUnit, verts, ctxInfo); } @@ -2336,10 +2201,10 @@ executeIndexedGeometryArray( if (vformat & GA_TEXTURE_COORDINATE) { /* XXXX: texCoordoff == 0 ???*/ - executeTexture(texUnitIndex, texCoordSetMapLen, + executeTexture(texCoordSetMapLen, texSize, bstride, texCoordoff, texCoordSetMapOffset, - numActiveTexUnit, texUnitStateMap, + numActiveTexUnit, verts, ctxInfo); } @@ -2377,7 +2242,7 @@ executeIndexedGeometryArray( /* clean up if we turned on normalize */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + if (isNonUniformScale) { glDisable(GL_NORMALIZE); } if(varray != NULL) @@ -2392,20 +2257,16 @@ executeIndexedGeometryArray( (*(table->ReleasePrimitiveArrayCritical))(env, texUnitOffset, texCoordSetMapOffset, 0); - if (texUnitStateMap != NULL) - (*(table->ReleasePrimitiveArrayCritical))(env, texUnitStateMapArray, - texUnitStateMap, 0); if (vAttrSizesPtr != NULL) { table->ReleaseIntArrayElements(env, vertexAttrSizes, vAttrSizesPtr, JNI_ABORT); } } JNIEXPORT void JNICALL -Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometry( +Java_javax_media_j3d_NativePipeline_executeIndexedGeometry( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint indexCount, @@ -2416,9 +2277,8 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometry( jintArray texCoordSetMap, jint texCoordSetMapLen, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray texUnitStateMapArray, jfloatArray varray, jfloatArray carray, - jint texUnitIndex, jint cDirty, + jint cDirty, jintArray indexCoord) { @@ -2427,7 +2287,7 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometry( #endif /* VERBOSE */ executeIndexedGeometryArray(env, obj, ctxInfo, geo, geo_type, - isNonUniformScale, useAlpha, multiScreen, + isNonUniformScale, useAlpha, ignoreVertexColors, initialIndexIndex, indexCount, @@ -2438,18 +2298,16 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometry( texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnit, - texUnitStateMapArray, varray, NULL, carray, - texUnitIndex, cDirty, + cDirty, indexCoord); } JNIEXPORT void JNICALL -Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryBuffer( +Java_javax_media_j3d_NativePipeline_executeIndexedGeometryBuffer( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, jboolean useAlpha, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint indexCount, @@ -2459,9 +2317,8 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryBuffer( jintArray texCoordSetMap, jint texCoordSetMapLen, jintArray texUnitOffset, jint numActiveTexUnit, - jintArray texUnitStateMapArray, jobject varray, jfloatArray carray, - jint texUnitIndex, jint cDirty, + jint cDirty, jintArray indexCoord) { @@ -2470,7 +2327,7 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryBuffer( #endif /* VERBOSE */ executeIndexedGeometryArray(env, obj, ctxInfo, geo, geo_type, - isNonUniformScale, useAlpha, multiScreen, + isNonUniformScale, useAlpha, ignoreVertexColors, initialIndexIndex, indexCount, @@ -2481,9 +2338,8 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryBuffer( texCoordSetMap, texCoordSetMapLen, texUnitOffset, numActiveTexUnit, - texUnitStateMapArray, NULL, varray, carray, - texUnitIndex, cDirty, + cDirty, indexCoord); } @@ -2496,7 +2352,6 @@ executeIndexedGeometryArrayVA( jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint validIndexCount, @@ -2510,12 +2365,10 @@ executeIndexedGeometryArrayVA( jfloat* norms, jint vertexAttrCount, jintArray vertexAttrSizes, - jfloat ** vertexAttrPointer, - jint pass, + jfloat ** vertexAttrPointer, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jint texStride, jfloat** texCoordPointer, jint cdirty, @@ -2543,7 +2396,7 @@ executeIndexedGeometryArrayVA( jlong ctx = ctxProperties->context; int texSet; - jint *texCoordSetMap, *texUnitStateMap; + jint *texCoordSetMap; GLsizei *countArray; jint* vAttrSizes; jint offset = 0; @@ -2557,7 +2410,7 @@ executeIndexedGeometryArrayVA( #endif /* VERBOSE */ /* Enable normalize for non-uniform scale (which rescale can't handle) */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + if (isNonUniformScale) { glEnable(GL_NORMALIZE); } @@ -2608,43 +2461,23 @@ executeIndexedGeometryArrayVA( int tus = 0; float *ptexCoords; - texCoordSetMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env,tcoordsetmap, NULL); - if (pass < 0) { - texUnitStateMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env,tunitstatemap, NULL); - for (i = 0; i < numActiveTexUnit; i++) { - tus = texUnitStateMap[i]; - if ((tus < texCoordMapLength) && ( - ((texSet=texCoordSetMap[tus]) != -1))) { - - ptexCoords = texCoordPointer[texSet]; + texCoordSetMap = (jint *) (*(table->GetPrimitiveArrayCritical))(env,tcoordsetmap, NULL); + for (i = 0; i < numActiveTexUnit; i++) { + if ((i < texCoordMapLength) && ( + ((texSet=texCoordSetMap[i]) != -1))) { - enableTexCoordPointer(ctxProperties, i, texStride, - GL_FLOAT, 0, - ptexCoords); - - } else { + ptexCoords = texCoordPointer[texSet]; - disableTexCoordPointer(ctxProperties, i); - } - } - } - else { - texUnitStateMap = NULL; - texSet = texCoordSetMap[pass]; - if (texSet != -1) { - ptexCoords = texCoordPointer[texSet]; - enableTexCoordPointer(ctxProperties, 0, texStride, - GL_FLOAT, 0, - ptexCoords); + enableTexCoordPointer(ctxProperties, i, texStride, + GL_FLOAT, 0, + ptexCoords); + + } else { + + disableTexCoordPointer(ctxProperties, i); + } + } - /* - * in a non-multitexturing case, only the first texture - * unit is used, it will be the core library responsibility - * to disable all texture units before enabling "the" - * texture unit for multi-pass purpose - */ - } - } /* Reset client active texture unit to 0 */ clientActiveTextureUnit(ctxProperties, 0); } @@ -2714,7 +2547,7 @@ executeIndexedGeometryArrayVA( unlockArray(ctxProperties); /* clean up if we turned on normalize */ - if (ctxProperties->rescale_normal_ext && isNonUniformScale) { + if (isNonUniformScale) { glDisable(GL_NORMALIZE); } @@ -2728,21 +2561,18 @@ executeIndexedGeometryArrayVA( resetTexture(ctxInfo); (*(table->ReleasePrimitiveArrayCritical))(env, tcoordsetmap, texCoordSetMap, 0); - if (texUnitStateMap != NULL) - (*(table->ReleasePrimitiveArrayCritical))(env, tunitstatemap, texUnitStateMap, 0); } } JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryVA( +void JNICALL Java_javax_media_j3d_NativePipeline_executeIndexedGeometryVA( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint validIndexCount, @@ -2756,12 +2586,10 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jfloatArray ndata, jint vertexAttrCount, jintArray vertexAttrSizes, - jobjectArray vertexAttrData, - jint pass, + jobjectArray vertexAttrData, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jint texStride, jobjectArray texCoords, jint cdirty, @@ -2871,7 +2699,6 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo geo, geo_type, isNonUniformScale, - multiScreen, ignoreVertexColors, initialIndexIndex, validIndexCount, @@ -2885,12 +2712,10 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo norms, vertexAttrCount, vertexAttrSizes, - vertexAttrPointer, - pass, + vertexAttrPointer, texCoordMapLength, tcoordsetmap, numActiveTexUnit, - tunitstatemap, texStride, texCoordPointer, cdirty, @@ -2946,14 +2771,13 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo } JNIEXPORT -void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeometryVABuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_executeIndexedGeometryVABuffer( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, jboolean isNonUniformScale, - jboolean multiScreen, jboolean ignoreVertexColors, jint initialIndexIndex, jint validIndexCount, @@ -2967,12 +2791,10 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo jobject ndata, jint vertexAttrCount, jintArray vertexAttrSizes, - jobjectArray vertexAttrData, - jint pass, + jobjectArray vertexAttrData, jint texCoordMapLength, jintArray tcoordsetmap, jint numActiveTexUnit, - jintArray tunitstatemap, jint texStride, jobjectArray texCoords, jint cdirty, @@ -3089,7 +2911,6 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo geo, geo_type, isNonUniformScale, - multiScreen, ignoreVertexColors, initialIndexIndex, validIndexCount, @@ -3104,11 +2925,9 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo vertexAttrCount, vertexAttrSizes, vertexAttrPointer, - pass, texCoordMapLength, tcoordsetmap, numActiveTexUnit, - tunitstatemap, texStride, texCoordPointer, cdirty, @@ -3137,7 +2956,7 @@ void JNICALL Java_javax_media_j3d_IndexedGeometryArrayRetained_executeIndexedGeo } JNIEXPORT void JNICALL -Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeometry( +Java_javax_media_j3d_NativePipeline_buildIndexedGeometry( JNIEnv *env, jobject obj, jlong ctxInfo, jobject geo, jint geo_type, @@ -3414,10 +3233,10 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeometry( if (vformat & GA_TEXTURE_COORDINATE) { - executeTexture(-1, texCoordSetMapLen, + executeTexture(texCoordSetMapLen, texSize, bstride, texCoordoff, texCoordSetMapOffset, - texCoordSetMapLen, NULL, + texCoordSetMapLen, verts, ctxInfo); } @@ -3536,10 +3355,10 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeometry( } if (vformat & GA_TEXTURE_COORDINATE) { - executeTexture(-1, texCoordSetMapLen, + executeTexture(texCoordSetMapLen, texSize, bstride, texCoordoff, texCoordSetMapOffset, - texCoordSetMapLen, NULL, + texCoordSetMapLen, verts, ctxInfo); } @@ -3607,7 +3426,7 @@ Java_javax_media_j3d_IndexedGeometryArrayRetained_buildIndexedGeometry( * Method: buildGAForByRef * Signature: (JLjavax/media/j3d/GeometryArrayRetained;IZZFZIIII[F[DI[F[BI[FI[I[I[[FI[I[II[Ljava/lang/Object;[D[D)V */ -JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRef( +JNIEXPORT void JNICALL Java_javax_media_j3d_NativePipeline_buildGAForByRef( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -3665,7 +3484,6 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRe jfloat **vertexAttrPointer = NULL; jfloat **texCoordPointer = NULL; jarray *texobjs = NULL; - jint *tunitstatemap = NULL; int offset = 0; jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); @@ -3741,14 +3559,11 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRe /* get texture arrays */ if (textureDefined) { - tunitstatemap = (int *)malloc(texCoordMapLength * sizeof(int)); for (i = 0; i < texCoordMapLength; i++) { - tunitstatemap[i] = i; if (texobjs[i] != NULL) texCoordPointer[i] = (jfloat*)(*(table->GetPrimitiveArrayCritical))(env,texobjs[i], NULL); else - texCoordPointer[i] = NULL; - + texCoordPointer[i] = NULL; } } @@ -3917,17 +3732,14 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRe fprintf(stderr, "GeometryArrayRetained.buildGAForByRef() -- calling executeGeometryArrayVA\n"); #endif /* VERBOSE */ - executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, - isNonUniformScale, JNI_FALSE, ignoreVertexColors, - vcount, vformat, vdefined, initialCoordIndex, - fvptr, dvptr, initialColorIndex, + executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, isNonUniformScale, + ignoreVertexColors, vcount, vformat, vdefined, + initialCoordIndex, fvptr, dvptr, initialColorIndex, fcptr, bcptr, initialNormalIndex, - nptr, - vertexAttrCount, vertexAttrSizes, - vertexAttrIndices, vertexAttrPointer, - -1, texCoordMapLength, - tcoordsetmap, texCoordMapLength, tunitstatemap, - texindices,texStride,texCoordPointer,0, sarray, + nptr, vertexAttrCount, vertexAttrSizes, + vertexAttrIndices, vertexAttrPointer, texCoordMapLength, + tcoordsetmap, texCoordMapLength, + texindices, texStride, texCoordPointer, 0, sarray, strip_len, start_array); if (vattrDefined) { @@ -3944,9 +3756,6 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRe } if (textureDefined) { - if (tunitstatemap != NULL) { - free(tunitstatemap); - } for (i = 0; i < texCoordMapLength; i++) { if (texCoordPointer[i] != NULL) { (*(table->ReleasePrimitiveArrayCritical))(env, texobjs[i], texCoordPointer[i], 0); @@ -3992,7 +3801,7 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRe else if (doubleCoordDefined) { (*env)->ReleasePrimitiveArrayCritical(env, vdcoords, dverts, 0); if (tmpDoubleCoordArray != NULL) { - free(tmpFloatCoordArray); + free(tmpDoubleCoordArray); } } } @@ -4002,7 +3811,7 @@ JNIEXPORT void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForByRe #if 0 /* execute geometry array with java array format */ JNIEXPORT -void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( +void JNICALL Java_javax_media_j3d_NativePipeline_buildGAForBuffer( JNIEnv *env, jobject obj, jlong ctxInfo, @@ -4052,7 +3861,6 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( jbyte* bcptr = NULL; jfloat **texCoordPointer = NULL; jarray *texobjs = NULL; - jint *tunitstatemap = NULL; jboolean floatCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_FLOAT) != 0); jboolean doubleCoordDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COORD_DOUBLE) != 0); jboolean floatColorsDefined = ((vdefined & javax_media_j3d_GeometryArrayRetained_COLOR_FLOAT) != 0); @@ -4110,9 +3918,7 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( } /* get texture arrays */ if (textureDefined) { - tunitstatemap = (int *)malloc( texCoordMapLength * sizeof(int)); for (i = 0; i < texCoordMapLength; i++) { - tunitstatemap[i] = i; if (texobjs[i] != NULL) texCoordPointer[i] = (jfloat*)(*(table->GetPrimitiveArrayCritical))(env,texobjs[i], NULL); else @@ -4287,20 +4093,17 @@ void JNICALL Java_javax_media_j3d_GeometryArrayRetained_buildGAForBuffer( #endif /* VERBOSE */ executeGeometryArrayVA(env, obj, ctxInfo, geo, geo_type, - isNonUniformScale, JNI_FALSE, ignoreVertexColors, + isNonUniformScale, ignoreVertexColors, vcount, vformat, vdefined, initialCoordIndex, fvptr, dvptr, initialColorIndex, fcptr, bcptr, initialNormalIndex, nptr, /* TODO: vertexAttrCount, vertexAttrSizes, */ /* TODO: vertexAttrIndices, vertexAttrPointer, */ - -1, texCoordMapLength, - tcoordsetmap, texCoordMapLength, tunitstatemap, + texCoordMapLength, + tcoordsetmap, texCoordMapLength, texindices,texStride,texCoordPointer,0, sarray, strip_len, start_array); if (textureDefined) { - if (tunitstatemap != NULL) { - free(tunitstatemap); - } for (i = 0; i < texCoordMapLength; i++) { if (texCoordPointer[i] != NULL) { (*(table->ReleasePrimitiveArrayCritical))(env, texobjs[i], texCoordPointer[i], 0); diff --git a/src/native/ogl/GraphicsContext3D.c b/src/native/ogl/GraphicsContext3D.c index da656a6..50f73bf 100644 --- a/src/native/ogl/GraphicsContext3D.c +++ b/src/native/ogl/GraphicsContext3D.c @@ -17,21 +17,163 @@ extern void throwAssert(JNIEnv *env, char *str); +JNIEXPORT +void JNICALL Java_javax_media_j3d_NativePipeline_readRaster( + JNIEnv *env, jobject obj, jlong ctx, + jint type, jint xOffset, jint yOffset, + jint wRaster, jint hRaster, jint hCanvas, + jint imageDataType, + jint imageFormat, jobject imageBuffer, + jint depthFormat, jobject depthBuffer) +{ + JNIEnv table; + int yAdjusted; + GLenum oglFormat; + void *imageObjPtr; + void *depthObjPtr; + + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctx; + + table = *env; + + glPixelStorei(GL_PACK_ROW_LENGTH, wRaster); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + yAdjusted = hCanvas - hRaster - yOffset; + + if ((type & javax_media_j3d_Raster_RASTER_COLOR) != 0) { + + imageObjPtr = + (void *)(*(table->GetPrimitiveArrayCritical))(env, (jarray)imageBuffer, NULL); + + if(imageDataType == IMAGE_DATA_TYPE_BYTE_ARRAY) { + + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_BYTE_BGR: + oglFormat = GL_BGR; + break; + case IMAGE_FORMAT_BYTE_RGB: + oglFormat = GL_RGB; + break; + /* GL_ABGR_EXT */ + case IMAGE_FORMAT_BYTE_ABGR: + if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ + oglFormat = GL_ABGR_EXT; + } + else { + throwAssert(env, "readRaster : GL_ABGR_EXT format is unsupported"); + return; + } + break; + case IMAGE_FORMAT_BYTE_RGBA: + oglFormat = GL_RGBA; + break; + case IMAGE_FORMAT_BYTE_LA: + /* all LA types are stored as LA8 */ + oglFormat = GL_LUMINANCE_ALPHA; + break; + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_INT_BGR: + case IMAGE_FORMAT_INT_RGB: + case IMAGE_FORMAT_INT_ARGB: + default: + throwAssert(env, "readRaster : imageFormat illegal format"); + return; + } + + glReadPixels(xOffset, yAdjusted, wRaster, hRaster, + oglFormat, GL_UNSIGNED_BYTE, imageObjPtr); + + } + else if(imageDataType == IMAGE_DATA_TYPE_INT_ARRAY) { + GLenum intType = GL_UNSIGNED_INT_8_8_8_8; + GLboolean forceAlphaToOne = GL_FALSE; + + switch (imageFormat) { + /* GL_BGR */ + case IMAGE_FORMAT_INT_BGR: /* Assume XBGR format */ + oglFormat = GL_RGBA; + intType = GL_UNSIGNED_INT_8_8_8_8_REV; + forceAlphaToOne = GL_TRUE; + break; + case IMAGE_FORMAT_INT_RGB: /* Assume XRGB format */ + forceAlphaToOne = GL_TRUE; + /* Fall through to next case */ + case IMAGE_FORMAT_INT_ARGB: + oglFormat = GL_BGRA; + intType = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + /* This method only supports 3 and 4 components formats and INT types. */ + case IMAGE_FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_BYTE_BGR: + case IMAGE_FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_ABGR: + default: + throwAssert(env, "readRaster : imageFormat illegal format"); + return; + } + + /* Force Alpha to 1.0 if needed */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 0.0f); + glPixelTransferf(GL_ALPHA_BIAS, 1.0f); + } + + glReadPixels(xOffset, yAdjusted, wRaster, hRaster, + oglFormat, intType, imageObjPtr); + + /* Restore Alpha scale and bias */ + if(forceAlphaToOne) { + glPixelTransferf(GL_ALPHA_SCALE, 1.0f); + glPixelTransferf(GL_ALPHA_BIAS, 0.0f); + } + } + else { + throwAssert(env, "readRaster : illegal image data type"); + return; + } + + (*(table->ReleasePrimitiveArrayCritical))(env, imageBuffer, imageObjPtr, 0); + } + + if ((type & javax_media_j3d_Raster_RASTER_DEPTH) != 0) { + GLenum depthType = 0; + depthObjPtr = + (void *)(*(table->GetPrimitiveArrayCritical))(env, (jarray)depthBuffer, NULL); + + if (depthFormat == javax_media_j3d_DepthComponentRetained_DEPTH_COMPONENT_TYPE_INT) { + depthType = GL_UNSIGNED_INT; + } else { /* javax_media_j3d_DepthComponentRetained_DEPTH_COMPONENT_TYPE_FLOAT */ + depthType = GL_FLOAT; + } + + /* yOffset is adjusted for OpenGL - Y upward */ + glReadPixels(xOffset, yAdjusted, wRaster, hRaster, + GL_DEPTH_COMPONENT, depthType , depthObjPtr); + + (*(table->ReleasePrimitiveArrayCritical))(env, depthBuffer, depthObjPtr, 0); + } + +} + JNIEXPORT -void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( - JNIEnv *env, jobject obj, jlong ctxInfo, +void JNICALL Java_javax_media_j3d_NativePipeline_readRasterNative( + JNIEnv *env, jobject obj, jlong ctx, jint type, jint xOffset, jint yOffset, jint wRaster, jint hRaster, jint hCanvas, - jint format, jobject image, jobject depth, jobject ctx) -{ + jint format, jobject image, jobject depth, jobject gc) +{ JNIEnv table; int yAdjusted; - jclass ctx_class; + jclass gc_class; GLenum gltype; - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - jlong d3dctx = ctxProperties->context; + GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctx; table = *env; @@ -39,7 +181,7 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( glPixelStorei(GL_PACK_ALIGNMENT, 1); yAdjusted = hCanvas - hRaster - yOffset; - ctx_class = (jclass) (*(table->GetObjectClass))(env, ctx); + gc_class = (jclass) (*(table->GetObjectClass))(env, gc); if ((type & javax_media_j3d_Raster_RASTER_COLOR) != 0) { @@ -50,8 +192,8 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( jbyte *byteData; byteData_field = (jfieldID)(*(table->GetFieldID))(env, - ctx_class, "byteBuffer","[B"); - byteData_array = (jarray)(*(table->GetObjectField))(env, ctx, + gc_class, "byteBuffer","[B"); + byteData_array = (jarray)(*(table->GetObjectField))(env, gc, byteData_field); image_class = (jclass) (*(table->GetObjectClass))(env, image); @@ -61,30 +203,28 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( } switch (format) { - case FORMAT_BYTE_RGBA: + case IMAGE_FORMAT_BYTE_RGBA: gltype = GL_RGBA; break; - case FORMAT_BYTE_RGB: + case IMAGE_FORMAT_BYTE_RGB: gltype = GL_RGB; break; - case FORMAT_BYTE_ABGR: + case IMAGE_FORMAT_BYTE_ABGR: if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ gltype = GL_ABGR_EXT; } break; - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - gltype = ctxProperties->bgr_ext_enum; - } + case IMAGE_FORMAT_BYTE_BGR: + gltype = GL_BGR; break; - case FORMAT_BYTE_LA: + case IMAGE_FORMAT_BYTE_LA: gltype = GL_LUMINANCE_ALPHA; break; - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: + case IMAGE_FORMAT_BYTE_GRAY: + case IMAGE_FORMAT_USHORT_GRAY: default: throwAssert(env, "illegal format"); break; @@ -139,8 +279,8 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( jint *intData; intData_field = (jfieldID)(*(table->GetFieldID))(env, - ctx_class, "intBuffer","[I"); - intData_array = (jarray)(*(table->GetObjectField))(env, ctx, + gc_class, "intBuffer","[I"); + intData_array = (jarray)(*(table->GetObjectField))(env, gc, intData_field); intData = (jint *)(*(table->GetPrimitiveArrayCritical))(env, @@ -158,8 +298,8 @@ void JNICALL Java_javax_media_j3d_GraphicsContext3D_readRasterNative( jfloat *floatData; floatData_field = (jfieldID)(*(table->GetFieldID))(env, - ctx_class, "floatBuffer","[F"); - floatData_array = (jarray)(*(table->GetObjectField))(env, ctx, + gc_class, "floatBuffer","[F"); + floatData_array = (jarray)(*(table->GetObjectField))(env, gc, floatData_field); floatData = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, floatData_array, NULL); diff --git a/src/native/ogl/Lights.c b/src/native/ogl/Lights.c index db0c54f..2acece8 100644 --- a/src/native/ogl/Lights.c +++ b/src/native/ogl/Lights.c @@ -27,9 +27,9 @@ const float black[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; JNIEXPORT -void JNICALL Java_javax_media_j3d_DirectionalLightRetained_updateLight( +void JNICALL Java_javax_media_j3d_NativePipeline_updateDirectionalLight( JNIEnv *env, - jobject light, + jobject obj, jlong ctxInfo, jint lightSlot, jfloat red, @@ -70,9 +70,9 @@ void JNICALL Java_javax_media_j3d_DirectionalLightRetained_updateLight( } JNIEXPORT -void JNICALL Java_javax_media_j3d_PointLightRetained_updateLight( +void JNICALL Java_javax_media_j3d_NativePipeline_updatePointLight( JNIEnv *env, - jobject light, + jobject obj, jlong ctxInfo, jint lightSlot, jfloat red, @@ -114,9 +114,9 @@ void JNICALL Java_javax_media_j3d_PointLightRetained_updateLight( } JNIEXPORT -void JNICALL Java_javax_media_j3d_SpotLightRetained_updateLight( +void JNICALL Java_javax_media_j3d_NativePipeline_updateSpotLight( JNIEnv *env, - jobject light, + jobject obj, jlong ctxInfo, jint lightSlot, jfloat red, diff --git a/src/native/ogl/MasterControl.c b/src/native/ogl/MasterControl.c index 2ca2b08..027b640 100644 --- a/src/native/ogl/MasterControl.c +++ b/src/native/ogl/MasterControl.c @@ -72,7 +72,7 @@ extern int isExtensionSupported(const char *allExtensions, const char *extension); JNIEXPORT jboolean JNICALL -Java_javax_media_j3d_MasterControl_initializeJ3D( +Java_javax_media_j3d_NativePipeline_initializeJ3D( JNIEnv *env, jobject obj, jboolean disableXinerama) { jboolean glIsMTSafe = JNI_TRUE; @@ -164,84 +164,8 @@ DWORD countBits(DWORD mask) #endif /* WIN32 */ -/* - * Class: javax_media_j3d_MasterControl - * Method: getNumberOfProcessor - * Signature: ()I - * - * This function get the number of active processor in the system - */ -JNIEXPORT jint JNICALL Java_javax_media_j3d_MasterControl_getNumberOfProcessor - (JNIEnv *env, jobject obj) -{ -#if defined(UNIX) - return sysconf(_SC_NPROCESSORS_ONLN); -#endif /* UNIX_ */ - -#ifdef WIN32 - SYSTEM_INFO sysInfo; - - GetSystemInfo(&sysInfo); - return countBits(sysInfo.dwActiveProcessorMask); -#endif /* WIN32 */ -} - - -/* - * Class: javax_media_j3d_MasterControl - * Method: getThreadConcurrency - * Signature: ()I - */ -JNIEXPORT jint JNICALL -Java_javax_media_j3d_MasterControl_getThreadConcurrency(JNIEnv *env, - jobject obj) -{ - /* - * Return the number of concurrent threads that can be run, - * -1 if unknown. - */ - -#ifdef SOLARIS - return (jint) thr_getconcurrency(); -#endif /* SOLARIS */ - -#ifdef LINUX - return -1; -#endif /* LINUX */ - -#ifdef WIN32 - return -1; -#endif /* WIN32 */ -} - - -/* - * Class: javax_media_j3d_MasterControl - * Method: setThreadConcurrency - * Signature: (I)V - */ -JNIEXPORT void JNICALL -Java_javax_media_j3d_MasterControl_setThreadConcurrency(JNIEnv *env, - jobject obj, - jint newLevel) -{ -#ifdef SOLARIS - thr_setconcurrency((int)newLevel); -#endif /* SOLARIS */ - -#ifdef WIN32 - /* No-op on windows */ -#endif /* WIN32 */ - -#ifdef LINUX - /* No-op on linux */ -#endif /* LINUX */ -} - - - JNIEXPORT -jint JNICALL Java_javax_media_j3d_MasterControl_getMaximumLights( +jint JNICALL Java_javax_media_j3d_NativePipeline_getMaximumLights( JNIEnv *env, jobject obj ) { @@ -258,86 +182,3 @@ jint JNICALL Java_javax_media_j3d_MasterControl_getMaximumLights( return 8; #endif /* LINUX */ } - - -/* ======================================================================= */ - -/* - * The following method implements a high-resolution timer (based on the - * native code in the J3DTimer class). It will no longer be needed once - * we drop support for JDK 1.4.2, at which time it will be replaced by - * a call to System.nanoTime(). - */ - -#define NSEC_PER_SEC ((jlong)1000000000) - -#ifdef __linux__ -#include <sys/time.h> -#include <time.h> -#include <unistd.h> -#endif - -#ifdef SOLARIS -#include <time.h> -#include <sys/systeminfo.h> -#include <string.h> -#ifndef CLOCK_HIGHRES -#define CLOCK_HIGHRES 4 /* Solaris 7 does not define this */ -#endif /* constant. When run on Solaris 7 */ -#endif /* CLOCK_HIGHRES is not used. */ - -#ifdef WIN32 -#include <Windows.h> -#include <math.h> -static double timerScale = -1.0; -#endif - -/* - * Class: javax_media_j3d_MasterControl - * Method: getNativeTimerValue - * Signature: ()J - */ -JNIEXPORT jlong JNICALL -Java_javax_media_j3d_MasterControl_getNativeTimerValue(JNIEnv *env, jclass clazz) -{ - jlong timerNsec; - -#ifdef SOLARIS - /* - struct timespec tp; - clock_gettime( CLOCK_HIGHRES, &tp ); - - return (jlong)tp.tv_nsec + (jlong)tp.tv_sec * NSEC_PER_SEC; - */ - - timerNsec = (jlong)gethrtime(); -#endif /* SOLARIS */ - -#ifdef WIN32 - LARGE_INTEGER time; - LARGE_INTEGER freq; - - if (timerScale < 0.0) { - QueryPerformanceFrequency( &freq ); - if (freq.QuadPart <= 0) { - timerScale = 0.0; - } - else { - timerScale = (double) NSEC_PER_SEC / (double)freq.QuadPart; - } - } - - QueryPerformanceCounter(&time); - timerNsec = (jlong)((double)time.QuadPart * timerScale); - -#endif /* WIN32 */ - -#ifdef __linux__ - struct timeval t; - - gettimeofday(&t, 0); - timerNsec = ((jlong)t.tv_sec) * NSEC_PER_SEC + ((jlong)t.tv_usec) * ((jlong)1000); -#endif /* __linux__ */ - - return timerNsec; -} diff --git a/src/native/ogl/NativeAPIInfo.c b/src/native/ogl/NativeAPIInfo.c deleted file mode 100644 index 47dff76..0000000 --- a/src/native/ogl/NativeAPIInfo.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -/* - * Portions of this code were derived from work done by the Blackdown - * group (www.blackdown.org), who did the initial Linux implementation - * of the Java 3D API. - */ - -#include <jni.h> - -#include "javax_media_j3d_MasterControl.h" -#include "javax_media_j3d_NativeAPIInfo.h" - -JNIEXPORT -jint JNICALL Java_javax_media_j3d_NativeAPIInfo_getRenderingAPI( - JNIEnv *env, jobject obj) -{ -#ifdef WIN32 - return (jint)javax_media_j3d_MasterControl_RENDER_OPENGL_WIN32; -#endif /* WIN32 */ - -#ifdef SOLARIS - return (jint)javax_media_j3d_MasterControl_RENDER_OPENGL_SOLARIS; -#endif /* SOLARIS */ - -#ifdef LINUX - return (jint)javax_media_j3d_MasterControl_RENDER_OPENGL_LINUX; -#endif /* LINUX */ -} diff --git a/src/native/ogl/NativeConfigTemplate3D.c b/src/native/ogl/NativeConfigTemplate3D.c index 9241c05..2d7ace7 100644 --- a/src/native/ogl/NativeConfigTemplate3D.c +++ b/src/native/ogl/NativeConfigTemplate3D.c @@ -617,23 +617,6 @@ jboolean JNICALL Java_javax_media_j3d_NativeConfigTemplate3D_isSceneAntialiasing return JNI_FALSE; } - - -JNIEXPORT -jboolean JNICALL Java_javax_media_j3d_J3dGraphicsConfig_isValidVisualID( - JNIEnv *env, - jclass cls, - jlong display, - jint vid) -{ - XVisualInfo template; - int nitems; - - template.visualid = vid; - XGetVisualInfo((Display *)display, VisualIDMask, &template, &nitems); - return (nitems == 1); - -} #endif /* UNIX_ */ diff --git a/src/native/ogl/NativeWSInfo.c b/src/native/ogl/NativeWSInfo.c deleted file mode 100644 index aa44776..0000000 --- a/src/native/ogl/NativeWSInfo.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -/* - * Portions of this code were derived from work done by the Blackdown - * group (www.blackdown.org), who did the initial Linux implementation - * of the Java 3D API. - */ - -#include <jni.h> -#include <math.h> - -#include "gldefs.h" - -#if defined(UNIX) -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> -#endif - -#ifdef WIN32 -#include <windows.h> -#endif - -#ifdef WIN32 - -/* - * Workaround for bug 4169320: Resizing a Java 3D canvas - * on Win95 crashes the application - */ - -#ifdef STRICT -static WNDPROC g_lpDefWindowProc; -#else -static FARPROC g_lpDefWindowProc; -#endif - -static -LRESULT CALLBACK canvas3dWndProc( - HWND hWnd, - UINT message, - WPARAM wParam, - LPARAM lParam) -{ - switch (message) { - case WM_WINDOWPOSCHANGED: - return 0; - default: - return CallWindowProc(g_lpDefWindowProc, hWnd, message, - wParam, lParam); - } -} - -JNIEXPORT -void JNICALL Java_javax_media_j3d_NativeWSInfo_subclass( - JNIEnv * env, - jobject obj, - jint hWnd) -{ -#ifdef STRICT - g_lpDefWindowProc = (WNDPROC) SetWindowLong((HWND) hWnd, GWL_WNDPROC, - (LONG) canvas3dWndProc); -#else - g_lpDefWindowProc = (FARPROC) SetWindowLong((HWND) hWnd, GWL_WNDPROC, - (LONG) canvas3dWndProc); -#endif -} - -#endif diff --git a/src/native/ogl/RasterRetained.c b/src/native/ogl/RasterRetained.c deleted file mode 100644 index 2f54146..0000000 --- a/src/native/ogl/RasterRetained.c +++ /dev/null @@ -1,398 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - -#include <stdio.h> -#include <jni.h> - -#include "gldefs.h" - -#ifdef DEBUG -/* Uncomment the following for VERBOSE debug messages */ -/* #define VERBOSE */ -#endif /* DEBUG */ - - -extern void throwAssert(JNIEnv *env, char *str); - - -JNIEXPORT -void JNICALL Java_javax_media_j3d_RasterRetained_execute(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, - jboolean updateAlpha, jfloat alpha, - jint type, jint w_raster, jint h_raster, - jint x_offset, jint y_offset, jfloat x, jfloat y, jfloat z, jbyteArray imageYdown) - - -{ - jclass geo_class; - JNIEnv table; - - jfieldID w_field, h_field; - int width, height; - - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - jlong ctx = ctxProperties->context; - - table = *env; - - geo_class = (jclass) (*(table->GetObjectClass))(env, geo); - -#ifdef VERBOSE - fprintf(stderr, - "x %g ,y %g ,z %g ,w_raster %d,h_raster %d, x_offset %d, y_offset %d\n", - x,y,z,w_raster,h_raster,x_offset,y_offset); -#endif - - if ((type == javax_media_j3d_Raster_RASTER_COLOR) || - (type == javax_media_j3d_Raster_RASTER_COLOR_DEPTH)) { - jobject image; - jclass image_class; - jfieldID image_field, format_field; - jbyte *byteData; - int format; - int glformat; - - image_field = (jfieldID)(*(table->GetFieldID))(env, geo_class, - "image","Ljavax/media/j3d/ImageComponent2DRetained;"); - image = (jobject) (*(table->GetObjectField))(env, geo, image_field); - - if (image == NULL) { - return; - } - image_class = (jclass) (*(table->GetObjectClass))(env, image); - - format_field = (jfieldID) (*(table->GetFieldID))(env, image_class, - "storedYdownFormat", "I"); - format = (jint)(*(table->GetIntField))(env, image, format_field); - w_field = (jfieldID) (*(table->GetFieldID))(env, image_class, - "width", "I"); - width = (jint)(*(table->GetIntField))(env, image, w_field); - h_field = (jfieldID)(*(table->GetFieldID))(env, image_class, - "height", "I"); - height = (jint)(*(table->GetIntField))(env, image, h_field); - - - /* - * raster position is upper left corner, default for Java3D - * ImageComponent currently has the data reverse in Y - */ - glPixelZoom(1.0, -1.0); - glPixelStorei(GL_UNPACK_ROW_LENGTH, width); - if (x_offset >= 0) { - glPixelStorei(GL_UNPACK_SKIP_PIXELS, x_offset); - if (x_offset + w_raster > width) { - w_raster = width - x_offset; - } - } else { - w_raster += x_offset; - if (w_raster > width) { - w_raster = width; - } - } - if (y_offset >= 0) { - glPixelStorei(GL_UNPACK_SKIP_ROWS, y_offset); - if (y_offset + h_raster > height) { - h_raster = height - y_offset; - } - } else { - h_raster += y_offset; - if (h_raster > height) { - h_raster = height; - } - } - - - - glRasterPos3f(x, y, z); - - byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, - imageYdown, NULL); - -/* - { - int i, j, *intData; - - fprintf(stderr, "format = %d, w_raster = %d, h_raster = %d\n\n", format, w_raster, h_raster); - intData = (int*)byteData; - for (i = 0; i < w_raster; i++) { - for (j = 0; j < h_raster; j++, intData++) { - fprintf(stderr, " 0x%x", *intData); - } - fprintf(stderr, "\n"); - } - } - */ - switch (format) { - case FORMAT_BYTE_RGBA: - glformat = GL_RGBA; - break; - case FORMAT_BYTE_RGB: - glformat = GL_RGB; - break; - - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - glformat = GL_ABGR_EXT; - } - break; - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - glformat = ctxProperties->bgr_ext_enum; - } - break; - case FORMAT_BYTE_LA: - glformat = GL_LUMINANCE_ALPHA; - break; - - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: - default: - throwAssert(env, "illegal format"); - break; - } - glDrawPixels(w_raster, h_raster, glformat, GL_UNSIGNED_BYTE, - byteData); - - (*(table->ReleasePrimitiveArrayCritical))(env, - imageYdown, byteData, 0); - } - - if ((type == javax_media_j3d_Raster_RASTER_DEPTH) || - (type == javax_media_j3d_Raster_RASTER_COLOR_DEPTH)) { - GLint draw_buf; - jobject depth; - jclass depth_class; - jfieldID depth_field, depth_type_field; - int depth_type; - - depth_field = (jfieldID)(*(table->GetFieldID))(env, geo_class, - "depthComponent","Ljavax/media/j3d/DepthComponentRetained;"); - - depth = (jobject) (*(table->GetObjectField))(env, geo, depth_field); - if (depth == NULL) { - return; - } - depth_class = (jclass) (*(table->GetObjectClass))(env, depth); - - depth_type_field = (jfieldID) (*(table->GetFieldID))(env, - depth_class, "type", "I"); - depth_type = (jint)(*(table->GetIntField))(env, depth, - depth_type_field); - - w_field = (jfieldID) (*(table->GetFieldID))(env, depth_class, - "width", "I"); - width = (jint)(*(table->GetIntField))(env, depth, w_field); - h_field = (jfieldID)(*(table->GetFieldID))(env, depth_class, - "height", "I"); - height = (jint)(*(table->GetIntField))(env, depth, h_field); - - - glGetIntegerv(GL_DRAW_BUFFER, &draw_buf); - /* disable draw buffer */ - glDrawBuffer(GL_NONE); - /* glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); */ - - /* - * raster position is upper left corner, default for Java3D - * ImageComponent currently has the data reverse in Y - */ - glPixelStorei(GL_UNPACK_ROW_LENGTH, width); - if (x_offset >= 0) { - glPixelStorei(GL_UNPACK_SKIP_PIXELS, x_offset); - if (x_offset + w_raster > width) { - w_raster = width - x_offset; - } - } else { - w_raster += x_offset; - if (w_raster > width) { - w_raster = width; - } - } - if (y_offset >= 0) { - glPixelStorei(GL_UNPACK_SKIP_ROWS, y_offset); - if (y_offset + h_raster > height) { - h_raster = height - y_offset; - } - } else { - h_raster += y_offset; - if (h_raster > height) { - h_raster = height; - } - } - - - if (depth_type == javax_media_j3d_DepthComponentRetained_DEPTH_COMPONENT_TYPE_INT) { - jfieldID intData_field; - jintArray intData_array; - jint *intData; - - intData_field = (jfieldID)(*(table->GetFieldID))(env, - depth_class, "depthData","[I"); - - intData_array = (jintArray)(*(table->GetObjectField))(env, depth, - intData_field); - intData = (jint *)(*(table->GetPrimitiveArrayCritical))(env, - intData_array, NULL); - glDrawPixels(w_raster, h_raster, GL_DEPTH_COMPONENT, - GL_UNSIGNED_INT, intData); - (*(table->ReleasePrimitiveArrayCritical))(env, intData_array, - intData, 0); - } else { /* javax_media_j3d_DepthComponentRetained_DEPTH_COMPONENT_TYPE_FLOAT */ - jfieldID floatData_field; - jfloatArray floatData_array; - jfloat *floatData; - - floatData_field = (jfieldID)(*(table->GetFieldID))(env, - depth_class, "depthData","[F"); - floatData_array = (jfloatArray)(*(table->GetObjectField))(env, depth, - floatData_field); - floatData = (jfloat *)(*(table->GetPrimitiveArrayCritical))(env, - floatData_array, NULL); - glDrawPixels(w_raster, h_raster, GL_DEPTH_COMPONENT, - GL_FLOAT, floatData); - (*(table->ReleasePrimitiveArrayCritical))(env, floatData_array, - floatData, 0); - } - - /* re-enable draw buffer */ - glDrawBuffer(draw_buf); - - } - glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - -} - - -#if 0 - -JNIEXPORT -void JNICALL Java_javax_media_j3d_RasterRetained_executeTiled(JNIEnv *env, - jobject obj, jlong ctxInfo, jobject geo, - jint format, jint w_raster, jint h_raster, - jint x_offset, jint y_offset, jint deltaw, jint deltah, jfloat x, jfloat y, jfloat z, jbyteArray tile) - - -{ - jclass geo_class; - JNIEnv table; - jint j; - int alphaChanged = 0; /* used so we can get alpha data from */ - /* JNI before using it so we can use */ - /* GetPrimitiveArrayCritical */ - jobject image; - jclass image_class; - jfieldID byteData_field, image_field, format_field; - jbyteArray byteData_array; - jbyte *byteData; - int glformat; - float rasterPos[3]; - GraphicsContextPropertiesInfo *ctxProperties = (GraphicsContextPropertiesInfo *)ctxInfo; - jlong ctx = ctxProperties->context; - - table = *env; - - -#ifdef VERBOSE - fprintf(stderr, - "x %g ,y %g ,z %g ,w_raster %d,h_raster %d, x_offset %d, y_offset %d\n", - x,y,z,w_raster,h_raster,x_offset,y_offset); -#endif - - - /* - * raster position is upper left corner, default for Java3D - * ImageComponent currently has the data reverse in Y - */ - glPixelZoom(1.0, -1.0); - /* glPixelStorei(GL_UNPACK_ROW_LENGTH, width);*/ - if (x_offset >= 0) { - glPixelStorei(GL_UNPACK_SKIP_PIXELS, x_offset); - if (x_offset + w_raster > width) { - w_raster = width - x_offset; - } - } else { - w_raster += x_offset; - if (w_raster > width) { - w_raster = width; - } - } - if (y_offset >= 0) { - glPixelStorei(GL_UNPACK_SKIP_ROWS, y_offset); - if (y_offset + h_raster > height) { - h_raster = height - y_offset; - } - } else { - h_raster += y_offset; - if (h_raster > height) { - h_raster = height; - } - } - - if (deltaw == 0 && deltah == 0) { - glRasterPos3f(x, y, z); - } - else { - glGetFloatv(GL_CURRENT_RASTER_POSITION,rasterPos); - rasterPos[0] += (float)deltaw; - rasterPos[1] += (float)deltah; - glRasterPos3f(rasterPos[0], rasterPos[1], rasterPos[2]); - } - - - - byteData = (jbyte *)(*(table->GetPrimitiveArrayCritical))(env, - tile, NULL); - switch (format) { - case FORMAT_BYTE_RGBA: - glformat = GL_RGBA; - break; - case FORMAT_BYTE_RGB: - glformat = GL_RGB; - break; - - case FORMAT_BYTE_ABGR: - if (ctxProperties->abgr_ext) { /* If its zero, should never come here! */ - glformat = GL_ABGR_EXT; - } - break; - - - case FORMAT_BYTE_BGR: - if (ctxProperties->bgr_ext) { /* If its zero, should never come here! */ - glformat = ctxProperties->bgr_ext_enum; - } - break; - - case FORMAT_BYTE_LA: - glformat = GL_LUMINANCE_ALPHA; - break; - case FORMAT_BYTE_GRAY: - case FORMAT_USHORT_GRAY: - default: - throwAssert(env, "illegal format"); - break; - } - fprintf(stderr, "w_raster = %d, h_raster = %d, glformat = %d\n",w_raster, h_raster, glformat); - glDrawPixels(w_raster, h_raster, glformat, GL_UNSIGNED_BYTE, - byteData); - - (*(table->ReleasePrimitiveArrayCritical))(env, - tile, byteData, 0); - - /* glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);*/ - glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); - glPixelStorei(GL_UNPACK_SKIP_ROWS, 0); - -} -#endif diff --git a/src/native/ogl/build-linux-amd64.xml b/src/native/ogl/build-linux-amd64.xml index 9510591..c4a1e1a 100644 --- a/src/native/ogl/build-linux-amd64.xml +++ b/src/native/ogl/build-linux-amd64.xml @@ -38,12 +38,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-m64 -march=k8 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} ${bldFlag} -DLINUX ${cflags.cg} -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-m64 -march=k8 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} ${bldFlag} -DLINUX ${cflags.cg} -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/X11R6/lib64 -ldl -lGL -lX11 -lXext -lm -lnsl -lc -L${java.home}/lib/amd64 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/X11R6/lib64 -ldl -lGL -lX11 -lXext -lm -lnsl -lc -L${java.home}/lib/amd64 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> </exec> </target> diff --git a/src/native/ogl/build-linux-i586.xml b/src/native/ogl/build-linux-i586.xml index d47b155..a1d8c9f 100644 --- a/src/native/ogl/build-linux-i586.xml +++ b/src/native/ogl/build-linux-i586.xml @@ -38,12 +38,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-w -m32 -mcpu=i386 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} ${bldFlag} -DLINUX ${cflags.cg} -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-w -m32 -mcpu=i386 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} ${bldFlag} -DLINUX ${cflags.cg} -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -L${java.home}/lib/i386 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -L${java.home}/lib/i386 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> </exec> </target> diff --git a/src/native/ogl/build-linux-ia64.xml b/src/native/ogl/build-linux-ia64.xml index 28c924d..12903b5 100644 --- a/src/native/ogl/build-linux-ia64.xml +++ b/src/native/ogl/build-linux-ia64.xml @@ -35,15 +35,16 @@ <!-- Compile the c source files; based on build-linux-amd64.xml--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-I${oglsrc} -I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} ${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-I${oglsrc} -I${java.home}/../include -I${java.home}/../include/linux -I${javahCoreTarget} ${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file; based on build-linux-amd64.xml--> <!-- Must use gcc to link, not ld, hence also need -shared; refer to http://www.gelato.unsw.edu.au/linux-ia64/0006/0212.html --> <!-- Removed -R/usr/openwin/lib - an ld specific option (should be a filename, not a dir?!?) --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -shared -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -L${java.home}/lib/ia64 -ljawt -L${java.home}/lib/ia64/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -shared -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -L${java.home}/lib/ia64 -ljawt -L${java.home}/lib/ia64/jrockit -ljvm -o libj3dcore-ogl.so"/> </exec> +<!-- -L${java.home}/lib/ia64/server -ljvm -o libj3dcore-ogl.so"/> --> <!-- Copy the copyright library file --> <copy file="${build}/${platform}/${bldType}/native/ogl/objs/libj3dcore-ogl.so" diff --git a/src/native/ogl/build-linux-ppc.xml b/src/native/ogl/build-linux-ppc.xml index 8cea9f6..daef73b 100644 --- a/src/native/ogl/build-linux-ppc.xml +++ b/src/native/ogl/build-linux-ppc.xml @@ -13,7 +13,7 @@ */ --> -<!-- Ant file for building native ogl renderer files for Solaris --> +<!-- Ant file for building native ogl renderer files for Linux PPC --> <project name="Java 3D" default="compile"> <target name="compile"> @@ -36,12 +36,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-w -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/linux -I/usr/X11R6/include -I${javahCoreTarget} ${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/CompressedGeometryRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-w -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/linux -I/usr/X11R6/include -I${javahCoreTarget} ${bldFlag} -DLINUX -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o CompressedGeometryRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -R/usr/openwin/lib -L${java.home}/bin -ljawt -L${java.home}/bin/classic -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/X11R6/lib -ldl -lGL -lX11 -lXext -lm -lnsl -lc -R/usr/openwin/lib -L${java.home}/bin -ljawt -L${java.home}/bin/classic -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-solaris-sparc-forte.xml b/src/native/ogl/build-solaris-sparc-forte.xml index 28f9bf6..7ef8c46 100644 --- a/src/native/ogl/build-solaris-sparc-forte.xml +++ b/src/native/ogl/build-solaris-sparc-forte.xml @@ -30,12 +30,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cc"> - <arg line="-v -xCC -xchip=ultra -xarch=v8a -xcode=pic32 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-v -xCC -xchip=ultra -xarch=v8a -xcode=pic32 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/sparc -L${java.home}/lib/sparc/motif21 -ljawt -L${java.home}/lib/sparc/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/openwin/lib -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/sparc -L${java.home}/lib/sparc/motif21 -ljawt -L${java.home}/lib/sparc/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> @@ -51,12 +51,12 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/sparcv9" executable="cc"> - <arg line="-v -xCC -xchip=ultra -xarch=v9a -xcode=pic32 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-v -xCC -xchip=ultra -xarch=v9a -xcode=pic32 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/sparcv9" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/sparcv9 -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/sparcv9 -L${java.home}/lib/sparcv9 -L${java.home}/lib/sparcv9/motif21 -ljawt -L${java.home}/lib/sparcv9/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/openwin/lib/sparcv9 -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/sparcv9 -L${java.home}/lib/sparcv9 -L${java.home}/lib/sparcv9/motif21 -ljawt -L${java.home}/lib/sparcv9/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-solaris-sparc-gcc.xml b/src/native/ogl/build-solaris-sparc-gcc.xml index d759268..e69ad28 100644 --- a/src/native/ogl/build-solaris-sparc-gcc.xml +++ b/src/native/ogl/build-solaris-sparc-gcc.xml @@ -30,12 +30,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-w -m32 -mcpu=v9 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-w -m32 -mcpu=v9 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/sparc -L${java.home}/lib/sparc/motif21 -ljawt -L${java.home}/lib/sparc/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/openwin/lib -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/sparc -L${java.home}/lib/sparc/motif21 -ljawt -L${java.home}/lib/sparc/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> @@ -51,12 +51,12 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/sparcv9" executable="gcc"> - <arg line="-m64 -mcpu=v9 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-m64 -mcpu=v9 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/sparcv9" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/sparcv9 -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/sparcv9 -L${java.home}/lib/sparcv9 -L${java.home}/lib/sparcv9/motif21 -ljawt -L${java.home}/lib/sparcv9/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/openwin/lib/sparcv9 -ldga -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/sparcv9 -L${java.home}/lib/sparcv9 -L${java.home}/lib/sparcv9/motif21 -ljawt -L${java.home}/lib/sparcv9/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-solaris-x86-forte.xml b/src/native/ogl/build-solaris-x86-forte.xml index 7a36050..ac56d67 100644 --- a/src/native/ogl/build-solaris-x86-forte.xml +++ b/src/native/ogl/build-solaris-x86-forte.xml @@ -30,12 +30,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cc"> - <arg line="-v -xCC -xchip=pentium3 -xarch=generic -KPIC -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-v -xCC -xchip=pentium3 -xarch=generic -KPIC -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -L${java.home}/lib/i386/motif21 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/openwin/lib -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -L${java.home}/lib/i386/motif21 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> @@ -58,12 +58,12 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64" executable="cc"> - <arg line="-v -xCC -xchip=opteron -xarch=generic64 -KPIC -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-v -xCC -xchip=opteron -xarch=generic64 -KPIC -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/amd64 -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/amd64 -L${java.home}/lib/amd64 -L${java.home}/lib/amd64/motif21 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/openwin/lib/amd64 -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/amd64 -L${java.home}/lib/amd64 -L${java.home}/lib/amd64/motif21 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-solaris-x86-gcc.xml b/src/native/ogl/build-solaris-x86-gcc.xml index cfa20ba..7676b5d 100644 --- a/src/native/ogl/build-solaris-x86-gcc.xml +++ b/src/native/ogl/build-solaris-x86-gcc.xml @@ -30,12 +30,12 @@ <!-- Compile the c source files--> <!-- Inhibit all warning for 32 bit build. Any warning will be caught in the 64 bit build --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-w -m32 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-w -m32 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -L${java.home}/lib/i386/motif21 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/openwin/lib -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib -L${java.home}/lib/i386 -L${java.home}/lib/i386/motif21 -ljawt -L${java.home}/lib/i386/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> @@ -58,12 +58,12 @@ <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64" executable="gcc"> - <arg line="-m64 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeWSInfo.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/RasterRetained.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c ${oglsrc}/NativeAPIInfo.c"/> + <arg line="-m64 -I${oglsrc} -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahCoreTarget} ${bldFlag} -DSOLARIS -c ${oglsrc}/DrawingSurfaceObjectAWT.c ${oglsrc}/Canvas3D.c ${oglsrc}/GraphicsContext3D.c ${oglsrc}/NativeScreenInfo.c ${oglsrc}/NativeConfigTemplate3D.c ${oglsrc}/MasterControl.c ${oglsrc}/GeometryArrayRetained.c ${oglsrc}/Attributes.c ${oglsrc}/CgShaderProgram.c ${oglsrc}/GLSLShaderProgram.c ${oglsrc}/Lights.c"/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs/amd64" executable="ld"> - <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -G -z defs -L/usr/openwin/lib/amd64 -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/amd64 -L${java.home}/lib/amd64 -L${java.home}/lib/amd64/motif21 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> + <arg line="DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -G -z defs -L/usr/openwin/lib/amd64 -ldl -lGL -lX11 -lXext -lm -lsocket -lnsl -lc -R/usr/openwin/lib/amd64 -L${java.home}/lib/amd64 -L${java.home}/lib/amd64/motif21 -ljawt -L${java.home}/lib/amd64/server -ljvm -o libj3dcore-ogl.so"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-windows-amd64-vc.xml b/src/native/ogl/build-windows-amd64-vc.xml new file mode 100644 index 0000000..91d038b --- /dev/null +++ b/src/native/ogl/build-windows-amd64-vc.xml @@ -0,0 +1,108 @@ +<?xml version="1.0"?> + +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. + * + * Use is subject to license terms. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<!-- +/* 1. define the following property to change the location of the CG library: + * + * ant -Dcg.home="path-to-cg-installation" + */ + --> + +<!-- Ant file for building native ogl renderer files for Windows-amd64 --> +<project name="Java 3D" default="compile"> + + + + <target name="init" depends="init-cg,init-nocg"> + <!-- Create the build directories for win32 --> + <mkdir dir="${build}/${platform}/${bldType}/native/ogl/objs"/> + <mkdir dir="${build}/${platform}/${bldType}/bin"/> + + <echo message="Executing 64 bit native renderer build [${bldType}]"/> + + <property name="javaInclude" + location="${java.home}/../include"/> + + <property name="javaWin32Include" + location="${java.home}/../include/win32"/> + + <property name="oglsrc" location="${src}/native/ogl"/> + </target> + + <target name="init-cg" if="build.cg"> + <property name="cflags.cg" value="-DCOMPILE_CG_SHADERS=1"/> + <property name="cg.home" location="c:/Program Files/NVIDIA Corporation/Cg"/> + </target> + + <target name="init-nocg" unless="build.cg"> + <property name="cflags.cg" value=""/> + <property name="cg.home" value=""/> + </target> + + <target name="compile-ogl"> + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cl"> + <arg line="-I"${oglsrc}" -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" -I"${cg.home}\include" -nologo -MT -W3 -EHsc -wd4996 -Ox -FD ${bldFlag} ${cflags.cg} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/CgShaderProgram.c" "${oglsrc}/GLSLShaderProgram.c" "${oglsrc}/Lights.c""/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="link"> + <arg line="-nologo -dll -subsystem:windows -pdb:none -out:j3dcore-ogl.dll DrawingSurfaceObjectAWT.obj Canvas3D.obj GraphicsContext3D.obj NativeScreenInfo.obj NativeConfigTemplate3D.obj MasterControl.obj GeometryArrayRetained.obj Attributes.obj CgShaderProgram.obj GLSLShaderProgram.obj Lights.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib delayimp.lib -DELAYLOAD:jawt.dll -LIBPATH:"${java.home}\..\lib" jawt.lib"/> + </exec> + + </target> + + + <target name="compile-ogl-cg" if="build.cg"> + <!-- Compile the c source files--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cl"> + <arg line="-I"${oglsrc}" -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" -I"${cg.home}\include" -nologo -MT -W3 -EHsc -Ox -FD ${bldFlag} ${cflags.cg} -c "${oglsrc}/CgWrapper.c""/> + </exec> + + <!-- Create the library file--> + <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="link"> + <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 -out:j3dcore-ogl-cg.dll CgWrapper.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib delayimp.lib -LIBPATH:"${cg.home}\lib" cg.lib cgGL.lib"/> + </exec> + + </target> + + + + <target name="compile" depends="init,compile-ogl,compile-ogl-cg"> + + <!-- Copy the library file --> + <copy todir="${build}/${platform}/${bldType}/bin"> + <fileset dir="${build}/${platform}/${bldType}/native/ogl/objs" + includes="j3dcore-ogl*.dll" + /> + </copy> + + </target> + + <target name="dist"> + <!-- Create the distribution directory --> + <mkdir dir="${dist}/${platform}/bin"/> + + <!-- Copy the library files --> + <copy todir="${dist}/${platform}/bin"> + <fileset dir="${build}/${platform}/opt/bin" + includes="j3dcore-ogl*.dll" + /> + </copy> + + </target> + +</project> diff --git a/src/native/ogl/build-windows-i586-gcc.xml b/src/native/ogl/build-windows-i586-gcc.xml index 976bcc1..8307d92 100644 --- a/src/native/ogl/build-windows-i586-gcc.xml +++ b/src/native/ogl/build-windows-i586-gcc.xml @@ -52,12 +52,12 @@ <!-- Inhibit all warning for native build. Remove -w to switch warning on --> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-w -D_WINGDI_ -D_JNI_IMPLEMENTATION_ -I"${oglsrc}" -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" ${bldFlag} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeWSInfo.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/RasterRetained.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/CgShaderProgram.c" "${oglsrc}/GLSLShaderProgram.c" "${oglsrc}/Lights.c" "${oglsrc}/NativeAPIInfo.c""/> + <arg line="-w -D_WINGDI_ -D_JNI_IMPLEMENTATION_ -I"${oglsrc}" -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" ${bldFlag} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/CgShaderProgram.c" "${oglsrc}/GLSLShaderProgram.c" "${oglsrc}/Lights.c""/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="gcc"> - <arg line="-shared -o j3dcore-ogl.dll DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeWSInfo.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o RasterRetained.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o NativeAPIInfo.o -Wl,--kill-at -L"${java.home}\..\lib" -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lopengl32 -ljawt"/> + <arg line="-shared -o j3dcore-ogl.dll DrawingSurfaceObjectAWT.o Canvas3D.o GraphicsContext3D.o NativeScreenInfo.o NativeConfigTemplate3D.o MasterControl.o GeometryArrayRetained.o Attributes.o CgShaderProgram.o GLSLShaderProgram.o Lights.o -Wl,--kill-at -L"${java.home}\..\lib" -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lopengl32 -ljawt"/> </exec> <!-- Copy the copyright library file --> diff --git a/src/native/ogl/build-windows-i586-vc.xml b/src/native/ogl/build-windows-i586-vc.xml index d1a49ac..8e62417 100644 --- a/src/native/ogl/build-windows-i586-vc.xml +++ b/src/native/ogl/build-windows-i586-vc.xml @@ -55,12 +55,12 @@ <target name="compile-ogl"> <!-- Compile the c source files--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="cl"> - <arg line="-I"${oglsrc}" -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" -I"${cg.home}\include" -nologo -MT -W3 -GX -Ox -YX -FD ${bldFlag} ${cflags.cg} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeWSInfo.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/RasterRetained.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/CgShaderProgram.c" "${oglsrc}/GLSLShaderProgram.c" "${oglsrc}/Lights.c" "${oglsrc}/NativeAPIInfo.c""/> + <arg line="-I"${oglsrc}" -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahCoreTarget}" -I"${cg.home}\include" -nologo -MT -W3 -GX -Ox -YX -FD ${bldFlag} ${cflags.cg} -c "${oglsrc}/DrawingSurfaceObjectAWT.c" "${oglsrc}/Canvas3D.c" "${oglsrc}/GraphicsContext3D.c" "${oglsrc}/NativeScreenInfo.c" "${oglsrc}/NativeConfigTemplate3D.c" "${oglsrc}/MasterControl.c" "${oglsrc}/GeometryArrayRetained.c" "${oglsrc}/Attributes.c" "${oglsrc}/CgShaderProgram.c" "${oglsrc}/GLSLShaderProgram.c" "${oglsrc}/Lights.c""/> </exec> <!-- Create the library file--> <exec dir="${build}/${platform}/${bldType}/native/ogl/objs" executable="link"> - <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 -out:j3dcore-ogl.dll DrawingSurfaceObjectAWT.obj Canvas3D.obj GraphicsContext3D.obj NativeWSInfo.obj NativeScreenInfo.obj NativeConfigTemplate3D.obj MasterControl.obj RasterRetained.obj GeometryArrayRetained.obj Attributes.obj CgShaderProgram.obj GLSLShaderProgram.obj Lights.obj NativeAPIInfo.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib delayimp.lib -DELAYLOAD:jawt.dll -LIBPATH:"${java.home}\..\lib" jawt.lib"/> + <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 -out:j3dcore-ogl.dll DrawingSurfaceObjectAWT.obj Canvas3D.obj GraphicsContext3D.obj NativeScreenInfo.obj NativeConfigTemplate3D.obj MasterControl.obj GeometryArrayRetained.obj Attributes.obj CgShaderProgram.obj GLSLShaderProgram.obj Lights.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib delayimp.lib -DELAYLOAD:jawt.dll -LIBPATH:"${java.home}\..\lib" jawt.lib"/> </exec> </target> diff --git a/src/native/ogl/gldefs.h b/src/native/ogl/gldefs.h index 7112a79..e278f1d 100644 --- a/src/native/ogl/gldefs.h +++ b/src/native/ogl/gldefs.h @@ -109,7 +109,6 @@ #include "javax_media_j3d_ColoringAttributes.h" #include "javax_media_j3d_ColoringAttributesRetained.h" #include "javax_media_j3d_DepthComponentRetained.h" -#include "javax_media_j3d_DetailTextureImage.h" #include "javax_media_j3d_DirectionalLightRetained.h" #include "javax_media_j3d_DisplayListRenderMethod.h" #include "javax_media_j3d_DrawingSurfaceObjectAWT.h" @@ -129,8 +128,8 @@ #include "javax_media_j3d_Material.h" #include "javax_media_j3d_MaterialRetained.h" #include "javax_media_j3d_ModelClipRetained.h" -#include "javax_media_j3d_NativeAPIInfo.h" #include "javax_media_j3d_NativeConfigTemplate3D.h" +#include "javax_media_j3d_NativePipeline.h" #include "javax_media_j3d_NodeRetained.h" #include "javax_media_j3d_PointAttributesRetained.h" #include "javax_media_j3d_PointLightRetained.h" @@ -162,24 +161,6 @@ #include "javax_media_j3d_ShaderAttributeObjectRetained.h" #include "javax_media_j3d_ShaderError.h" -/* - * Define these constants here as a workaround for conflicting - * glext.h files between Mesa and Solaris - */ - -#ifndef GL_CLAMP_TO_BORDER_SGIS -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_VIDEO_RESIZE_COMPENSATION_SUN -#define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD -#endif - -/* - * End constant workaround - */ - - /* Used to compare floating point values close to 0.0 */ #define J3D_SMALL_FLOAT 0.00001f @@ -265,13 +246,21 @@ /* now the imagecomponent formats are reduced the ones below */ -#define FORMAT_BYTE_RGBA javax_media_j3d_ImageComponentRetained_BYTE_RGBA -#define FORMAT_BYTE_ABGR javax_media_j3d_ImageComponentRetained_BYTE_ABGR -#define FORMAT_BYTE_GRAY javax_media_j3d_ImageComponentRetained_BYTE_GRAY -#define FORMAT_USHORT_GRAY javax_media_j3d_ImageComponentRetained_USHORT_GRAY -#define FORMAT_BYTE_LA javax_media_j3d_ImageComponentRetained_BYTE_LA -#define FORMAT_BYTE_BGR javax_media_j3d_ImageComponentRetained_BYTE_BGR -#define FORMAT_BYTE_RGB javax_media_j3d_ImageComponentRetained_BYTE_RGB +#define IMAGE_FORMAT_BYTE_BGR javax_media_j3d_ImageComponentRetained_TYPE_BYTE_BGR +#define IMAGE_FORMAT_BYTE_RGB javax_media_j3d_ImageComponentRetained_TYPE_BYTE_RGB +#define IMAGE_FORMAT_BYTE_ABGR javax_media_j3d_ImageComponentRetained_TYPE_BYTE_ABGR +#define IMAGE_FORMAT_BYTE_RGBA javax_media_j3d_ImageComponentRetained_TYPE_BYTE_RGBA +#define IMAGE_FORMAT_BYTE_LA javax_media_j3d_ImageComponentRetained_TYPE_BYTE_LA +#define IMAGE_FORMAT_BYTE_GRAY javax_media_j3d_ImageComponentRetained_TYPE_BYTE_GRAY +#define IMAGE_FORMAT_USHORT_GRAY javax_media_j3d_ImageComponentRetained_TYPE_USHORT_GRAY +#define IMAGE_FORMAT_INT_BGR javax_media_j3d_ImageComponentRetained_TYPE_INT_BGR +#define IMAGE_FORMAT_INT_RGB javax_media_j3d_ImageComponentRetained_TYPE_INT_RGB +#define IMAGE_FORMAT_INT_ARGB javax_media_j3d_ImageComponentRetained_TYPE_INT_ARGB + +#define IMAGE_DATA_TYPE_BYTE_ARRAY javax_media_j3d_ImageComponentRetained_IMAGE_DATA_TYPE_BYTE_ARRAY +#define IMAGE_DATA_TYPE_INT_ARRAY javax_media_j3d_ImageComponentRetained_IMAGE_DATA_TYPE_INT_ARRAY +#define IMAGE_DATA_TYPE_BYTE_BUFFER javax_media_j3d_ImageComponentRetained_IMAGE_DATA_TYPE_BYTE_BUFFER +#define IMAGE_DATA_TYPE_INT_BUFFER javax_media_j3d_ImageComponentRetained_IMAGE_DATA_TYPE_INT_BUFFER /* These match the definitions in GeometryArray.java */ @@ -360,53 +349,7 @@ - #ifndef D3D -#if defined(UNIX) -extern void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -extern void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -extern void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -extern void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -extern void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -extern void APIENTRY glMultiDrawArraysSUN (GLenum, GLint *, GLsizei *, GLsizei); -extern void APIENTRY glMultiDrawElementsEXT (GLenum, GLsizei *, GLenum, const GLvoid**, GLsizei); -extern void APIENTRY glMultiDrawElementsSUN (GLenum, GLsizei *, GLenum, const GLvoid**, GLsizei); -extern void APIENTRY glLockArraysEXT (GLint first, GLsizei count); -extern void APIENTRY glUnlockArraysEXT (void); - - -extern void APIENTRY glClientActiveTextureARB (GLenum); -extern void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -extern void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -extern void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -extern void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -extern void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -extern void APIENTRY glActiveTextureARB (GLenum); -extern void APIENTRY glSharpenTexFuncSGIS(GLenum, GLsizei, const GLfloat *); -extern void APIENTRY glDetailTexFuncSGIS(GLenum, GLsizei, const GLfloat *); -extern void APIENTRY glTexFilterFuncSGIS(GLenum, GLenum, GLsizei, const GLfloat *); -extern void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -extern void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -extern void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -extern void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -extern void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -extern void APIENTRY glCombinerParameteriNV (GLenum, GLint); - -extern void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -extern void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); - - - -#ifndef GLX_SUN_video_resize -#define GLX_SUN_video_resize 1 -extern int glXVideoResizeSUN( Display *, GLXDrawable, float); -#endif - -#endif /* UNIX_ */ #ifndef APIENTRY #define APIENTRY @@ -420,18 +363,18 @@ typedef void (APIENTRY * MYPFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green typedef void (APIENTRY * MYPFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); typedef void (APIENTRY * MYPFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); typedef void (APIENTRY * MYPFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRY * MYPFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRY * MYPFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRY * MYPFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); typedef void (APIENTRY * MYPFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum, GLsizei *, GLenum, const GLvoid**, GLsizei); typedef void (APIENTRY * MYPFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); typedef void (APIENTRY * MYPFNGLUNLOCKARRAYSEXTPROC) (void); -typedef void (APIENTRY * MYPFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * MYPFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * MYPFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRY * MYPFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRY * MYPFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRY * MYPFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRY * MYPFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * MYPFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * MYPFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRY * MYPFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRY * MYPFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRY * MYPFNGLACTIVETEXTUREPROC) (GLenum texture); typedef void (APIENTRY * MYPFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRY * MYPFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); @@ -450,7 +393,6 @@ typedef void (APIENTRY * MYPFNGLTEXFILTERFUNCSGI) (GLenum target, GLenum filter, #if defined(UNIX) typedef GLXFBConfig * (APIENTRY * MYPFNGLXCHOOSEFBCONFIG) (Display *dpy, int screen, const int *attrib_list, int *nelements); -typedef int (APIENTRY * MYPFNGLXVIDEORESIZESUN) (Display * dpy, GLXDrawable draw, float factor); #endif /* UNIX_ */ @@ -491,41 +433,15 @@ struct GraphicsContextPropertiesInfoRec { char *rendererStr; char *extensionStr; int versionNumbers[2]; - - /* both in 1.2 core part and 1.1 extensions */ - /* GL_EXT_rescale_normal or GL_RESCALE_NORMAL */ - jboolean rescale_normal_ext; - GLenum rescale_normal_ext_enum; - - /* GL_BGR_EXT or GL_BGR */ - jboolean bgr_ext; - GLenum bgr_ext_enum; - - /* GL_EXT_texture3D or GL_TEXTURE3D */ - jboolean texture3DAvailable; - GLenum texture_3D_ext_enum; - GLenum texture_wrap_r_ext_enum; + jboolean gl13; /* OpenGL 1.3 or greater */ + jboolean gl20; /* OpenGL 2.0 or greater */ /* GL_ARB_imaging subset */ /* GL_EXT_blend_color or GL_BLEND_COLOR */ jboolean blend_color_ext; GLenum blendFunctionTable[MAX_BLEND_FUNC_TABLE_SIZE]; - - /* GL_SGI_color_table or GL_COLOR_TABLE */ - jboolean color_table_ext; - - /* GL_EXT_separate_specular_color */ - jboolean seperate_specular_color; - GLenum light_model_color_control_enum; - GLenum single_color_enum; - GLenum seperate_specular_color_enum; - - /* GL_CLAMP_TO_EDGE or GL_EXT_texture_edge_clamp or - GL_SGIS_texture_edge_clamp */ - GLenum texture_clamp_to_edge_enum; - - /* GL_SGIS_texture_lod */ + /* texture_lod */ jboolean textureLodAvailable; GLenum texture_min_lod_enum; GLenum texture_max_lod_enum; @@ -533,22 +449,17 @@ struct GraphicsContextPropertiesInfoRec { GLenum texture_max_level_enum; - /* ***********1.1 extension or 1.2 extensions ********************/ + /* ***** GL extensions ***** */ - /* GL_ARB_texture_border_clamp or GL_SGIS_texture_border_clamp */ + /* GL_CLAMP_TO_BORDER or GL_CLAMP */ GLenum texture_clamp_to_border_enum; /* GL_SUN_multi_draw_arrays */ jboolean multi_draw_arrays_sun; - /* GLX_SUN_video_resize */ - jboolean videoResizeAvailable; - /* GL_SUN_global_alpha */ jboolean global_alpha_sun; - /* GL_SUNX_constant_data */ - jboolean constant_data_sun; - + /* GL_EXT_abgr */ jboolean abgr_ext; /* GL_EXT_multi_draw_arrays */ @@ -557,11 +468,7 @@ struct GraphicsContextPropertiesInfoRec { /* GL_EXT_compiled_vertex_array */ jboolean compiled_vertex_array_ext; - /* GL_ARB_transpose_matrix */ - jboolean arb_transpose_matrix; - - /* GL_ARB_multitexture */ - jboolean arb_multitexture; + /* Multitexture parameters */ int maxTexCoordSets; /* maximum number of texture coordinate sets */ int maxTextureUnits; /* number of fixed-function texture units */ int maxTextureImageUnits; /* number of fragment shader texture units */ @@ -593,13 +500,8 @@ struct GraphicsContextPropertiesInfoRec { GLenum combine_dot3_rgb_enum; GLenum combine_dot3_rgba_enum; - /* GL_ARB_texture_cube_map */ - /* GL_EXT_texture_cube_map */ - jboolean textureCubeMapAvailable; - GLenum texture_cube_map_ext_enum; - - /* GL_ARB_mulitsample */ - jboolean arb_multisample; + /* GL mulitsample functionality */ + jboolean multisample; /* By default, full scene antialiasing is disable if @@ -647,6 +549,9 @@ struct GraphicsContextPropertiesInfoRec { /* GL_SGIX_texture_lod_bias */ jboolean textureLodBiasAvailable; + /* GL_ARB_texture_non_power_of_two */ + jboolean textureNonPowerOfTwoAvailable; + /* extension mask */ jint extMask; jint textureExtMask; @@ -658,17 +563,17 @@ struct GraphicsContextPropertiesInfoRec { MYPFNGLGETCOLORTABLEPARAMETERIVPROC glGetColorTableParameteriv; MYPFNGLTEXIMAGE3DPROC glTexImage3DEXT; MYPFNGLTEXSUBIMAGE3DPROC glTexSubImage3DEXT; - MYPFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB; - MYPFNGLACTIVETEXTUREARBPROC glActiveTextureARB; + MYPFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture; + MYPFNGLACTIVETEXTUREPROC glActiveTexture; MYPFNGLMULTIDRAWARRAYSEXTPROC glMultiDrawArraysEXT; MYPFNGLMULTIDRAWELEMENTSEXTPROC glMultiDrawElementsEXT; MYPFNGLLOCKARRAYSEXTPROC glLockArraysEXT; MYPFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT; - MYPFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB; - MYPFNGLMULTITEXCOORD3FVARBPROC glMultiTexCoord3fvARB; - MYPFNGLMULTITEXCOORD4FVARBPROC glMultiTexCoord4fvARB; - MYPFNGLLOADTRANSPOSEMATRIXDARBPROC glLoadTransposeMatrixdARB; - MYPFNGLMULTTRANSPOSEMATRIXDARBPROC glMultTransposeMatrixdARB; + MYPFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv; + MYPFNGLMULTITEXCOORD3FVPROC glMultiTexCoord3fv; + MYPFNGLMULTITEXCOORD4FVPROC glMultiTexCoord4fv; + MYPFNGLLOADTRANSPOSEMATRIXDPROC glLoadTransposeMatrixd; + MYPFNGLMULTTRANSPOSEMATRIXDPROC glMultTransposeMatrixd; MYPFNGLGLOBALALPHAFACTORFSUNPROC glGlobalAlphaFactorfSUN; MYPFNGLCOMBINERINPUTNV glCombinerInputNV; @@ -683,10 +588,6 @@ struct GraphicsContextPropertiesInfoRec { MYPFNGLDETAILTEXFUNCSGI glDetailTexFuncSGIS; MYPFNGLTEXFILTERFUNCSGI glTexFilterFuncSGIS; -#if defined(UNIX) - MYPFNGLXVIDEORESIZESUN glXVideoResizeSUN; -#endif /* UNIX_ */ - /* Shading language support */ jboolean shadingLanguageGLSL; jboolean shadingLanguageCg; diff --git a/src/native/share/build-linux-amd64.xml b/src/native/share/build-linux-amd64.xml deleted file mode 100644 index 7380e32..0000000 --- a/src/native/share/build-linux-amd64.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Linux --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 64 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories linux --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/amd64"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-m64 -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/amd64"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/lib/amd64"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/lib/amd64/libj3dutils.so" - todir="${dist}/${platform}/lib/amd64"/> - </target> - - -</project> diff --git a/src/native/share/build-linux-i586.xml b/src/native/share/build-linux-i586.xml deleted file mode 100644 index 657f2b7..0000000 --- a/src/native/share/build-linux-i586.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Linux --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 32 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories linux --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/i386"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-m32 -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/i386"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/lib/i386"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/lib/i386/libj3dutils.so" - todir="${dist}/${platform}/lib/i386"/> - </target> - - -</project> diff --git a/src/native/share/build-linux-ia64.xml b/src/native/share/build-linux-ia64.xml deleted file mode 100644 index 47e4677..0000000 --- a/src/native/share/build-linux-ia64.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Linux --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 64 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories linux --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/ia64"/> - - <!-- Compile the c source files; based on build-linux-amd64.xml--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line=" -I/include -I${java.home}/../include -I${java.home}/../include/linux -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file; based on build-linux-amd64.xml--> - <!-- Must use gcc to link, not ld, hence also need -shared; refer to http://www.gelato.unsw.edu.au/linux-ia64/0006/0212.html --> - <!-- Removed -R/usr/openwin/lib - an ld specific option (should be a filename, not a dir?!?) --> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="J3DTimer.o -G -z lazyload -lc -shared -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/ia64"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/lib/ia64"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/lib/ia64/libj3dutils.so" - todir="${dist}/${platform}/lib/ia64"/> - </target> - - -</project> diff --git a/src/native/share/build-linux-ppc.xml b/src/native/share/build-linux-ppc.xml deleted file mode 100644 index bd9fa0a..0000000 --- a/src/native/share/build-linux-ppc.xml +++ /dev/null @@ -1,54 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Linux --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 64 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories linux --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/bin"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-I/include -I${java.home}/../include -I${java.home}/../include/linux -I${javahUtilsTarget} ${bldFlag} -DLINUX -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" - todir="${build}/${platform}/${bldType}/bin"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/bin"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/bin/libj3dutils.so" - todir="${dist}/${platform}/bin"/> - </target> - - -</project> diff --git a/src/native/share/build-solaris-sparc-forte.xml b/src/native/share/build-solaris-sparc-forte.xml deleted file mode 100644 index 5bc0cfc..0000000 --- a/src/native/share/build-solaris-sparc-forte.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Solaris --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 32 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories sparc --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/sparc"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="cc"> - <arg line="-v -xCC -xchip=ultra -xarch=v8a -xcode=pic32 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/sparc"/> - -<!-- ********************************************************************** --> - <echo message="Executing 64 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories sparcv9 --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs/sparcv9"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/sparcv9"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs/sparcv9" executable="cc"> - <arg line="-v -xCC -xchip=ultra -xarch=v9a -xcode=pic32 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs/sparcv9" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/sparcv9/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/sparcv9"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/lib/sparc"/> - <mkdir dir="${dist}/${platform}/lib/sparcv9"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/lib/sparc/libj3dutils.so" - todir="${dist}/${platform}/lib/sparc"/> - - <copy file="${build}/${platform}/opt/lib/sparcv9/libj3dutils.so" - todir="${dist}/${platform}/lib/sparcv9"/> - </target> - - -</project> diff --git a/src/native/share/build-solaris-sparc-gcc.xml b/src/native/share/build-solaris-sparc-gcc.xml deleted file mode 100644 index 5f0f790..0000000 --- a/src/native/share/build-solaris-sparc-gcc.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Solaris --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 32 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories sparc --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/sparc"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-m32 -mcpu=v9 -mtune=v9 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/sparc"/> - -<!-- ********************************************************************** --> - <echo message="Executing 64 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories sparcv9 --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs/sparcv9"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/sparcv9"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs/sparcv9" executable="gcc"> - <arg line="-m64 -mcpu=v9 -mtune=v9 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs/sparcv9" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/sparcv9/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/sparcv9"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/lib/sparc"/> - <mkdir dir="${dist}/${platform}/lib/sparcv9"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/lib/sparc/libj3dutils.so" - todir="${dist}/${platform}/lib/sparc"/> - - <copy file="${build}/${platform}/opt/lib/sparcv9/libj3dutils.so" - todir="${dist}/${platform}/lib/sparcv9"/> - </target> - - -</project> diff --git a/src/native/share/build-solaris-x86-forte.xml b/src/native/share/build-solaris-x86-forte.xml deleted file mode 100644 index 44bd2ec..0000000 --- a/src/native/share/build-solaris-x86-forte.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Solaris --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 32 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories i386 --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/i386"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="cc"> - <arg line="-v -xCC -xchip=pentium3 -xarch=generic -KPIC -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/i386"/> - - <!-- - /* - * TODO: only do the 64-bit build if isSolarisOnX86_64 property is - * set, indicating that a 64-bit JVM is available - */ - --> - -<!-- ********************************************************************** --> - <echo message="Executing 64 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories amd64 --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs/amd64"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/amd64"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs/amd64" executable="cc"> - <arg line="-v -xCC -xchip=opteron -xarch=amd64 -KPIC -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs/amd64" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/amd64/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/amd64"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/lib/i386"/> - <mkdir dir="${dist}/${platform}/lib/amd64"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/lib/i386/libj3dutils.so" - todir="${dist}/${platform}/lib/i386"/> - - <copy file="${build}/${platform}/opt/lib/amd64/libj3dutils.so" - todir="${dist}/${platform}/lib/amd64"/> - </target> - - -</project> diff --git a/src/native/share/build-solaris-x86-gcc.xml b/src/native/share/build-solaris-x86-gcc.xml deleted file mode 100644 index e21142b..0000000 --- a/src/native/share/build-solaris-x86-gcc.xml +++ /dev/null @@ -1,86 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Solaris --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 32 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories i386 --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/i386"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-m32 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/i386"/> - - <!-- - /* - * TODO: only do the 64-bit build if isSolarisOnX86_64 property is - * set, indicating that a 64-bit JVM is available - */ - --> - -<!-- ********************************************************************** --> - <echo message="Executing 64 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories amd64 --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs/amd64"/> - <mkdir dir="${build}/${platform}/${bldType}/lib/amd64"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs/amd64" executable="gcc"> - <arg line="-m64 -I/include -I${java.home}/../include -I${java.home}/../include/solaris -I/usr/openwin/include -I${javahUtilsTarget} ${bldFlag} -DSOLARIS -c ${core_utils_src}/native/share/J3DTimer.c"/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs/amd64" executable="ld"> - <arg line="J3DTimer.o -G -z lazyload -lposix4 -lc -o libj3dutils.so"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/amd64/libj3dutils.so" - todir="${build}/${platform}/${bldType}/lib/amd64"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/lib/i386"/> - <mkdir dir="${dist}/${platform}/lib/amd64"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/lib/i386/libj3dutils.so" - todir="${dist}/${platform}/lib/i386"/> - - <copy file="${build}/${platform}/opt/lib/amd64/libj3dutils.so" - todir="${dist}/${platform}/lib/amd64"/> - </target> - - -</project> diff --git a/src/native/share/build-windows-i586-gcc.xml b/src/native/share/build-windows-i586-gcc.xml deleted file mode 100644 index 2e1fbe5..0000000 --- a/src/native/share/build-windows-i586-gcc.xml +++ /dev/null @@ -1,63 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Windows-i586 --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 32 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories sparc --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/bin"/> - - <property name="javaInclude" - location="${java.home}/../include"/> - - <property name="javaWin32Include" - location="${java.home}/../include/win32"/> - - <property name="sharesrc" - location="${core_utils_src}/native/share"/> - - <!-- Compile the c source files--> - <!-- Inhibit all warning for native build. Remove -w to switch warning on --> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-w -D_WINGDI_ -D_JNI_IMPLEMENTATION_ -I"${javaInclude}" -I"${javaWin32Include}" -I"${javahUtilsTarget}" ${bldFlag} -c "${sharesrc}/J3DTimer.c""/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="gcc"> - <arg line="-shared -o j3dutils.dll J3DTimer.o -Wl,--kill-at -L"${java.home}\..\lib" -ljawt"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/j3dutils.dll" - todir="${build}/${platform}/${bldType}/bin"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/bin"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/bin/j3dutils.dll" - todir="${dist}/${platform}/bin"/> - </target> - -</project> diff --git a/src/native/share/build-windows-i586-vc.xml b/src/native/share/build-windows-i586-vc.xml deleted file mode 100644 index 4f730af..0000000 --- a/src/native/share/build-windows-i586-vc.xml +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0"?> - -<!-- -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Use is subject to license terms. - * - * $Revision$ - * $Date$ - * $State$ - */ - --> - -<!-- Ant file for building native utilities files for Windows-i586 --> -<project name="Java 3D" default="compile"> - - <target name="compile"> - - <echo message="Executing 32 bit native utilities build [${bldType}]"/> - - <!-- Create the build directories sparc --> - <mkdir dir="${build}/${platform}/${bldType}/native/share/objs"/> - <mkdir dir="${build}/${platform}/${bldType}/bin"/> - - <property name="javaInclude" - location="${java.home}/../include"/> - - <property name="javaWin32Include" - location="${java.home}/../include/win32"/> - - <property name="sharesrc" - location="${core_utils_src}/native/share"/> - - <!-- Compile the c source files--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="cl"> - <arg line="-I"${javaInclude}" -I"${javaWin32Include}" -I"${javahUtilsTarget}" ${bldFlag} -c "${sharesrc}/J3DTimer.c""/> - </exec> - - <!-- Create the library file--> - <exec dir="${build}/${platform}/${bldType}/native/share/objs" executable="link"> - <arg line="-nologo -dll -subsystem:windows -pdb:none -machine:I386 -out:j3dutils.dll J3DTimer.obj delayimp.lib -LIBPATH:"${java.home}\..\lib" jawt.lib"/> - </exec> - - <!-- Copy the copyright library file --> - <copy file="${build}/${platform}/${bldType}/native/share/objs/j3dutils.dll" - todir="${build}/${platform}/${bldType}/bin"/> - - </target> - - <target name="dist"> - <!-- Create the distribution directory --> - <mkdir dir="${dist}/${platform}/bin"/> - - <!-- Copy the library files --> - <copy file="${build}/${platform}/opt/bin/j3dutils.dll" - todir="${dist}/${platform}/bin"/> - </target> - -</project> |