diff options
17 files changed, 42 insertions, 3071 deletions
diff --git a/make/build-common.xml b/make/build-common.xml index 876aa27ce..29faaef20 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -124,9 +124,12 @@ </condition> <echo message="swt.jar=${swt.jar}" /> - <property name="target.sourcelevel" value="1.4" /> + <property name="target.sourcelevel" value="1.5" /> <property name="host.sourcelevel" value="1.5" /> + <!-- property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" /--> + <property name="javadoc.link" value="http://download.oracle.com/javase/1.5.0/docs/api/" /> + <!-- NOTE: the value of the debug and optimise attributes will not be overridden if already set externally --> <property name="javacdebug" value="true" /> <property name="javacdebuglevel" value="source,lines" /> @@ -140,9 +143,6 @@ and need exact string matching, which is why they use file.separator instead of "/". --> - <property name="javac.bootclasspath-cdc.jar" value="${gluegen.root}/make/lib/cdc_fp.jar"/> - <echo message="javac.bootclasspath-cdc.jar: ${javac.bootclasspath-cdc.jar}" /> - <!-- NOTE that these require a checked-out GlueGen, etc workspace as a --> <!-- sibling of the JOGL workspace. --> <property name="gluegen.make" value="${gluegen.root}/make" /> @@ -292,32 +292,6 @@ <pathelement location="${newt.all-noawt.jar}" /> </path> - <!-- CDC combinations . NO.AWT --> - <property name="gluegen-rt.cdc.jar" value="${build.gluegen}/gluegen-rt.cdc.jar" /> - <property name="gluegen-gl.cdc.jar" value="${build.jogl}/gluegen-gl.cdc.jar" /> - - <property name="nativewindow.all.cdc.jar" value="${build.nativewindow}/nativewindow.all.cdc.jar" /> - <property name="jogl.all.cdc.jar" value="${build.jogl}/jogl.all.cdc.jar" /> - <property name="newt.all.cdc.jar" value="${build.newt}/newt.all.cdc.jar" /> - - <path id="nativewindow_gluegen.classpath-cdc"> - <pathelement location="${gluegen-rt.cdc.jar}" /> - <pathelement location="${nativewindow.all.cdc.jar}" /> - </path> - - <path id="nativewindow_gluegen_jogl.classpath-cdc"> - <pathelement location="${gluegen-rt.cdc.jar}" /> - <pathelement location="${nativewindow.all.cdc.jar}" /> - <pathelement location="${jogl.all.cdc.jar}" /> - </path> - - <path id="jogl_newt_all.classpath-cdc"> - <pathelement location="${gluegen-rt.cdc.jar}" /> - <pathelement location="${nativewindow.all.cdc.jar}" /> - <pathelement location="${jogl.all.cdc.jar}" /> - <pathelement location="${newt.all.cdc.jar}" /> - </path> - <!-- Atomic JavaSE JARS --> <property name="nativewindow.core.jar" value="${build.nativewindow}/nativewindow.core.jar" /> @@ -361,33 +335,6 @@ <property name="newt.hw.broadcomegl.jar" value="${build.newt}/newt.hw.broadcomegl.jar" /> <property name="newt.hw.intelgdl.jar" value="${build.newt}/newt.hw.intelgdl.jar" /> - <!-- Atomic CDC JARS --> - <property name="nativewindow.core.cdc.jar" value="${build.nativewindow}/nativewindow.core.cdc.jar" /> - <property name="nativewindow.os.x11.cdc.jar" value="${build.nativewindow}/nativewindow.os.x11.cdc.jar" /> - <property name="nativewindow.os.win.cdc.jar" value="${build.nativewindow}/nativewindow.os.win.cdc.jar" /> - - <property name="jogl.core.cdc.jar" value="${build.jogl}/jogl.core.cdc.jar" /> - <property name="jogl.gles1.cdc.jar" value="${build.jogl}/jogl.gles1.cdc.jar" /> - <property name="jogl.gles1.dbg.cdc.jar" value="${build.jogl}/jogl.gles1.dbg.cdc.jar" /> - <property name="jogl.gles2.cdc.jar" value="${build.jogl}/jogl.gles2.cdc.jar" /> - <property name="jogl.gles2.dbg.cdc.jar" value="${build.jogl}/jogl.gles2.dbg.cdc.jar" /> - <property name="jogl.egl.cdc.jar" value="${build.jogl}/jogl.egl.cdc.jar" /> - <property name="jogl.glutess.cdc.jar" value="${build.jogl}/jogl.glu.tess.cdc.jar" /> - <property name="jogl.glumipmap.cdc.jar" value="${build.jogl}/jogl.glu.mipmap.cdc.jar" /> - <property name="jogl.os.x11.cdc.jar" value="${build.jogl}/jogl.os.x11.cdc.jar" /> - <property name="jogl.os.win.cdc.jar" value="${build.jogl}/jogl.os.win.cdc.jar" /> - <property name="jogl.os.osx.cdc.jar" value="${build.jogl}/jogl.os.osx.cdc.jar" /> - <property name="jogl.util.cdc.jar" value="${build.jogl}/jogl.util.cdc.jar" /> - <property name="jogl.util.fixedfuncemu.cdc.jar" value="${build.jogl}/jogl.util.fixedfuncemu.cdc.jar" /> - - <property name="newt.core.cdc.jar" value="${build.newt}/newt.core.cdc.jar" /> - <property name="newt.os.x11.cdc.jar" value="${build.newt}/newt.os.x11.cdc.jar" /> - <property name="newt.os.win.cdc.jar" value="${build.newt}/newt.os.win.cdc.jar" /> - <property name="newt.os.osx.cdc.jar" value="${build.newt}/newt.os.osx.cdc.jar" /> - <property name="newt.ogl.cdc.jar" value="${build.newt}/newt.ogl.cdc.jar" /> - <property name="newt.hw.broadcomegl.cdc.jar" value="${build.newt}/newt.hw.broadcomegl.cdc.jar" /> - <property name="newt.hw.intelgdl.cdc.jar" value="${build.newt}/newt.hw.intelgdl.cdc.jar" /> - <!-- The location and name of the configuration ANT file that will - validate to ensure that all user-define variables are set. --> <property name="validate.user.properties" value="${make}/validate-properties.xml" /> diff --git a/make/build-jogl.xml b/make/build-jogl.xml index cfdbf75e8..a0a9c70f8 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -163,11 +163,11 @@ <property name="java.excludes.fixme" value="jogamp/opengl/gl2/fixme/** com/jogamp/audio/windows/waveout/TestSpatialization.java" /> - <property name="java.excludes.cdcfp" - value="${java.excludes.fixme} ${java.part.nv-cg} ${java.part.gldesktop} ${java.part.gldesktop.dbg} ${java.part.awt} ${java.part.glugldesktop} ${java.part.util.awt} ${java.part.util.gldesktop} com/jogamp/opengl/util/TGAWriter.java"/> + <property name="java.part.desktop" + value="${java.part.glx} ${java.part.wgl} ${java.part.cgl} ${java.excludes.fixme} ${java.part.nv-cg} ${java.part.gldesktop} ${java.part.gldesktop.dbg} ${java.part.awt} ${java.part.glugldesktop} ${java.part.util.awt} ${java.part.util.gldesktop} com/jogamp/opengl/util/TGAWriter.java"/> <condition property="java.excludes.desktop" - value="${java.part.glx} ${java.excludes.cdcfp}"> + value="${java.part.desktop}"> <isset property="setup.nodesktop"/> </condition> @@ -198,7 +198,6 @@ <!-- The generated source directories. --> <property name="src.generated" value="${build.jogl}/gensrc" /> <property name="src.generated.java" value="${src.generated}/classes" /> - <property name="src.generated.java-cdc" value="${src.generated}/classes-cdc" /> <property name="src.generated.java.cg" value="${src.generated.java}/com/jogamp/opengl/cg" /> <property name="src.generated.c" value="${src.generated}/native/jogl" /> <property name="src.generated.c.openmax" value="${src.generated}/native/openmax" /> @@ -206,7 +205,6 @@ <!-- The compiler output directories. --> <property name="classes" value="${build.jogl}/classes" /> - <property name="classes-cdc" value="${build.jogl}/classes-cdc" /> <property name="obj.joglsub" value="${obj.jogl}/jogl" /> <property name="obj.cgsub" value="${obj.jogl}/cg" /> @@ -264,7 +262,6 @@ <property name="javadoc" value="${project.root}/javadoc_jogl_public" /> <property name="javadoc.spec" value="${project.root}/javadoc_jogl_spec" /> <property name="javadoc.dev" value="${project.root}/javadoc_jogl_dev" /> - <property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" /> <property name="javadoc.windowtitle" value="JOGL API -- JSR-231 ${jogl_base_version} Specification" /> <property name="javadoc.overview" value="doc/jogl/spec-overview.html" /> <property name="javadoc.spec.packagenames" value="javax.media.opengl.*" /> @@ -294,20 +291,6 @@ <property name="gl2.headers" value="${stub.includes}/opengl/GL/*.h" /> <!-- NOTE: this MUST be relative for FileSet --> <!-- CHECK: this may need to be pruned for each platform --> </target> - <target name="setup.javacdc"> - <copy file="../src/jogl/classes/jogamp/opengl/SystemUtil.java.javame_cdc_fp" tofile="${src.generated.java-cdc}/jogamp/opengl/SystemUtil.java" /> - <copy file="../src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp" tofile="${src.generated.java-cdc}/com/jogamp/opengl/util/texture/TextureIO.java" /> - <copy file="../src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javame_cdc_fp" tofile="${src.generated.java-cdc}/com/jogamp/opengl/util/texture/spi/DDSImage.java" /> - <copy file="../src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp" tofile="${src.generated.java-cdc}/com/jogamp/opengl/util/texture/spi/TGAImage.java" /> - </target> - - <target name="setup.javase"> - <copy file="../src/jogl/classes/jogamp/opengl/SystemUtil.java.javase" tofile="${src.generated.java}/jogamp/opengl/SystemUtil.java" /> - <copy file="../src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javase" tofile="${src.generated.java}/com/jogamp/opengl/util/texture/TextureIO.java" /> - <copy file="../src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javase" tofile="${src.generated.java}/com/jogamp/opengl/util/texture/spi/DDSImage.java" /> - <copy file="../src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java.javase" tofile="${src.generated.java}/com/jogamp/opengl/util/texture/spi/TGAImage.java" /> - </target> - <!-- ================================================================== --> <!-- - Initialize all parameters required for the build and create any @@ -316,21 +299,15 @@ <target name="init" depends="declare.common, declare.gl.gles, declare.gl.gl2"> <!-- Create the required output directories. --> <mkdir dir="${src.generated.java}" /> - <mkdir dir="${src.generated.java-cdc}" /> <mkdir dir="${src.generated.c}" /> <mkdir dir="${src.generated.c}/MacOSX" /> <mkdir dir="${src.generated.c}/Windows" /> <mkdir dir="${src.generated.c}/X11" /> <mkdir dir="${src.generated.c.openmax}" /> <mkdir dir="${classes}" /> - <mkdir dir="${classes-cdc}" /> <mkdir dir="${obj.jogl}" /> <mkdir dir="${obj.joglsub}" /> <mkdir dir="${obj.cgsub}" /> - - <!-- Set up Java SE and Java CDC files --> - <antcall target="setup.javase" inheritRefs="true" /> - <antcall target="setup.javacdc" inheritRefs="true" /> </target> <!-- @@ -676,7 +653,7 @@ fork="yes" memoryMaximumSize="${javac.memorymax}" includeAntRuntime="true" - source="1.5" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> + source="${target.sourcelevel}" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="gluegen-gl.classpath"/> <src path="${src.java}" /> </javac> @@ -880,10 +857,6 @@ <arg value="${src.generated.java}/javax/media/opengl" /> <classpath refid="pipeline.classpath" /> </java> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="javax/media/opengl/DebugGLES1.java javax/media/opengl/TraceGLES1.java javax/media/opengl/DebugGL2ES1.java javax/media/opengl/TraceGL2ES1.java" /> - </copy> </target> <target name="java.generate.composable.pipeline.es2" depends="java.generate.composable.pipeline.check.es2" unless="java.generate.composable.pipeline.skip.es2"> @@ -897,10 +870,6 @@ <arg value="${src.generated.java}/javax/media/opengl" /> <classpath refid="pipeline.classpath" /> </java> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="javax/media/opengl/DebugGLES2.java javax/media/opengl/TraceGLES2.java javax/media/opengl/DebugGL2ES2.java javax/media/opengl/TraceGL2ES2.java" /> - </copy> </target> <target name="java.generate.composable.pipeline.gl2" depends="java.generate.composable.pipeline.check.gl2" unless="java.generate.composable.pipeline.skip.gl2"> @@ -914,10 +883,6 @@ <arg value="${src.generated.java}/javax/media/opengl" /> <classpath refid="pipeline.classpath" /> </java> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="javax/media/opengl/DebugGL2.java javax/media/opengl/TraceGL2.java javax/media/opengl/DebugGL2GL3.java javax/media/opengl/TraceGL2GL3.java" /> - </copy> </target> <target name="java.generate.composable.pipeline.gl3" depends="java.generate.composable.pipeline.check.gl3" unless="java.generate.composable.pipeline.skip.gl3"> @@ -926,20 +891,12 @@ <arg value="${src.generated.java}/javax/media/opengl" /> <classpath refid="pipeline.classpath" /> </java> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="javax/media/opengl/DebugGL3.java javax/media/opengl/TraceGL3.java" /> - </copy> <java classname="com.jogamp.gluegen.opengl.BuildComposablePipeline" fork="yes" failonerror="true"> <arg value="javax.media.opengl.GL3bc" /> <arg value="${src.generated.java}/javax/media/opengl" /> <classpath refid="pipeline.classpath" /> </java> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="javax/media/opengl/DebugGL3bc.java javax/media/opengl/TraceGL3bc.java" /> - </copy> </target> <target name="java.generate.composable.pipeline.gl4" depends="java.generate.composable.pipeline.check.gl4" unless="java.generate.composable.pipeline.skip.gl4"> @@ -948,20 +905,12 @@ <arg value="${src.generated.java}/javax/media/opengl" /> <classpath refid="pipeline.classpath" /> </java> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="javax/media/opengl/DebugGL4.java javax/media/opengl/TraceGL4.java" /> - </copy> <java classname="com.jogamp.gluegen.opengl.BuildComposablePipeline" fork="yes" failonerror="true"> <arg value="javax.media.opengl.GL4bc" /> <arg value="${src.generated.java}/javax/media/opengl" /> <classpath refid="pipeline.classpath" /> </java> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="javax/media/opengl/DebugGL4bc.java javax/media/opengl/TraceGL4bc.java" /> - </copy> </target> <target name="java.generate.composable.pipeline" depends="java.generate.composable.pipeline.es1, java.generate.composable.pipeline.es2, java.generate.composable.pipeline.gl2, java.generate.composable.pipeline.gl3, java.generate.composable.pipeline.gl4"> @@ -993,10 +942,6 @@ <arg value="prolog_xor_downstream" /> <classpath refid="pipeline.classpath" /> </java> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="jogamp/opengl/util/glsl/fixedfunc/FixedFuncImpl.java" /> - </copy> </target> <target name="java.generate.composable.pipeline.custom" depends="init, common.gluegen.build, java.generate.composable.pipeline.custom.glfixfunc"> </target> @@ -1015,21 +960,11 @@ fork="yes" memoryMaximumSize="${javac.memorymax}" includeAntRuntime="false" - source="1.4" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> + source="${target.sourcelevel}" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> <classpath refid="nativewindow_gluegen.classpath"/> <src path="${src.java}" /> <src path="${src.generated.java}" /> </javac> - - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="**" - excludes="com/jogamp/opengl/cg/** jogamp/opengl/gl2/** jogamp/opengl/gl3/** jogamp/opengl/gl4/** jogamp/opengl/glu/gl2/** javax/media/opengl/glu/gl2/**"/> - </copy> - <copy todir="${classes-cdc}"> - <fileset dir="${classes}" - includes="**" /> - </copy> </target> <target name="java.compile.secondpass.javase"> @@ -1047,23 +982,7 @@ </javac> </target> - <!-- bootclasspath="${javac.bootclasspath-cdc.jar}" --> - <target name="java.compile.secondpass.javacdc" unless="setup.noCDC"> - <!-- Perform the second pass Java compile; everything except portion of fixed function emulation depending on generated code. --> - <javac destdir="${classes-cdc}" - excludes="com/jogamp/opengl/util/glsl/fixedfunc/FixedFuncUtil.java,${java.excludes.all},${java.excludes.cdcfp}" - source="${target.sourcelevel}" - fork="yes" - memoryMaximumSize="${javac.memorymax}" - includeAntRuntime="false" - debug="${javacdebug}" debuglevel="${javacdebuglevel}"> - <classpath refid="nativewindow_gluegen.classpath-cdc"/> - <src path="${src.java}" /> - <src path="${src.generated.java-cdc}" /> - </javac> - </target> - - <target name="java.compile.secondpass" depends="java.generate.composable.pipeline, java.compile.secondpass.javase, java.compile.secondpass.javacdc" /> + <target name="java.compile.secondpass" depends="java.generate.composable.pipeline, java.compile.secondpass.javase" /> <target name="java.compile.thirdpass.javase"> <!-- Perform the third pass Java compile; everything including fixed function emulation. --> @@ -1080,23 +999,7 @@ </javac> </target> - <target name="java.compile.thirdpass.javacdc" unless="setup.noCDC"> - <!-- Perform the third pass Java compile; everything including fixed function emulation. --> - <javac destdir="${classes-cdc}" - excludes="${java.excludes.all},${java.excludes.cdcfp}" - source="${target.sourcelevel}" - bootclasspath="${javac.bootclasspath-cdc.jar}" - fork="yes" - memoryMaximumSize="${javac.memorymax}" - includeAntRuntime="false" - debug="${javacdebug}" debuglevel="${javacdebuglevel}"> - <classpath refid="nativewindow_gluegen.classpath-cdc"/> - <src path="${src.java}" /> - <src path="${src.generated.java-cdc}" /> - </javac> - </target> - - <target name="java.compile.thirdpass" depends="java.generate.composable.pipeline.custom, java.compile.thirdpass.javase, java.compile.thirdpass.javacdc" /> + <target name="java.compile.thirdpass" depends="java.generate.composable.pipeline.custom, java.compile.thirdpass.javase" /> <target name="java.compile" depends="java.compile.firstpass,java.compile.secondpass,java.compile.thirdpass" /> @@ -1282,7 +1185,6 @@ <target name="rename.dylib" if="isOSX"> <move file="${src}" tofile="${dest}" /> - <copy file="${dest}" tofile="${dest-cdc}" /> </target> <macrodef name="c.build"> @@ -1390,7 +1292,6 @@ <antcall target="rename.dylib" inheritRefs="true"> <param name="src" value="${build.jogl}/obj/lib@{output.lib.name}.dylib" /> <param name="dest" value="${build.jogl}/obj/lib@{output.lib.name}.jnilib" /> - <param name="dest-cdc" value="${build.jogl}/obj/lib@{output.lib.name}.so" /> </antcall> <!-- FIXME: this is a hack; the cpptask should have an option to change the @@ -1403,7 +1304,7 @@ </macrodef> <target name="c.build.jogl.prepare.openMAX" if="useOpenMAX"> - <javah destdir="${src.generated.c.openmax}" classpath="${classes-cdc}" class="com.jogamp.openmax.OMXInstance" /> + <javah destdir="${src.generated.c.openmax}" classpath="${classes}" class="com.jogamp.openmax.OMXInstance" /> </target> <target name="c.build.jogl.prepare" depends="c.build.jogl.prepare.openMAX"> @@ -1464,7 +1365,7 @@ <!-- - Build the jogl.jar files. --> - <target name="build-jars" depends="gluegen.cpptasks.detect.os,build-jars-javase,build-jars-cdc" /> + <target name="build-jars" depends="gluegen.cpptasks.detect.os,build-jars-javase" /> <target name="setup-manifestfile" depends="common.init"> <property name="manifestfile" value="joglversion"/> @@ -1480,20 +1381,6 @@ </copy> </target> - <target name="setup-manifestfile-cdc" unless="setup.noCDC" depends="common.init"> - <property name="manifestfile" value="joglversion-cdc"/> - <copy file="${manifestfile}" - tofile="${build.jogl}/tempversion-cdc" - overwrite="true"> - <filterset> - <filter token="VERSION" value="${jogl.version}"/> - <filter token="SCM_BRANCH" value="${jogl.build.branch}"/> - <filter token="SCM_COMMIT" value="${jogl.build.commit}"/> - <filter token="BASEVERSION" value="${jogl_base_version}"/> - </filterset> - </copy> - </target> - <target name="build-cg-jar-javase" depends="setup-manifestfile" if="jogl.cg"> <jar manifest="${build.jogl}/tempversion" destfile="${jogl.cg.jar}" filesonly="true"> <fileset dir="${classes}" @@ -1539,44 +1426,6 @@ </jar> </target> - <target name="build-jars-os-desktop-cdc" depends="setup-manifestfile" unless="setup.nodesktop"> - <jar manifest="${build.jogl}/tempversion" destfile="${jogl.os.x11.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" includes="${java.part.glx}"/> - </jar> - <jar manifest="${build.jogl}/tempversion" destfile="${jogl.os.win.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" includes="${java.part.wgl}" /> - </jar> - <jar manifest="${build.jogl}/tempversion" destfile="${jogl.os.osx.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" includes="${java.part.cgl}"/> - </jar> - </target> - - <target name="build-jars-es-cdc" depends="setup-manifestfile-cdc" unless="setup.noCDC"> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.egl.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.egl}" - excludes="${java.part.awt}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.gles1.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.es1}" - excludes="${java.part.es1.dbg}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.gles1.dbg.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.es1.dbg}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.gles2.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.es2} ${java.part.openmax}" - excludes="${java.part.es2.dbg}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.gles2.dbg.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.es2.dbg}"/> - </jar> - </target> - <target name="build-jars-awt-javase" depends="setup-manifestfile" unless="setup.noAWT"> <jar manifest="${build.jogl}/tempversion" destfile="${jogl.awt.jar}" filesonly="true"> <fileset dir="${classes}" @@ -1615,49 +1464,6 @@ includes="${java.part.util.fixedfuncemu.shadercode}"/> </jar> </target> - <target name="build-jars-all-cdc" depends="setup-manifestfile"> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.all.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.core} ${java.part.egl} ${java.part.glutess} ${java.part.glumipmap} ${java.part.openmax} ${java.part.sdk} ${java.part.glx} ${java.part.cgl} ${java.part.wgl} ${java.part.es1} ${java.part.es1.dbg} ${java.part.es2} ${java.part.es2.dbg} ${java.part.util} ${java.part.util.glsl} ${java.part.util.fixedfuncemu}" - excludes="${java.excludes.cdcfp}"/> - <fileset dir="${src.java}" - includes="${java.part.util.fixedfuncemu.shadercode}"/> - </jar> - </target> - - - <target name="build-jars-cdc" depends="setup-manifestfile-cdc, build-jars-es-cdc, build-jars-all-cdc" unless="setup.noCDC"> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.core.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.core}" - excludes="${java.part.core.exclude}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.glutess.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.glutess}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.glumipmap.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.glumipmap}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.util.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.util} ${java.part.util.glsl}" - excludes="${java.part.util.awt} ${java.part.util.gldesktop} ${java.part.util.fixedfuncemu}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${jogl.util.fixedfuncemu.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.util.fixedfuncemu}"/> - <fileset dir="${src.java}" - includes="${java.part.util.fixedfuncemu.shadercode}"/> - </jar> - <jar manifest="${build.jogl}/tempversion-cdc" destfile="${build.jogl}/jogl-natives-${os.and.arch}-cdc.jar" filesonly="true"> - <fileset dir="${obj.jogl}"> - <include name="*_es1.${native.library.suffix-cdc}" /> - <include name="*_es2.${native.library.suffix-cdc}" /> - </fileset> - </jar> - </target> <target name="build-jars-desktop-javase" depends="setup-manifestfile,build-jars-os-desktop-javase" unless="setup.nodesktop"> <!--os specific gldesktop--> @@ -1733,7 +1539,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" maxmemory="512m" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > @@ -1750,7 +1556,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" maxmemory="512m" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > @@ -1768,7 +1574,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc.spec}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" maxmemory="512m" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > @@ -1785,7 +1591,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc.spec}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" maxmemory="512m" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > @@ -1803,7 +1609,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc.dev}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" maxmemory="512m" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > @@ -1820,7 +1626,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc.dev}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" maxmemory="512m" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index 2ed2bca04..50ed109a2 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -118,12 +118,10 @@ <!-- The generated source directories. --> <property name="src.generated" value="${build.nativewindow}/gensrc" /> <property name="src.generated.java" value="${src.generated}/classes" /> - <property name="src.generated.java-cdc" value="${src.generated}/classes-cdc" /> <property name="src.generated.c" value="${src.generated}/native" /> <!-- The compiler output directories. --> <property name="classes" value="${build.nativewindow}/classes" /> - <property name="classes-cdc" value="${build.nativewindow}/classes-cdc" /> <!-- The headers from which Java files are generated --> <dirset id="stub.includes.fileset.all" dir="."> @@ -152,7 +150,6 @@ <property name="javadoc" value="${project.root}/javadoc_nativewindow_public" /> <property name="javadoc.spec" value="${project.root}/javadoc_nativewindow_spec" /> <property name="javadoc.dev" value="${project.root}/javadoc_nativewindow_dev" /> - <property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" /> <property name="javadoc.windowtitle" value="Native Windowing Interface (NativeWindow) API -- ${nativewindow_base_version} Specification" /> <property name="javadoc.overview" value="../src/nativewindow/classes/javax/media/nativewindow/package.html" /> <property name="javadoc.spec.packagenames" value="javax.media.nativewindow.*" /> @@ -171,13 +168,11 @@ <target name="init" depends="declare.common"> <!-- Create the required output directories. --> <mkdir dir="${src.generated.java}" /> - <mkdir dir="${src.generated.java-cdc}" /> <mkdir dir="${src.generated.c}" /> <mkdir dir="${src.generated.c}/MacOSX" /> <mkdir dir="${src.generated.c}/Windows" /> <mkdir dir="${src.generated.c}/X11" /> <mkdir dir="${classes}" /> - <mkdir dir="${classes-cdc}" /> <mkdir dir="${obj.nativewindow}" /> </target> @@ -232,10 +227,6 @@ emitter="com.jogamp.gluegen.JavaEmitter"> <classpath refid="gluegen.classpath" /> </gluegen> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="jogamp/nativewindow/x11/** jogamp/nativewindow/windows/**" /> - </copy> </target> <target name="java.generate.jawt" unless="setup.noAWT"> @@ -252,10 +243,6 @@ emitter="com.jogamp.gluegen.JavaEmitter"> <classpath refid="gluegen.classpath" /> </gluegen> - <copy todir="${src.generated.java-cdc}"> - <fileset dir="${src.generated.java}" - includes="jogamp/nativewindow/jawt/**" /> - </copy> </target> <target name="java.generate.platforms" > @@ -313,22 +300,6 @@ - Compile the original and generated source. The composable pipelines - will be generated. --> - <target name="java.compile.javacdc" depends="java.generate" unless="setup.noCDC"> - <!-- Perform the first pass Java compile; everything --> - <javac destdir="${classes-cdc}" - excludes="${java.part.awt} ${java.excludes.all}" - source="${target.sourcelevel}" - classpath="${gluegen-rt.cdc.jar}" - bootclasspath="${javac.bootclasspath-cdc.jar}" - fork="yes" - includeAntRuntime="false" - memoryMaximumSize="${javac.memorymax}" - debug="${javacdebug}" debuglevel="${javacdebuglevel}"> - <src path="${src.java}" /> - <src path="${src.generated.java-cdc}" /> - </javac> - </target> - <target name="java.compile.javase" depends="java.generate"> <!-- Perform the second pass Java compile; everything. --> <javac destdir="${classes}" @@ -344,7 +315,7 @@ </javac> </target> - <target name="java.compile" depends="java.compile.javase,java.compile.javacdc" /> + <target name="java.compile" depends="java.compile.javase" /> <!-- ================================================================== --> <!-- @@ -519,7 +490,6 @@ <target name="rename.dylib" if="isOSX"> <move file="${src}" tofile="${dest}" /> - <copy file="${dest}" tofile="${dest-cdc}" /> </target> <macrodef name="c.build"> @@ -610,7 +580,6 @@ <antcall target="rename.dylib" inheritRefs="true"> <param name="src" value="${build.nativewindow}/obj/lib@{output.lib.name}.dylib" /> <param name="dest" value="${build.nativewindow}/obj/lib@{output.lib.name}.jnilib" /> - <param name="dest-cdc" value="${build.nativewindow}/obj/lib@{output.lib.name}.so" /> </antcall> <!-- FIXME: this is a hack; the cpptask should have an option to change the @@ -682,7 +651,7 @@ <!-- - Build the nativewindow.jar files. --> - <target name="build-jars" depends="gluegen.cpptasks.detect.os,build-jars-javase,build-jars-cdc" /> + <target name="build-jars" depends="gluegen.cpptasks.detect.os,build-jars-javase" /> <target name="setup-manifestfile"> <property name="manifestfile" value="nativewindowversion"/> @@ -698,20 +667,6 @@ </copy> </target> - <target name="setup-manifestfile-cdc"> - <property name="manifestfile" value="nativewindowversion-cdc"/> - <copy file="${manifestfile}" - tofile="tempversion-cdc" - overwrite="true"> - <filterset> - <filter token="VERSION" value="${nativewindow.version}"/> - <filter token="SCM_BRANCH" value="${jogl.build.branch}"/> - <filter token="SCM_COMMIT" value="${jogl.build.commit}"/> - <filter token="BASEVERSION" value="${nativewindow_base_version}"/> - </filterset> - </copy> - </target> - <target name="build-jars-awt" depends="setup-manifestfile" unless="setup.noAWT"> <jar manifest="tempversion" destfile="${nativewindow.awt.jar}" filesonly="true"> <fileset dir="${classes}" @@ -726,12 +681,6 @@ includes="${java.part.x11}" /> </jar> </target> - <target name="build-jars-x11-cdc" depends="setup-manifestfile-cdc"> - <jar manifest="tempversion-cdc" destfile="${nativewindow.os.x11.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.x11}" /> - </jar> - </target> <target name="build-jars-windows" depends="setup-manifestfile"> <jar manifest="tempversion" destfile="${nativewindow.os.win.jar}" filesonly="true"> @@ -739,12 +688,6 @@ includes="${java.part.windows}" /> </jar> </target> - <target name="build-jars-windows-cdc" depends="setup-manifestfile-cdc"> - <jar manifest="tempversion-cdc" destfile="${nativewindow.os.win.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.windows}" /> - </jar> - </target> <target name="build-jars-all" depends="setup-manifestfile" unless="setup.noAWT"> <jar manifest="tempversion" destfile="${nativewindow.all.jar}" filesonly="true"> @@ -759,12 +702,6 @@ excludes="${java.part.awt}"/> </jar> </target> - <target name="build-jars-all-cdc" depends="setup-manifestfile-cdc"> - <jar manifest="tempversion-cdc" destfile="${nativewindow.all.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="javax/media/nativewindow/** com/jogamp/nativewindow/** jogamp/nativewindow/**" /> - </jar> - </target> <target name="build-jars-javase" depends="setup-manifestfile,build-jars-awt,build-jars-x11,build-jars-windows,build-jars-all,build-jars-all-noawt"> <jar manifest="tempversion" destfile="${nativewindow.core.jar}" filesonly="true"> @@ -780,22 +717,6 @@ <delete file="tempversion"/> </target> - <target name="build-jars-cdc" depends="setup-manifestfile-cdc,build-jars-x11-cdc,build-jars-windows-cdc,build-jars-all-cdc"> - <jar manifest="tempversion-cdc" destfile="${nativewindow.core.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.core}" - excludes="${java.part.awt} ${java.part.x11} ${java.part.windows}"/> - </jar> - <jar manifest="tempversion-cdc" destfile="${build.nativewindow}/nativewindow-natives-${os.and.arch}-cdc.jar" filesonly="true"> - <fileset dir="${obj.nativewindow}"> - <include name="*_jvm.${native.library.suffix-cdc}" /> - <include name="*_x11.${native.library.suffix-cdc}" /> - </fileset> - </jar> - - <delete file="tempversion-cdc"/> - </target> - <!-- ================================================================== --> <!-- - Build the Javadocs for the sources. @@ -808,10 +729,10 @@ <javadoc packagenames="${javadoc.packagenames}" excludepackagenames="${java.excludes.javadoc.packagenames}" sourcepath="${src.java};${src.generated.java}" - classpath="${gluegen-rt.cdc.jar}" + classpath="${gluegen-rt.jar}" destdir="${javadoc}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > </javadoc> @@ -822,10 +743,10 @@ <javadoc packagenames="${javadoc.spec.packagenames}" excludepackagenames="${java.excludes.javadoc.packagenames}" sourcepath="${src.java};${src.generated.java}" - classpath="${gluegen-rt.cdc.jar}" + classpath="${gluegen-rt.jar}" destdir="${javadoc.spec}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > </javadoc> @@ -836,10 +757,10 @@ <javadoc packagenames="${javadoc.dev.packagenames}" excludepackagenames="${java.excludes.javadoc.packagenames}" sourcepath="${src.java};${src.generated.java}" - classpath="${gluegen-rt.cdc.jar}" + classpath="${gluegen-rt.jar}" destdir="${javadoc.dev}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > </javadoc> diff --git a/make/build-newt.xml b/make/build-newt.xml index 7ad013f6c..c91a2fda1 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -122,8 +122,6 @@ <isset property="setup.noOpenGL"/> </condition> - <property name="java.excludes.cdcfp" value="${java.part.awt}"/> - <condition property="java.excludes.desktop" value="${java.part.x11} ${java.part.windows}, ${java.part.macosx}, ${java.part.awt}"> <isset property="setup.nodesktop"/> @@ -153,13 +151,11 @@ <!-- The compiler output directories. --> <property name="classes" value="${build.newt}/classes" /> - <property name="classes-cdc" value="${build.newt}/classes-cdc" /> <!-- The javadoc dirs. --> <property name="javadoc" value="${project.root}/javadoc_newt_public" /> <property name="javadoc.spec" value="${project.root}/javadoc_newt_spec" /> <property name="javadoc.dev" value="${project.root}/javadoc_newt_dev" /> - <property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" /> <property name="javadoc.windowtitle" value="NEWT API -- ${newt_base_version} Specification" /> <property name="javadoc.overview" value="spec-overview.html" /> <property name="javadoc.spec.packagenames" value="com.jogamp.newt, com.jogamp.newt.event.*, com.jogamp.newt.opengl" /> @@ -184,7 +180,6 @@ <mkdir dir="${src.generated.c}/IntelGDL" /> <mkdir dir="${src.generated.c}/BroadcomEGL" /> <mkdir dir="${classes}" /> - <mkdir dir="${classes-cdc}" /> <mkdir dir="${obj.newt}" /> </target> @@ -206,22 +201,7 @@ </javac> </target> - <target name="java.compile.javacdc" unless="setup.noCDC"> - <!-- Perform the first pass Java compile; everything --> - <javac destdir="${classes-cdc}" - excludes="${java.excludes.all} ${java.excludes.cdcfp}" - source="${target.sourcelevel}" - bootclasspath="${javac.bootclasspath-cdc.jar}" - fork="yes" - includeAntRuntime="false" - memoryMaximumSize="${javac.memorymax}" - debug="${javacdebug}" debuglevel="${javacdebuglevel}"> - <classpath refid="nativewindow_gluegen_jogl.classpath-cdc"/> - <src path="${src.java}" /> - </javac> - </target> - - <target name="java.compile" depends="java.compile.javase,java.compile.javacdc" /> + <target name="java.compile" depends="java.compile.javase" /> <!-- ================================================================== --> <!-- @@ -428,7 +408,6 @@ <target name="rename.dylib" if="isOSX"> <move file="${src}" tofile="${dest}" /> - <copy file="${dest}" tofile="${dest-cdc}" /> </target> <macrodef name="c.build"> @@ -502,7 +481,6 @@ <antcall target="rename.dylib" inheritRefs="true"> <param name="src" value="${obj.newt}/lib@{output.lib.name}.dylib" /> <param name="dest" value="${obj.newt}/lib@{output.lib.name}.jnilib" /> - <param name="dest-cdc" value="${obj.newt}/lib@{output.lib.name}.so" /> </antcall> <!-- FIXME: this is a hack; the cpptask should have an option to change the @@ -569,7 +547,7 @@ <!-- - Build the newt.jar files. --> - <target name="build-jars" depends="gluegen.cpptasks.detect.os,build-jars-javase,build-jars-cdc" /> + <target name="build-jars" depends="gluegen.cpptasks.detect.os,build-jars-javase" /> <target name="setup-manifestfile"> <property name="manifestfile" value="newtversion"/> @@ -585,20 +563,6 @@ </copy> </target> - <target name="setup-manifestfile-cdc"> - <property name="manifestfile" value="newtversion-cdc"/> - <copy file="${manifestfile}" - tofile="tempversion-cdc" - overwrite="true"> - <filterset> - <filter token="VERSION" value="${newt.version}"/> - <filter token="SCM_BRANCH" value="${jogl.build.branch}"/> - <filter token="SCM_COMMIT" value="${jogl.build.commit}"/> - <filter token="BASEVERSION" value="${newt_base_version}"/> - </filterset> - </copy> - </target> - <target name="build-jars-awt" depends="setup-manifestfile" unless="setup.noAWT"> <jar manifest="tempversion" destfile="${newt.awt.jar}" filesonly="true"> <fileset dir="${classes}" @@ -624,24 +588,6 @@ </jar> </target> - <target name="build-jars-opengl-cdc" depends="setup-manifestfile-cdc" unless="setup.noOpenGL"> - <jar manifest="tempversion-cdc" destfile="${newt.ogl.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.opengl}"/> - </jar> - <jar manifest="tempversion-cdc" destfile="${newt.hw.broadcomegl.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.broadcomegl}"/> - </jar> - </target> - - <target name="build-jars-driver-cdc" depends="setup-manifestfile-cdc"> - <jar manifest="tempversion-cdc" destfile="${newt.hw.intelgdl.cdc.jar}" filesonly="true"> - <fileset dir="${classes}" - includes="${java.part.intelgdl}"/> - </jar> - </target> - <target name="build-jars-desktop" depends="setup-manifestfile" unless="setup.nodesktop"> <jar manifest="tempversion" destfile="${newt.os.x11.jar}" filesonly="true"> <fileset dir="${classes}" @@ -657,21 +603,6 @@ </jar> </target> - <target name="build-jars-desktop-cdc" depends="setup-manifestfile-cdc" unless="setup.nodesktop"> - <jar manifest="tempversion-cdc" destfile="${newt.os.x11.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.x11}"/> - </jar> - <jar manifest="tempversion-cdc" destfile="${newt.os.win.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.windows}"/> - </jar> - <jar manifest="tempversion-cdc" destfile="${newt.os.osx.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.macosx}"/> - </jar> - </target> - <target name="build-jars-all-awt" depends="setup-manifestfile" unless="setup.noAWT"> <jar manifest="tempversion" destfile="${newt.all.jar}" filesonly="true"> <fileset dir="${classes}"> @@ -701,16 +632,6 @@ </jar> </target> - <target name="build-jars-all-cdc" depends="setup-manifestfile-cdc"> - <jar manifest="tempversion-cdc" destfile="${newt.all.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - excludes="${java.excludes.cdcfp}" > - <include name="com/jogamp/newt/**" /> - <include name="jogamp/newt/**" /> - </fileset> - </jar> - </target> - <target name="build-jars-javase" depends="setup-manifestfile,build-jars-awt,build-jars-opengl,build-jars-all-noawt,build-jars-all-awt,build-jars-desktop,build-jars-driver"> <jar manifest="tempversion" destfile="${newt.core.jar}" filesonly="true"> <fileset dir="${classes}" @@ -724,19 +645,6 @@ <delete file="tempversion"/> </target> - <target name="build-jars-cdc" depends="setup-manifestfile-cdc,build-jars-opengl-cdc,build-jars-all-cdc,build-jars-desktop-cdc,build-jars-driver-cdc" unless="setup.noCDC"> - <jar manifest="tempversion-cdc" destfile="${newt.core.cdc.jar}" filesonly="true"> - <fileset dir="${classes-cdc}" - includes="${java.part.core}"/> - </jar> - <jar manifest="tempversion-cdc" destfile="${build.newt}/newt-natives-${os.and.arch}-cdc.jar" filesonly="true"> - <fileset dir="${obj.newt}"> - <include name="*.${native.library.suffix-cdc}" /> - </fileset> - </jar> - <delete file="tempversion-cdc"/> - </target> - <!-- ================================================================== --> <!-- - Build the Javadocs for the sources. @@ -751,7 +659,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > <classpath refid="nativewindow_gluegen_jogl.classpath"/> @@ -765,7 +673,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc.spec}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > <classpath refid="nativewindow_gluegen_jogl.classpath"/> @@ -779,7 +687,7 @@ sourcepath="${src.java};${src.generated.java}" destdir="${javadoc.dev}" windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" - source="1.4" + source="${target.sourcelevel}" linkoffline="${javadoc.link} 142-packages" bottom="${javadoc.bottom}" > <classpath refid="nativewindow_gluegen_jogl.classpath"/> diff --git a/make/build-staticglgen.xml b/make/build-staticglgen.xml index 505129d6d..325b737bb 100644 --- a/make/build-staticglgen.xml +++ b/make/build-staticglgen.xml @@ -29,7 +29,7 @@ <mkdir dir="${classes}" /> <!-- Compile BuildStaticGLInfo --> - <javac srcdir="${src.java}" destdir="${classes}" includes="**/BuildStaticGLInfo.java" source="1.4" debug="true" debuglevel="${javacdebuglevel}" + <javac srcdir="${src.java}" destdir="${classes}" includes="**/BuildStaticGLInfo.java" source="${target.sourcelevel}" debug="true" debuglevel="${javacdebuglevel}" includeAntRuntime="false"> <classpath refid="antlr.classpath" /> </javac> @@ -50,7 +50,7 @@ <!-- Build the BuildStaticGLInfo ANT task. - NOTE: ONLY the StaticGLGen is built at this time. BuildStaticGLInfo - itself is built in a separate task. --> - <javac destdir="${classes}" includes="**/StaticGLGenTask.java" source="1.4" debug="true" debuglevel="${javacdebuglevel}" + <javac destdir="${classes}" includes="**/StaticGLGenTask.java" source="${target.sourcelevel}" debug="true" debuglevel="${javacdebuglevel}" includeAntRuntime="false"> <src path="${src.java}" /> <classpath refid="classpath" /> diff --git a/make/build.xml b/make/build.xml index 69609881b..518e17309 100644 --- a/make/build.xml +++ b/make/build.xml @@ -72,10 +72,10 @@ <delete includeEmptyDirs="true" quiet="true" dir="${lib}" failonerror="false" /> <mkdir dir="${lib}" /> <copy todir="${lib}"> - <fileset dir="${gluegen.root}/${rootrel.build}/obj" includes="*.${native.library.suffix} *.${native.library.suffix-cdc}" /> - <fileset dir="${build}/jogl/obj" includes="*.${native.library.suffix} *.${native.library.suffix-cdc}" /> - <fileset dir="${build}/nativewindow/obj" includes="*.${native.library.suffix} *.${native.library.suffix-cdc}" /> - <fileset dir="${build}/newt/obj" includes="*.${native.library.suffix} *.${native.library.suffix-cdc}" /> + <fileset dir="${gluegen.root}/${rootrel.build}/obj" includes="*.${native.library.suffix}" /> + <fileset dir="${build}/jogl/obj" includes="*.${native.library.suffix}" /> + <fileset dir="${build}/nativewindow/obj" includes="*.${native.library.suffix}" /> + <fileset dir="${build}/newt/obj" includes="*.${native.library.suffix}" /> </copy> </target> @@ -185,9 +185,6 @@ </target> <target name="javadoc.init" depends="init"> - <property name="javadoc.link" value="http://java.sun.com/j2se/1.4.2/docs/api/" /> - <!--property name="javadoc.link" value="http://download.oracle.com/javase/1.4.2/docs/api/"/--> - <!-- Link offline with relative URLs does not work. Link online with relative URLs works, so we have to assume the same relative online folder structure: @@ -252,7 +249,7 @@ windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" access="public" - source="1.4" + source="${target.sourcelevel}" maxmemory="1024m" bottom="${javadoc.bottom}" > <classpath refid="jogl_newt_all.classpath"/> @@ -273,7 +270,7 @@ windowtitle="${javadoc.spec.windowtitle}" overview="${javadoc.overview}" access="public" - source="1.4" + source="${target.sourcelevel}" maxmemory="1024m" bottom="${javadoc.bottom}" > <classpath refid="jogl_newt_all.classpath"/> @@ -295,7 +292,7 @@ windowtitle="${javadoc.windowtitle}" overview="${javadoc.overview}" access="protected" - source="1.5" + source="${target.sourcelevel}" maxmemory="1024m" bottom="${javadoc.bottom}" > <classpath refid="jogl_newt_all.classpath"/> @@ -316,7 +313,7 @@ windowtitle="${javadoc.nw.spec.windowtitle}" overview="${javadoc.nw.overview}" access="public" - source="1.4" + source="${target.sourcelevel}" maxmemory="1024m" bottom="${javadoc.bottom}" > <classpath refid="jogl_newt_all.classpath"/> diff --git a/make/joglversion-cdc b/make/joglversion-cdc deleted file mode 100644 index 4b1745606..000000000 --- a/make/joglversion-cdc +++ /dev/null @@ -1,12 +0,0 @@ -Specification-Title: Java Bindings for OpenGL API Specification CDC -Specification-Version: @BASEVERSION@ -Specification-Vendor: JogAmp Community -Implementation-Title: Java Bindings for OpenGL Runtime Environment CDC -Implementation-Version: @VERSION@ -Implementation-Branch: @SCM_BRANCH@ -Implementation-Commit: @SCM_COMMIT@ -Implementation-Vendor: JogAmp Community -Implementation-URL: http://jogamp.org/ -Extension-Name: javax.media.opengl -Implementation-Vendor-Id: com.jogamp -Trusted-Library: true diff --git a/make/nativewindowversion-cdc b/make/nativewindowversion-cdc deleted file mode 100644 index 78098c9ff..000000000 --- a/make/nativewindowversion-cdc +++ /dev/null @@ -1,12 +0,0 @@ -Specification-Title: Native Window Interface API Specification CDC -Specification-Version: @BASEVERSION@ -Specification-Vendor: JogAmp Community -Implementation-Title: Native Window Interface Runtime Environment CDC -Implementation-Version: @VERSION@ -Implementation-Branch: @SCM_BRANCH@ -Implementation-Commit: @SCM_COMMIT@ -Implementation-Vendor: JogAmp Community -Implementation-URL: http://jogamp.org/ -Extension-Name: javax.media.nativewindow -Implementation-Vendor-Id: com.jogamp -Trusted-Library: true diff --git a/make/newtversion-cdc b/make/newtversion-cdc deleted file mode 100644 index d687ca320..000000000 --- a/make/newtversion-cdc +++ /dev/null @@ -1,12 +0,0 @@ -Specification-Title: NEWT API Specification CDC -Specification-Version: @BASEVERSION@ -Specification-Vendor: JogAmp Community -Implementation-Title: NEWT Runtime Environment CDC -Implementation-Version: @VERSION@ -Implementation-Branch: @SCM_BRANCH@ -Implementation-Commit: @SCM_COMMIT@ -Implementation-Vendor: JogAmp Community -Implementation-URL: http://jogamp.org/ -Extension-Name: com.jogamp.newt -Implementation-Vendor-Id: com.jogamp -Trusted-Library: true diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javase b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index e86ff161b..e86ff161b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javase +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp deleted file mode 100644 index eb65ff538..000000000 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java.javame_cdc_fp +++ /dev/null @@ -1,1256 +0,0 @@ -/* - * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package com.jogamp.opengl.util.texture; - -import java.io.*; -import java.net.*; -import java.nio.*; -import java.util.*; - -import javax.media.opengl.*; -import javax.media.opengl.glu.*; -import jogamp.opengl.Debug; -import com.jogamp.opengl.util.*; -import com.jogamp.opengl.util.texture.spi.*; - -/** <P> Provides input and output facilities for both loading OpenGL - textures from disk and streams as well as writing textures already - in memory back to disk. </P> - - <P> The TextureIO class supports an arbitrary number of plug-in - readers and writers via TextureProviders and TextureWriters. - TextureProviders know how to produce TextureData objects from - files, InputStreams and URLs. TextureWriters know how to write - TextureData objects to disk in various file formats. The - TextureData class represents the raw data of the texture before it - has been converted to an OpenGL texture object. The Texture class - represents the OpenGL texture object and provides easy facilities - for using the texture. </P> - - <P> There are several built-in TextureProviders and TextureWriters - supplied with the TextureIO implementation. The most basic - provider uses the platform's Image I/O facilities to read in a - BufferedImage and convert it to a texture. This is the baseline - provider and is registered so that it is the last one consulted. - All others are asked first to open a given file. </P> - - <P> There are three other providers registered by default as of - the time of this writing. One handles SGI RGB (".sgi", ".rgb") - images from both files and streams. One handles DirectDraw Surface - (".dds") images read from files, though can not read these images - from streams. One handles Targa (".tga") images read from both - files and streams. These providers are executed in an arbitrary - order. Some of these providers require the file's suffix to either - be specified via the newTextureData methods or for the file to be - named with the appropriate suffix. In general a file suffix should - be provided to the newTexture and newTextureData methods if at all - possible. </P> - - <P> Note that additional TextureProviders, if reading images from - InputStreams, must use the mark()/reset() methods on InputStream - when probing for e.g. magic numbers at the head of the file to - make sure not to disturb the state of the InputStream for - downstream TextureProviders. </P> - - <P> There are analogous TextureWriters provided for writing - textures back to disk if desired. As of this writing, there are - four TextureWriters registered by default: one for Targa files, - one for SGI RGB files, one for DirectDraw surface (.dds) files, - and one for ImageIO-supplied formats such as .jpg and .png. Some - of these writers have certain limitations such as only being able - to write out textures stored in GL_RGB or GL_RGBA format. The DDS - writer supports fetching and writing to disk of texture data in - DXTn compressed format. Whether this will occur is dependent on - whether the texture's internal format is one of the DXTn - compressed formats and whether the target file is .dds format. -*/ - -public class TextureIO { - /** Constant which can be used as a file suffix to indicate a - DirectDraw Surface file. */ - public static final String DDS = "dds"; - - /** Constant which can be used as a file suffix to indicate an SGI - RGB file. */ - public static final String SGI = "sgi"; - - /** Constant which can be used as a file suffix to indicate an SGI - RGB file. */ - public static final String SGI_RGB = "rgb"; - - /** Constant which can be used as a file suffix to indicate a GIF - file. */ - public static final String GIF = "gif"; - - /** Constant which can be used as a file suffix to indicate a JPEG - file. */ - public static final String JPG = "jpg"; - - /** Constant which can be used as a file suffix to indicate a PNG - file. */ - public static final String PNG = "png"; - - /** Constant which can be used as a file suffix to indicate a Targa - file. */ - public static final String TGA = "tga"; - - /** Constant which can be used as a file suffix to indicate a TIFF - file. */ - public static final String TIFF = "tiff"; - - private static final boolean DEBUG = Debug.debug("TextureIO"); - - // For manually disabling the use of the texture rectangle - // extensions so you know the texture target is GL_TEXTURE_2D; this - // is useful for shader writers (thanks to Chris Campbell for this - // observation) - private static boolean texRectEnabled = true; - - //---------------------------------------------------------------------- - // methods that *do not* require a current context - // These methods assume RGB or RGBA textures. - // Some texture providers may not recognize the file format unless - // the fileSuffix is specified, so it is strongly recommended to - // specify it wherever it is known. - // Some texture providers may also only support one kind of input, - // i.e., reading from a file as opposed to a stream. - - /** - * Creates a TextureData from the given file. Does no OpenGL work. - * - * @param glp the OpenGL Profile this texture data should be - * created for. - * @param file the file from which to read the texture data - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @param fileSuffix the suffix of the file name to be used as a - * hint of the file format to the underlying - * texture provider, or null if none and should be - * auto-detected (some texture providers do not - * support this) - * @return the texture data from the file, or null if none of the - * registered texture providers could read the file - * @throws IOException if an error occurred while reading the file - */ - public static TextureData newTextureData(GLProfile glp, File file, - boolean mipmap, - String fileSuffix) throws IOException { - if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(file); - } - return newTextureDataImpl(glp, file, 0, 0, mipmap, fileSuffix); - } - - /** - * Creates a TextureData from the given stream. Does no OpenGL work. - * - * @param glp the OpenGL Profile this texture data should be - * created for. - * @param stream the stream from which to read the texture data - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @param fileSuffix the suffix of the file name to be used as a - * hint of the file format to the underlying - * texture provider, or null if none and should be - * auto-detected (some texture providers do not - * support this) - * @return the texture data from the stream, or null if none of the - * registered texture providers could read the stream - * @throws IOException if an error occurred while reading the stream - */ - public static TextureData newTextureData(GLProfile glp, InputStream stream, - boolean mipmap, - String fileSuffix) throws IOException { - return newTextureDataImpl(glp, stream, 0, 0, mipmap, fileSuffix); - } - - /** - * Creates a TextureData from the given URL. Does no OpenGL work. - * - * @param glp the OpenGL Profile this texture data should be - * created for. - * @param url the URL from which to read the texture data - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @param fileSuffix the suffix of the file name to be used as a - * hint of the file format to the underlying - * texture provider, or null if none and should be - * auto-detected (some texture providers do not - * support this) - * @return the texture data from the URL, or null if none of the - * registered texture providers could read the URL - * @throws IOException if an error occurred while reading the URL - */ - public static TextureData newTextureData(GLProfile glp, URL url, - boolean mipmap, - String fileSuffix) throws IOException { - if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(url.getPath()); - } - return newTextureDataImpl(glp, url, 0, 0, mipmap, fileSuffix); - } - - //---------------------------------------------------------------------- - // These methods make no assumption about the OpenGL internal format - // or pixel format of the texture; they must be specified by the - // user. It is not allowed to supply 0 (indicating no preference) - // for either the internalFormat or the pixelFormat; - // IllegalArgumentException will be thrown in this case. - - /** - * Creates a TextureData from the given file, using the specified - * OpenGL internal format and pixel format for the texture which - * will eventually result. The internalFormat and pixelFormat must - * be specified and may not be zero; to use default values, use the - * variant of this method which does not take these arguments. Does - * no OpenGL work. - * - * @param glp the OpenGL Profile this texture data should be - * created for. - * @param file the file from which to read the texture data - * @param internalFormat the OpenGL internal format of the texture - * which will eventually result from the TextureData - * @param pixelFormat the OpenGL pixel format of the texture - * which will eventually result from the TextureData - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @param fileSuffix the suffix of the file name to be used as a - * hint of the file format to the underlying - * texture provider, or null if none and should be - * auto-detected (some texture providers do not - * support this) - * @return the texture data from the file, or null if none of the - * registered texture providers could read the file - * @throws IllegalArgumentException if either internalFormat or - * pixelFormat was 0 - * @throws IOException if an error occurred while reading the file - */ - public static TextureData newTextureData(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException, IllegalArgumentException { - if ((internalFormat == 0) || (pixelFormat == 0)) { - throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); - } - - if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(file); - } - - return newTextureDataImpl(glp, file, internalFormat, pixelFormat, mipmap, fileSuffix); - } - - /** - * Creates a TextureData from the given stream, using the specified - * OpenGL internal format and pixel format for the texture which - * will eventually result. The internalFormat and pixelFormat must - * be specified and may not be zero; to use default values, use the - * variant of this method which does not take these arguments. Does - * no OpenGL work. - * - * @param glp the OpenGL Profile this texture data should be - * created for. - * @param stream the stream from which to read the texture data - * @param internalFormat the OpenGL internal format of the texture - * which will eventually result from the TextureData - * @param pixelFormat the OpenGL pixel format of the texture - * which will eventually result from the TextureData - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @param fileSuffix the suffix of the file name to be used as a - * hint of the file format to the underlying - * texture provider, or null if none and should be - * auto-detected (some texture providers do not - * support this) - * @return the texture data from the stream, or null if none of the - * registered texture providers could read the stream - * @throws IllegalArgumentException if either internalFormat or - * pixelFormat was 0 - * @throws IOException if an error occurred while reading the stream - */ - public static TextureData newTextureData(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException, IllegalArgumentException { - if ((internalFormat == 0) || (pixelFormat == 0)) { - throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); - } - - return newTextureDataImpl(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); - } - - /** - * Creates a TextureData from the given URL, using the specified - * OpenGL internal format and pixel format for the texture which - * will eventually result. The internalFormat and pixelFormat must - * be specified and may not be zero; to use default values, use the - * variant of this method which does not take these arguments. Does - * no OpenGL work. - * - * @param glp the OpenGL Profile this texture data should be - * created for. - * @param url the URL from which to read the texture data - * @param internalFormat the OpenGL internal format of the texture - * which will eventually result from the TextureData - * @param pixelFormat the OpenGL pixel format of the texture - * which will eventually result from the TextureData - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @param fileSuffix the suffix of the file name to be used as a - * hint of the file format to the underlying - * texture provider, or null if none and should be - * auto-detected (some texture providers do not - * support this) - * @return the texture data from the URL, or null if none of the - * registered texture providers could read the URL - * @throws IllegalArgumentException if either internalFormat or - * pixelFormat was 0 - * @throws IOException if an error occurred while reading the URL - */ - public static TextureData newTextureData(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException, IllegalArgumentException { - if ((internalFormat == 0) || (pixelFormat == 0)) { - throw new IllegalArgumentException("internalFormat and pixelFormat must be non-zero"); - } - - if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(url.getPath()); - } - - return newTextureDataImpl(glp, url, internalFormat, pixelFormat, mipmap, fileSuffix); - } - - //---------------------------------------------------------------------- - // methods that *do* require a current context - // - - /** - * Creates an OpenGL texture object from the specified TextureData - * using the current OpenGL context. - * - * @param data the texture data to turn into an OpenGL texture - * @throws GLException if no OpenGL context is current or if an - * OpenGL error occurred - * @throws IllegalArgumentException if the passed TextureData was null - */ - public static Texture newTexture(TextureData data) throws GLException, IllegalArgumentException { - if (data == null) { - throw new IllegalArgumentException("Null TextureData"); - } - return new Texture(data); - } - - /** - * Creates an OpenGL texture object from the specified file using - * the current OpenGL context. - * - * @param file the file from which to read the texture data - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @throws IOException if an error occurred while reading the file - * @throws GLException if no OpenGL context is current or if an - * OpenGL error occurred - */ - public static Texture newTexture(File file, boolean mipmap) throws IOException, GLException { - GLProfile glp = GLContext.getCurrentGL().getGLProfile(); - TextureData data = newTextureData(glp, file, mipmap, FileUtil.getFileSuffix(file)); - Texture texture = newTexture(data); - data.flush(); - return texture; - } - - /** - * Creates an OpenGL texture object from the specified stream using - * the current OpenGL context. - * - * @param stream the stream from which to read the texture data - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @param fileSuffix the suffix of the file name to be used as a - * hint of the file format to the underlying - * texture provider, or null if none and should be - * auto-detected (some texture providers do not - * support this) - * @throws IOException if an error occurred while reading the stream - * @throws GLException if no OpenGL context is current or if an - * OpenGL error occurred - */ - public static Texture newTexture(InputStream stream, boolean mipmap, String fileSuffix) throws IOException, GLException { - GLProfile glp = GLContext.getCurrentGL().getGLProfile(); - TextureData data = newTextureData(glp, stream, mipmap, fileSuffix); - Texture texture = newTexture(data); - data.flush(); - return texture; - } - - /** - * Creates an OpenGL texture object from the specified URL using the - * current OpenGL context. - * - * @param url the URL from which to read the texture data - * @param mipmap whether mipmaps should be produced for this - * texture either by autogenerating them or - * reading them from the file. Some file formats - * support multiple mipmaps in a single file in - * which case those mipmaps will be used rather - * than generating them. - * @param fileSuffix the suffix of the file name to be used as a - * hint of the file format to the underlying - * texture provider, or null if none and should be - * auto-detected (some texture providers do not - * support this) - * @throws IOException if an error occurred while reading the URL - * @throws GLException if no OpenGL context is current or if an - * OpenGL error occurred - */ - public static Texture newTexture(URL url, boolean mipmap, String fileSuffix) throws IOException, GLException { - if (fileSuffix == null) { - fileSuffix = FileUtil.getFileSuffix(url.getPath()); - } - GLProfile glp = GLContext.getCurrentGL().getGLProfile(); - TextureData data = newTextureData(glp, url, mipmap, fileSuffix); - Texture texture = newTexture(data); - data.flush(); - return texture; - } - - /** - * Creates an OpenGL texture object associated with the given OpenGL - * texture target using the current OpenGL context. The texture has - * no initial data. This is used, for example, to construct cube - * maps out of multiple TextureData objects. - * - * @param target the OpenGL target type, eg GL.GL_TEXTURE_2D, - * GL.GL_TEXTURE_RECTANGLE_ARB - * - * @throws GLException if no OpenGL context is current or if an - * OpenGL error occurred - */ - public static Texture newTexture(int target) throws GLException { - return new Texture(target); - } - - /** - * Wraps an OpenGL texture ID from an external library and allows - * some of the base methods from the Texture class, such as - * binding and querying of texture coordinates, to be used with - * it. Attempts to update such textures' contents will yield - * undefined results. - * - * @param textureID the OpenGL texture object to wrap - * @param target the OpenGL texture target, eg GL.GL_TEXTURE_2D, - * GL2.GL_TEXTURE_RECTANGLE - * @param texWidth the width of the texture in pixels - * @param texHeight the height of the texture in pixels - * @param imgWidth the width of the image within the texture in - * pixels (if the content is a sub-rectangle in the upper - * left corner); otherwise, pass in texWidth - * @param imgHeight the height of the image within the texture in - * pixels (if the content is a sub-rectangle in the upper - * left corner); otherwise, pass in texHeight - * @param mustFlipVertically indicates whether the texture - * coordinates must be flipped vertically - * in order to properly display the - * texture - */ - public static Texture newTexture(int textureID, - int target, - int texWidth, - int texHeight, - int imgWidth, - int imgHeight, - boolean mustFlipVertically) { - return new Texture(textureID, - target, - texWidth, - texHeight, - imgWidth, - imgHeight, - mustFlipVertically); - } - - /** - * Writes the given texture to a file. The type of the file is - * inferred from its suffix. An OpenGL context must be current in - * order to fetch the texture data back from the OpenGL pipeline. - * This method causes the specified Texture to be bound to the - * GL_TEXTURE_2D state. If no suitable writer for the requested file - * format was found, throws an IOException. <P> - * - * Reasonable attempts are made to produce good results in the - * resulting images. The Targa, SGI and ImageIO writers produce - * results in the correct vertical orientation for those file - * formats. The DDS writer performs no vertical flip of the data, - * even in uncompressed mode. (It is impossible to perform such a - * vertical flip with compressed data.) Applications should keep - * this in mind when using this routine to save textures to disk for - * later re-loading. <P> - * - * Any mipmaps for the specified texture are currently discarded - * when it is written to disk, regardless of whether the underlying - * file format supports multiple mipmaps in a given file. - * - * @throws IOException if an error occurred during writing or no - * suitable writer was found - * @throws GLException if no OpenGL context was current or an - * OpenGL-related error occurred - */ - public static void write(Texture texture, File file) throws IOException, GLException { - if (texture.getTarget() != GL.GL_TEXTURE_2D) { - throw new GLException("Only GL_TEXTURE_2D textures are supported"); - } - - // First fetch the texture data - GL _gl = GLContext.getCurrentGL(); - if (!_gl.isGL2()) { - throw new GLException("Only GL2 supports fetching compressed images, GL: " + _gl); - } - GL2 gl = _gl.getGL2(); - - texture.bind(); - int internalFormat = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_INTERNAL_FORMAT); - int width = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_WIDTH); - int height = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_HEIGHT); - int border = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_BORDER); - TextureData data = null; - if (internalFormat == GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT || - internalFormat == GL.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT || - internalFormat == GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT || - internalFormat == GL.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT) { - // Fetch using glGetCompressedTexImage - int size = glGetTexLevelParameteri(gl, GL.GL_TEXTURE_2D, 0, GL2.GL_TEXTURE_COMPRESSED_IMAGE_SIZE); - ByteBuffer res = ByteBuffer.wrap(new byte[size]); - gl.glGetCompressedTexImage(GL.GL_TEXTURE_2D, 0, res); - data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, internalFormat, GL.GL_UNSIGNED_BYTE, - false, true, true, res, null); - } else { - int bytesPerPixel = 0; - int fetchedFormat = 0; - switch (internalFormat) { - case GL.GL_RGB: - case GL2.GL_BGR: - case GL.GL_RGB8: - bytesPerPixel = 3; - fetchedFormat = GL.GL_RGB; - break; - case GL.GL_RGBA: - case GL2.GL_BGRA: - case GL2.GL_ABGR_EXT: - case GL.GL_RGBA8: - bytesPerPixel = 4; - fetchedFormat = GL.GL_RGBA; - break; - default: - throw new IOException("Unsupported texture internal format 0x" + Integer.toHexString(internalFormat)); - } - - // Fetch using glGetTexImage - int packAlignment = glGetInteger(GL.GL_PACK_ALIGNMENT); - int packRowLength = glGetInteger(GL2.GL_PACK_ROW_LENGTH); - int packSkipRows = glGetInteger(GL2.GL_PACK_SKIP_ROWS); - int packSkipPixels = glGetInteger(GL2.GL_PACK_SKIP_PIXELS); - int packSwapBytes = glGetInteger(GL2.GL_PACK_SWAP_BYTES); - - gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, 1); - gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, 0); - gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, 0); - gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, 0); - gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, 0); - - ByteBuffer res = ByteBuffer.wrap(new byte[(width + (2 * border)) * - (height + (2 * border)) * - bytesPerPixel]); - if (DEBUG) { - System.out.println("Allocated buffer of size " + res.remaining() + " for fetched image (" + - ((fetchedFormat == GL.GL_RGB) ? "GL_RGB" : "GL_RGBA") + ")"); - } - gl.glGetTexImage(GL.GL_TEXTURE_2D, 0, fetchedFormat, GL.GL_UNSIGNED_BYTE, res); - - gl.glPixelStorei(GL.GL_PACK_ALIGNMENT, packAlignment); - gl.glPixelStorei(GL2.GL_PACK_ROW_LENGTH, packRowLength); - gl.glPixelStorei(GL2.GL_PACK_SKIP_ROWS, packSkipRows); - gl.glPixelStorei(GL2.GL_PACK_SKIP_PIXELS, packSkipPixels); - gl.glPixelStorei(GL2.GL_PACK_SWAP_BYTES, packSwapBytes); - - data = new TextureData(gl.getGLProfile(), internalFormat, width, height, border, fetchedFormat, GL.GL_UNSIGNED_BYTE, - false, false, false, res, null); - - if (DEBUG) { - System.out.println("data.getPixelFormat() = " + - ((data.getPixelFormat() == GL.GL_RGB) ? "GL_RGB" : "GL_RGBA")); - } - } - - write(data, file); - } - - public static void write(TextureData data, File file) throws IOException, GLException { - for (Iterator iter = textureWriters.iterator(); iter.hasNext(); ) { - TextureWriter writer = (TextureWriter) iter.next(); - if (writer.write(file, data)) { - return; - } - } - - throw new IOException("No suitable texture writer found for "+file.getAbsolutePath()); - } - - //---------------------------------------------------------------------- - // SPI support - // - - /** Adds a TextureProvider to support reading of a new file - format. */ - public static void addTextureProvider(TextureProvider provider) { - // Must always add at the front so the ImageIO provider is last, - // so we don't accidentally use it instead of a user's possibly - // more optimal provider - textureProviders.add(0, provider); - } - - /** Adds a TextureWriter to support writing of a new file - format. */ - public static void addTextureWriter(TextureWriter writer) { - // Must always add at the front so the ImageIO writer is last, - // so we don't accidentally use it instead of a user's possibly - // more optimal writer - textureWriters.add(0, writer); - } - - //--------------------------------------------------------------------------- - // Global disabling of texture rectangle extension - // - - /** Toggles the use of the GL_ARB_texture_rectangle extension by the - TextureIO classes. By default, on hardware supporting this - extension, the TextureIO classes may use the - GL_ARB_texture_rectangle extension for non-power-of-two - textures. (If the hardware supports the - GL_ARB_texture_non_power_of_two extension, that one is - preferred.) In some situations, for example when writing - shaders, it is advantageous to force the texture target to - always be GL_TEXTURE_2D in order to have one version of the - shader, even at the expense of texture memory in the case where - NPOT textures are not supported. This method allows the use of - the GL_ARB_texture_rectangle extension to be turned off globally - for this purpose. The default is that the use of the extension - is enabled. */ - public static void setTexRectEnabled(boolean enabled) { - texRectEnabled = enabled; - } - - /** Indicates whether the GL_ARB_texture_rectangle extension is - allowed to be used for non-power-of-two textures; see {@link - #setTexRectEnabled setTexRectEnabled}. */ - public static boolean isTexRectEnabled() { - return texRectEnabled; - } - - //---------------------------------------------------------------------- - // Internals only below this point - // - - private static List/*<TextureProvider>*/ textureProviders = new ArrayList/*<TextureProvider>*/(); - private static List/*<TextureWriter>*/ textureWriters = new ArrayList/*<TextureWriter>*/(); - - static { - /* - if(GLProfile.isAWTAvailable()) { - // ImageIO provider, the fall-back, must be the first one added - try { - // Use reflection to avoid compile-time dependencies on AWT-related classes - TextureProvider provider = (TextureProvider) - Class.forName("com.jogamp.opengl.util.texture.spi.awt.IIOTextureProvider").newInstance(); - addTextureProvider(provider); - } catch (Exception e) { - if (DEBUG) { - e.printStackTrace(); - } - } - } - */ - - // Other special-case providers - addTextureProvider(new DDSTextureProvider()); - addTextureProvider(new SGITextureProvider()); - addTextureProvider(new TGATextureProvider()); - - /* - // ImageIO writer, the fall-back, must be the first one added - if(GLProfile.isAWTAvailable()) { - try { - // Use reflection to avoid compile-time dependencies on AWT-related classes - TextureWriter writer = (TextureWriter) - Class.forName("com.jogamp.opengl.util.texture.spi.awt.IIOTextureWriter").newInstance(); - addTextureWriter(writer); - } catch (Exception e) { - if (DEBUG) { - e.printStackTrace(); - } - } - } - */ - - // Other special-case writers - addTextureWriter(new DDSTextureWriter()); - addTextureWriter(new SGITextureWriter()); - addTextureWriter(new TGATextureWriter()); - addTextureWriter(new NetPbmTextureWriter()); - } - - // Implementation methods - private static TextureData newTextureDataImpl(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - if (file == null) { - throw new IOException("File was null"); - } - - fileSuffix = toLowerCase(fileSuffix); - - for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { - TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(glp, file, - internalFormat, - pixelFormat, - mipmap, - fileSuffix); - if (data != null) { - return data; - } - } - - throw new IOException("No suitable reader for given file "+file.getAbsolutePath()); - } - - private static TextureData newTextureDataImpl(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - if (stream == null) { - throw new IOException("Stream was null"); - } - - fileSuffix = toLowerCase(fileSuffix); - - // Note: use of BufferedInputStream works around 4764639/4892246 - if (!(stream instanceof BufferedInputStream)) { - stream = new BufferedInputStream(stream); - } - - for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { - TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(glp, stream, - internalFormat, - pixelFormat, - mipmap, - fileSuffix); - if (data != null) { - return data; - } - } - - throw new IOException("No suitable reader for given stream"); - } - - private static TextureData newTextureDataImpl(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - if (url == null) { - throw new IOException("URL was null"); - } - - fileSuffix = toLowerCase(fileSuffix); - - for (Iterator iter = textureProviders.iterator(); iter.hasNext(); ) { - TextureProvider provider = (TextureProvider) iter.next(); - TextureData data = provider.newTextureData(glp, url, - internalFormat, - pixelFormat, - mipmap, - fileSuffix); - if (data != null) { - return data; - } - } - - throw new IOException("No suitable reader for given URL "+url); - } - - //---------------------------------------------------------------------- - // DDS provider -- supports files only for now - static class DDSTextureProvider implements TextureProvider { - public TextureData newTextureData(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - if (DDS.equals(fileSuffix) || - DDS.equals(FileUtil.getFileSuffix(file))) { - DDSImage image = DDSImage.read(file); - return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); - } - - return null; - } - - public TextureData newTextureData(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - if (DDS.equals(fileSuffix) || - DDSImage.isDDSImage(stream)) { - DDSImage image = DDSImage.read(stream); - return newTextureData(glp, image, internalFormat, pixelFormat, mipmap); - } - - return null; - } - - public TextureData newTextureData(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - InputStream stream = new BufferedInputStream(url.openStream()); - try { - return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); - } finally { - stream.close(); - } - } - - private TextureData newTextureData(GLProfile glp, final DDSImage image, - int internalFormat, - int pixelFormat, - boolean mipmap) { - DDSImage.ImageInfo info = image.getMipMap(0); - if (pixelFormat == 0) { - switch (image.getPixelFormat()) { - case DDSImage.D3DFMT_R8G8B8: - pixelFormat = GL.GL_RGB; - break; - default: - pixelFormat = GL.GL_RGBA; - break; - } - } - if (info.isCompressed()) { - switch (info.getCompressionFormat()) { - case DDSImage.D3DFMT_DXT1: - internalFormat = GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - break; - case DDSImage.D3DFMT_DXT3: - internalFormat = GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - break; - case DDSImage.D3DFMT_DXT5: - internalFormat = GL.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - break; - default: - throw new RuntimeException("Unsupported DDS compression format \"" + - DDSImage.getCompressionFormatName(info.getCompressionFormat()) + "\""); - } - } - if (internalFormat == 0) { - switch (image.getPixelFormat()) { - case DDSImage.D3DFMT_R8G8B8: - pixelFormat = GL.GL_RGB; - break; - default: - pixelFormat = GL.GL_RGBA; - break; - } - } - TextureData.Flusher flusher = new TextureData.Flusher() { - public void flush() { - image.close(); - } - }; - TextureData data; - if (mipmap && image.getNumMipMaps() > 0) { - Buffer[] mipmapData = new Buffer[image.getNumMipMaps()]; - for (int i = 0; i < image.getNumMipMaps(); i++) { - mipmapData[i] = image.getMipMap(i).getData(); - } - data = new TextureData(glp, internalFormat, - info.getWidth(), - info.getHeight(), - 0, - pixelFormat, - GL.GL_UNSIGNED_BYTE, - info.isCompressed(), - true, - mipmapData, - flusher); - } else { - // Fix this up for the end user because we can't generate - // mipmaps for compressed textures - mipmap = false; - data = new TextureData(glp, internalFormat, - info.getWidth(), - info.getHeight(), - 0, - pixelFormat, - GL.GL_UNSIGNED_BYTE, - mipmap, - info.isCompressed(), - true, - info.getData(), - flusher); - } - return data; - } - } - - //---------------------------------------------------------------------- - // Base class for SGI RGB and TGA image providers - static abstract class StreamBasedTextureProvider implements TextureProvider { - public TextureData newTextureData(GLProfile glp, File file, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - InputStream inStream = new BufferedInputStream(new FileInputStream(file)); - try { - // The SGIImage and TGAImage implementations use InputStreams - // anyway so there isn't much point in having a separate code - // path for files - return newTextureData(glp, inStream, - internalFormat, - pixelFormat, - mipmap, - ((fileSuffix != null) ? fileSuffix : FileUtil.getFileSuffix(file))); - } finally { - inStream.close(); - } - } - - public TextureData newTextureData(GLProfile glp, URL url, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - InputStream stream = new BufferedInputStream(url.openStream()); - try { - return newTextureData(glp, stream, internalFormat, pixelFormat, mipmap, fileSuffix); - } finally { - stream.close(); - } - } - } - - //---------------------------------------------------------------------- - // SGI RGB image provider - static class SGITextureProvider extends StreamBasedTextureProvider { - public TextureData newTextureData(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - if (SGI.equals(fileSuffix) || - SGI_RGB.equals(fileSuffix) || - SGIImage.isSGIImage(stream)) { - SGIImage image = SGIImage.read(stream); - if (pixelFormat == 0) { - pixelFormat = image.getFormat(); - } - if (internalFormat == 0) { - internalFormat = image.getFormat(); - } - return new TextureData(glp, internalFormat, - image.getWidth(), - image.getHeight(), - 0, - pixelFormat, - GL.GL_UNSIGNED_BYTE, - mipmap, - false, - false, - ByteBuffer.wrap(image.getData()), - null); - } - - return null; - } - } - - //---------------------------------------------------------------------- - // TGA (Targa) image provider - static class TGATextureProvider extends StreamBasedTextureProvider { - public TextureData newTextureData(GLProfile glp, InputStream stream, - int internalFormat, - int pixelFormat, - boolean mipmap, - String fileSuffix) throws IOException { - if (TGA.equals(fileSuffix)) { - TGAImage image = TGAImage.read(stream); - if (pixelFormat == 0) { - pixelFormat = image.getGLFormat(); - } - if (internalFormat == 0) { - GL gl = GLContext.getCurrentGL(); - if(gl.isGL2()) { - internalFormat = GL.GL_RGBA8; - } else { - internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB; - } - } - return new TextureData(glp, internalFormat, - image.getWidth(), - image.getHeight(), - 0, - pixelFormat, - GL.GL_UNSIGNED_BYTE, - mipmap, - false, - false, - image.getData(), - null); - } - - return null; - } - } - - //---------------------------------------------------------------------- - // DDS texture writer - // - static class DDSTextureWriter implements TextureWriter { - public boolean write(File file, - TextureData data) throws IOException { - if (DDS.equals(FileUtil.getFileSuffix(file))) { - // See whether the DDS writer can handle this TextureData - int pixelFormat = data.getPixelFormat(); - int pixelType = data.getPixelType(); - if (pixelType != GL.GL_BYTE && - pixelType != GL.GL_UNSIGNED_BYTE) { - throw new IOException("DDS writer only supports byte / unsigned byte textures"); - } - - int d3dFormat = 0; - // FIXME: some of these are probably not completely correct and would require swizzling - switch (pixelFormat) { - case GL.GL_RGB: d3dFormat = DDSImage.D3DFMT_R8G8B8; break; - case GL.GL_RGBA: d3dFormat = DDSImage.D3DFMT_A8R8G8B8; break; - case GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT: d3dFormat = DDSImage.D3DFMT_DXT1; break; - case GL.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: throw new IOException("RGBA DXT1 not yet supported"); - case GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: d3dFormat = DDSImage.D3DFMT_DXT3; break; - case GL.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: d3dFormat = DDSImage.D3DFMT_DXT5; break; - default: throw new IOException("Unsupported pixel format 0x" + Integer.toHexString(pixelFormat) + " by DDS writer"); - } - - ByteBuffer[] mipmaps = null; - if (data.getMipmapData() != null) { - mipmaps = new ByteBuffer[data.getMipmapData().length]; - for (int i = 0; i < mipmaps.length; i++) { - mipmaps[i] = (ByteBuffer) data.getMipmapData()[i]; - } - } else { - mipmaps = new ByteBuffer[] { (ByteBuffer) data.getBuffer() }; - } - - DDSImage image = DDSImage.createFromData(d3dFormat, - data.getWidth(), - data.getHeight(), - mipmaps); - image.write(file); - return true; - } - - return false; - } - } - - //---------------------------------------------------------------------- - // SGI (rgb) texture writer - // - static class SGITextureWriter implements TextureWriter { - public boolean write(File file, - TextureData data) throws IOException { - String fileSuffix = FileUtil.getFileSuffix(file); - if (SGI.equals(fileSuffix) || - SGI_RGB.equals(fileSuffix)) { - // See whether the SGI writer can handle this TextureData - int pixelFormat = data.getPixelFormat(); - int pixelType = data.getPixelType(); - if ((pixelFormat == GL.GL_RGB || - pixelFormat == GL.GL_RGBA) && - (pixelType == GL.GL_BYTE || - pixelType == GL.GL_UNSIGNED_BYTE)) { - ByteBuffer buf = ((data.getBuffer() != null) ? - (ByteBuffer) data.getBuffer() : - (ByteBuffer) data.getMipmapData()[0]); - byte[] bytes; - if (buf.hasArray()) { - bytes = buf.array(); - } else { - buf.rewind(); - bytes = new byte[buf.remaining()]; - buf.get(bytes); - buf.rewind(); - } - - SGIImage image = SGIImage.createFromData(data.getWidth(), - data.getHeight(), - (pixelFormat == GL.GL_RGBA), - bytes); - image.write(file, false); - return true; - } - - throw new IOException("SGI writer doesn't support this pixel format / type (only GL_RGB/A + bytes)"); - } - - return false; - } - } - - //---------------------------------------------------------------------- - // TGA (Targa) texture writer - - static class TGATextureWriter implements TextureWriter { - public boolean write(File file, - TextureData data) throws IOException { - if (TGA.equals(FileUtil.getFileSuffix(file))) { - // See whether the TGA writer can handle this TextureData - int pixelFormat = data.getPixelFormat(); - int pixelType = data.getPixelType(); - if ((pixelFormat == GL.GL_RGB || - pixelFormat == GL.GL_RGBA) && - (pixelType == GL.GL_BYTE || - pixelType == GL.GL_UNSIGNED_BYTE)) { - ByteBuffer buf = ((data.getBuffer() != null) ? - (ByteBuffer) data.getBuffer() : - (ByteBuffer) data.getMipmapData()[0]); - // Must reverse order of red and blue channels to get correct results - int skip = ((pixelFormat == GL.GL_RGB) ? 3 : 4); - for (int i = 0; i < buf.remaining(); i += skip) { - byte red = buf.get(i + 0); - byte blue = buf.get(i + 2); - buf.put(i + 0, blue); - buf.put(i + 2, red); - } - - TGAImage image = TGAImage.createFromData(data.getWidth(), - data.getHeight(), - (pixelFormat == GL.GL_RGBA), - false, - ((data.getBuffer() != null) ? - (ByteBuffer) data.getBuffer() : - (ByteBuffer) data.getMipmapData()[0])); - image.write(file); - return true; - } - - throw new IOException("TGA writer doesn't support this pixel format / type (only GL_RGB/A + bytes)"); - } - - return false; - } - } - - //---------------------------------------------------------------------- - // Helper routines - // - - private static int glGetInteger(int pname) { - int[] tmp = new int[1]; - GL gl = GLContext.getCurrentGL(); - gl.glGetIntegerv(pname, tmp, 0); - return tmp[0]; - } - - private static int glGetTexLevelParameteri(GL2 gl, int target, int level, int pname) { - int[] tmp = new int[1]; - gl.glGetTexLevelParameteriv(target, 0, pname, tmp, 0); - return tmp[0]; - } - - private static String toLowerCase(String arg) { - if (arg == null) { - return null; - } - - return arg.toLowerCase(); - } -} diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javase b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java index e3092162d..e3092162d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javase +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javame_cdc_fp b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javame_cdc_fp deleted file mode 100644 index b18991dfc..000000000 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/DDSImage.java.javame_cdc_fp +++ /dev/null @@ -1,889 +0,0 @@ -/* - * Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package com.jogamp.opengl.util.texture.spi; - -import java.io.*; -import java.nio.*; - -import javax.media.opengl.*; -import com.jogamp.opengl.util.*; -import com.jogamp.opengl.util.texture.*; - -/** A reader and writer for DirectDraw Surface (.dds) files, which are - used to describe textures. These files can contain multiple mipmap - levels in one file. This class is currently minimal and does not - support all of the possible file formats. */ - -public class DDSImage { - - /** Simple class describing images and data; does not encapsulate - image format information. User is responsible for transmitting - that information in another way. */ - - public static class ImageInfo { - private ByteBuffer data; - private int width; - private int height; - private boolean isCompressed; - private int compressionFormat; - - public ImageInfo(ByteBuffer data, int width, int height, boolean compressed, int compressionFormat) { - this.data = data; this.width = width; this.height = height; - this.isCompressed = compressed; this.compressionFormat = compressionFormat; - } - public int getWidth() { return width; } - public int getHeight() { return height; } - public ByteBuffer getData() { return data; } - public boolean isCompressed() { return isCompressed; } - public int getCompressionFormat() { - if (!isCompressed()) - throw new RuntimeException("Should not call unless compressed"); - return compressionFormat; - } - } - - private ByteBuffer buf; - private Header header; - - // - // Selected bits in header flags - // - - public static final int DDSD_CAPS = 0x00000001; // Capacities are valid - public static final int DDSD_HEIGHT = 0x00000002; // Height is valid - public static final int DDSD_WIDTH = 0x00000004; // Width is valid - public static final int DDSD_PITCH = 0x00000008; // Pitch is valid - public static final int DDSD_BACKBUFFERCOUNT = 0x00000020; // Back buffer count is valid - public static final int DDSD_ZBUFFERBITDEPTH = 0x00000040; // Z-buffer bit depth is valid (shouldn't be used in DDSURFACEDESC2) - public static final int DDSD_ALPHABITDEPTH = 0x00000080; // Alpha bit depth is valid - public static final int DDSD_LPSURFACE = 0x00000800; // lpSurface is valid - public static final int DDSD_PIXELFORMAT = 0x00001000; // ddpfPixelFormat is valid - public static final int DDSD_MIPMAPCOUNT = 0x00020000; // Mip map count is valid - public static final int DDSD_LINEARSIZE = 0x00080000; // dwLinearSize is valid - public static final int DDSD_DEPTH = 0x00800000; // dwDepth is valid - - public static final int DDPF_ALPHAPIXELS = 0x00000001; // Alpha channel is present - public static final int DDPF_ALPHA = 0x00000002; // Only contains alpha information - public static final int DDPF_FOURCC = 0x00000004; // FourCC code is valid - public static final int DDPF_PALETTEINDEXED4 = 0x00000008; // Surface is 4-bit color indexed - public static final int DDPF_PALETTEINDEXEDTO8 = 0x00000010; // Surface is indexed into a palette which stores indices - // into the destination surface's 8-bit palette - public static final int DDPF_PALETTEINDEXED8 = 0x00000020; // Surface is 8-bit color indexed - public static final int DDPF_RGB = 0x00000040; // RGB data is present - public static final int DDPF_COMPRESSED = 0x00000080; // Surface will accept pixel data in the format specified - // and compress it during the write - public static final int DDPF_RGBTOYUV = 0x00000100; // Surface will accept RGB data and translate it during - // the write to YUV data. The format of the data to be written - // will be contained in the pixel format structure. The DDPF_RGB - // flag will be set. - public static final int DDPF_YUV = 0x00000200; // Pixel format is YUV - YUV data in pixel format struct is valid - public static final int DDPF_ZBUFFER = 0x00000400; // Pixel format is a z buffer only surface - public static final int DDPF_PALETTEINDEXED1 = 0x00000800; // Surface is 1-bit color indexed - public static final int DDPF_PALETTEINDEXED2 = 0x00001000; // Surface is 2-bit color indexed - public static final int DDPF_ZPIXELS = 0x00002000; // Surface contains Z information in the pixels - - // Selected bits in DDS capabilities flags - public static final int DDSCAPS_TEXTURE = 0x00001000; // Can be used as a texture - public static final int DDSCAPS_MIPMAP = 0x00400000; // Is one level of a mip-map - public static final int DDSCAPS_COMPLEX = 0x00000008; // Complex surface structure, such as a cube map - - // Selected bits in DDS extended capabilities flags - public static final int DDSCAPS2_CUBEMAP = 0x00000200; - public static final int DDSCAPS2_CUBEMAP_POSITIVEX = 0x00000400; - public static final int DDSCAPS2_CUBEMAP_NEGATIVEX = 0x00000800; - public static final int DDSCAPS2_CUBEMAP_POSITIVEY = 0x00001000; - public static final int DDSCAPS2_CUBEMAP_NEGATIVEY = 0x00002000; - public static final int DDSCAPS2_CUBEMAP_POSITIVEZ = 0x00004000; - public static final int DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x00008000; - - // Known pixel formats - public static final int D3DFMT_UNKNOWN = 0; - public static final int D3DFMT_R8G8B8 = 20; - public static final int D3DFMT_A8R8G8B8 = 21; - public static final int D3DFMT_X8R8G8B8 = 22; - // The following are also valid FourCC codes - public static final int D3DFMT_DXT1 = 0x31545844; - public static final int D3DFMT_DXT2 = 0x32545844; - public static final int D3DFMT_DXT3 = 0x33545844; - public static final int D3DFMT_DXT4 = 0x34545844; - public static final int D3DFMT_DXT5 = 0x35545844; - - /** Reads a DirectDraw surface from the specified file name, - returning the resulting DDSImage. - - @param filename File name - @return DDS image object - @throws java.io.IOException if an I/O exception occurred - */ - public static DDSImage read(String filename) throws IOException { - return read(new File(filename)); - } - - /** Reads a DirectDraw surface from the specified file, returning - the resulting DDSImage. - - @param file File object - @return DDS image object - @throws java.io.IOException if an I/O exception occurred - */ - public static DDSImage read(File file) throws IOException { - DDSImage image = new DDSImage(); - image.readFromFile(file); - return image; - } - - /** Reads a DirectDraw surface from the specified InputStream, returning - the resulting DDSImage. - - @param input Input stream - @return DDS image object - @throws java.io.IOException if an I/O exception occurred - */ - public static DDSImage read(InputStream input) throws IOException { - DDSImage image = new DDSImage(); - image.readFromStream(input); - return image; - } - - /** Closes open files and resources associated with the open - DDSImage. No other methods may be called on this object once - this is called. */ - public void close() { - } - - /** - * Creates a new DDSImage from data supplied by the user. The - * resulting DDSImage can be written to disk using the write() - * method. - * - * @param d3dFormat the D3DFMT_ constant describing the data; it is - * assumed that it is packed tightly - * @param width the width in pixels of the topmost mipmap image - * @param height the height in pixels of the topmost mipmap image - * @param mipmapData the data for each mipmap level of the resulting - * DDSImage; either only one mipmap level should - * be specified, or they all must be - * @throws IllegalArgumentException if the data does not match the - * specified arguments - * @return DDS image object - */ - public static DDSImage createFromData(int d3dFormat, - int width, - int height, - ByteBuffer[] mipmapData) throws IllegalArgumentException { - DDSImage image = new DDSImage(); - image.initFromData(d3dFormat, width, height, mipmapData); - return image; - } - - /** Determines from the magic number whether the given InputStream - points to a DDS image. The given InputStream must return true - from markSupported() and support a minimum of four bytes of - read-ahead. - - @param in Stream to check - @return true if input stream is DDS image or false otherwise - @throws java.io.IOException if an I/O exception occurred - */ - public static boolean isDDSImage(InputStream in) throws IOException { - if (!(in instanceof BufferedInputStream)) { - in = new BufferedInputStream(in); - } - if (!in.markSupported()) { - throw new IOException("Can not test non-destructively whether given InputStream is a DDS image"); - } - in.mark(4); - int magic = 0; - for (int i = 0; i < 4; i++) { - int tmp = in.read(); - if (tmp < 0) { - in.reset(); - return false; - } - magic = ((magic >>> 8) | (tmp << 24)); - } - in.reset(); - return (magic == MAGIC); - } - - /** - * Writes this DDSImage to the specified file name. - * @param filename File name to write to - * @throws java.io.IOException if an I/O exception occurred - */ - public void write(String filename) throws IOException { - write(new File(filename)); - } - - /** - * Writes this DDSImage to the specified file name. - * @param file File object to write to - * @throws java.io.IOException if an I/O exception occurred - */ - public void write(File file) throws IOException { - LEDataOutputStream output = - new LEDataOutputStream(new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)))); - header.write(output); - output.write(buf.array()); - output.close(); - } - - /** Test for presence/absence of surface description flags (DDSD_*) - * @param flag DDSD_* flags set to test - * @return true if flag present or false otherwise - */ - public boolean isSurfaceDescFlagSet(int flag) { - return ((header.flags & flag) != 0); - } - - /** Test for presence/absence of pixel format flags (DDPF_*) */ - public boolean isPixelFormatFlagSet(int flag) { - return ((header.pfFlags & flag) != 0); - } - - /** Gets the pixel format of this texture (D3DFMT_*) based on some - heuristics. Returns D3DFMT_UNKNOWN if could not recognize the - pixel format. */ - public int getPixelFormat() { - if (isCompressed()) { - return getCompressionFormat(); - } else if (isPixelFormatFlagSet(DDPF_RGB)) { - if (isPixelFormatFlagSet(DDPF_ALPHAPIXELS)) { - if (getDepth() == 32 && - header.pfRBitMask == 0x00FF0000 && - header.pfGBitMask == 0x0000FF00 && - header.pfBBitMask == 0x000000FF && - header.pfABitMask == 0xFF000000) { - return D3DFMT_A8R8G8B8; - } - } else { - if (getDepth() == 24 && - header.pfRBitMask == 0x00FF0000 && - header.pfGBitMask == 0x0000FF00 && - header.pfBBitMask == 0x000000FF) { - return D3DFMT_R8G8B8; - } else if (getDepth() == 32 && - header.pfRBitMask == 0x00FF0000 && - header.pfGBitMask == 0x0000FF00 && - header.pfBBitMask == 0x000000FF) { - return D3DFMT_X8R8G8B8; - } - } - } - - return D3DFMT_UNKNOWN; - } - - /** - * Indicates whether this texture is cubemap - * @return true if cubemap or false otherwise - */ - public boolean isCubemap() { - return ((header.ddsCaps1 & DDSCAPS_COMPLEX) != 0) && ((header.ddsCaps2 & DDSCAPS2_CUBEMAP) != 0); - } - - /** - * Indicates whethe this cubemap side present - * @param side Side to test - * @return true if side present or false otherwise - */ - public boolean isCubemapSidePresent(int side) { - return isCubemap() && (header.ddsCaps2 & side) != 0; - } - - /** Indicates whether this texture is compressed. */ - public boolean isCompressed() { - return (isPixelFormatFlagSet(DDPF_FOURCC)); - } - - /** If this surface is compressed, returns the kind of compression - used (DXT1..DXT5). */ - public int getCompressionFormat() { - return header.pfFourCC; - } - - /** Width of the texture (or the top-most mipmap if mipmaps are - present) */ - public int getWidth() { - return header.width; - } - - /** Height of the texture (or the top-most mipmap if mipmaps are - present) */ - public int getHeight() { - return header.height; - } - - /** Total number of bits per pixel. Only valid if DDPF_RGB is - present. For A8R8G8B8, would be 32. */ - public int getDepth() { - return header.pfRGBBitCount; - } - - /** Number of mip maps in the texture */ - public int getNumMipMaps() { - if (!isSurfaceDescFlagSet(DDSD_MIPMAPCOUNT)) { - return 0; - } - return header.mipMapCountOrAux; - } - - /** Gets the <i>i</i>th mipmap data (0..getNumMipMaps() - 1) - * @param map Mipmap index - * @return Image object - */ - public ImageInfo getMipMap(int map) { - return getMipMap( 0, map ); - } - - /** - * Gets the <i>i</i>th mipmap data (0..getNumMipMaps() - 1) - * @param side Cubemap side or 0 for 2D texture - * @param map Mipmap index - * @return Image object - */ - public ImageInfo getMipMap(int side, int map) { - if (!isCubemap() && (side != 0)) { - throw new RuntimeException( "Illegal side for 2D texture: " + side ); - } - if (isCubemap() && !isCubemapSidePresent(side)) { - throw new RuntimeException( "Illegal side, side not present: " + side ); - } - if (getNumMipMaps() > 0 && - ((map < 0) || (map >= getNumMipMaps()))) { - throw new RuntimeException("Illegal mipmap number " + map + " (0.." + (getNumMipMaps() - 1) + ")"); - } - - // Figure out how far to seek - int seek = 0; - if (isCubemap()) { - seek += sideShiftInBytes(side); - } - for (int i = 0; i < map; i++) { - seek += mipMapSizeInBytes(i); - } - buf.limit(seek + mipMapSizeInBytes(map)); - buf.position(seek); - ByteBuffer next = buf.slice(); - buf.position(0); - buf.limit(buf.capacity()); - return new ImageInfo(next, mipMapWidth(map), mipMapHeight(map), isCompressed(), getCompressionFormat()); - } - - /** Returns an array of ImageInfos corresponding to all mipmap - levels of this DDS file. - @return Mipmap image objects set - */ - public ImageInfo[] getAllMipMaps() { - return getAllMipMaps(0); - } - - /** - * Returns an array of ImageInfos corresponding to all mipmap - * levels of this DDS file. - * @param side Cubemap side or 0 for 2D texture - * @return Mipmap image objects set - */ - public ImageInfo[] getAllMipMaps( int side ) { - int numLevels = getNumMipMaps(); - if (numLevels == 0) { - numLevels = 1; - } - ImageInfo[] result = new ImageInfo[numLevels]; - for (int i = 0; i < numLevels; i++) { - result[i] = getMipMap(side, i); - } - return result; - } - - /** Converts e.g. DXT1 compression format constant (see {@link - #getCompressionFormat}) into "DXT1". - @param compressionFormat Compression format constant - @return String format code - */ - public static String getCompressionFormatName(int compressionFormat) { - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < 4; i++) { - char c = (char) (compressionFormat & 0xFF); - buf.append(c); - compressionFormat = compressionFormat >> 8; - } - return buf.toString(); - } - - /** Allocates a temporary, empty ByteBuffer suitable for use in a - call to glCompressedTexImage2D. This is used by the Texture - class to expand non-power-of-two DDS compressed textures to - power-of-two sizes on hardware not supporting OpenGL 2.0 and the - NPOT texture extension. The specified OpenGL internal format - must be one of GL_COMPRESSED_RGB_S3TC_DXT1_EXT, - GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, - GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, or - GL_COMPRESSED_RGBA_S3TC_DXT5_EXT. - */ - public static ByteBuffer allocateBlankBuffer(int width, - int height, - int openGLInternalFormat) { - int size = width * height; - switch (openGLInternalFormat) { - case GL.GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - case GL.GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - size /= 2; - break; - - case GL.GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL.GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - break; - - default: - throw new IllegalArgumentException("Illegal OpenGL texture internal format " + - openGLInternalFormat); - } - if (size == 0) - size = 1; - return GLBuffers.newDirectByteBuffer(size); - } - - public void debugPrint() { - PrintStream tty = System.err; - tty.println("Compressed texture: " + isCompressed()); - if (isCompressed()) { - int fmt = getCompressionFormat(); - String name = getCompressionFormatName(fmt); - tty.println("Compression format: 0x" + Integer.toHexString(fmt) + " (" + name + ")"); - } - tty.println("Width: " + header.width + " Height: " + header.height); - tty.println("header.pitchOrLinearSize: " + header.pitchOrLinearSize); - tty.println("header.pfRBitMask: 0x" + Integer.toHexString(header.pfRBitMask)); - tty.println("header.pfGBitMask: 0x" + Integer.toHexString(header.pfGBitMask)); - tty.println("header.pfBBitMask: 0x" + Integer.toHexString(header.pfBBitMask)); - tty.println("SurfaceDesc flags:"); - boolean recognizedAny = false; - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_CAPS, "DDSD_CAPS"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_HEIGHT, "DDSD_HEIGHT"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_WIDTH, "DDSD_WIDTH"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_PITCH, "DDSD_PITCH"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_BACKBUFFERCOUNT, "DDSD_BACKBUFFERCOUNT"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_ZBUFFERBITDEPTH, "DDSD_ZBUFFERBITDEPTH"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_ALPHABITDEPTH, "DDSD_ALPHABITDEPTH"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_LPSURFACE, "DDSD_LPSURFACE"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_PIXELFORMAT, "DDSD_PIXELFORMAT"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_MIPMAPCOUNT, "DDSD_MIPMAPCOUNT"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_LINEARSIZE, "DDSD_LINEARSIZE"); - recognizedAny |= printIfRecognized(tty, header.flags, DDSD_DEPTH, "DDSD_DEPTH"); - if (!recognizedAny) { - tty.println("(none)"); - } - tty.println("Raw SurfaceDesc flags: 0x" + Integer.toHexString(header.flags)); - tty.println("Pixel format flags:"); - recognizedAny = false; - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_ALPHAPIXELS, "DDPF_ALPHAPIXELS"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_ALPHA, "DDPF_ALPHA"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_FOURCC, "DDPF_FOURCC"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_PALETTEINDEXED4, "DDPF_PALETTEINDEXED4"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_PALETTEINDEXEDTO8, "DDPF_PALETTEINDEXEDTO8"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_PALETTEINDEXED8, "DDPF_PALETTEINDEXED8"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_RGB, "DDPF_RGB"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_COMPRESSED, "DDPF_COMPRESSED"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_RGBTOYUV, "DDPF_RGBTOYUV"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_YUV, "DDPF_YUV"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_ZBUFFER, "DDPF_ZBUFFER"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_PALETTEINDEXED1, "DDPF_PALETTEINDEXED1"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_PALETTEINDEXED2, "DDPF_PALETTEINDEXED2"); - recognizedAny |= printIfRecognized(tty, header.pfFlags, DDPF_ZPIXELS, "DDPF_ZPIXELS"); - if (!recognizedAny) { - tty.println("(none)"); - } - tty.println("Raw pixel format flags: 0x" + Integer.toHexString(header.pfFlags)); - tty.println("Depth: " + getDepth()); - tty.println("Number of mip maps: " + getNumMipMaps()); - int fmt = getPixelFormat(); - tty.print("Pixel format: "); - switch (fmt) { - case D3DFMT_R8G8B8: tty.println("D3DFMT_R8G8B8"); break; - case D3DFMT_A8R8G8B8: tty.println("D3DFMT_A8R8G8B8"); break; - case D3DFMT_X8R8G8B8: tty.println("D3DFMT_X8R8G8B8"); break; - case D3DFMT_DXT1: tty.println("D3DFMT_DXT1"); break; - case D3DFMT_DXT2: tty.println("D3DFMT_DXT2"); break; - case D3DFMT_DXT3: tty.println("D3DFMT_DXT3"); break; - case D3DFMT_DXT4: tty.println("D3DFMT_DXT4"); break; - case D3DFMT_DXT5: tty.println("D3DFMT_DXT5"); break; - case D3DFMT_UNKNOWN: tty.println("D3DFMT_UNKNOWN"); break; - default: tty.println("(unknown pixel format " + fmt + ")"); break; - } - } - - //---------------------------------------------------------------------- - // Internals only below this point - // - - private static final int MAGIC = 0x20534444; - - static class Header { - int size; // size of the DDSURFACEDESC structure - int flags; // determines what fields are valid - int height; // height of surface to be created - int width; // width of input surface - int pitchOrLinearSize; - int backBufferCountOrDepth; - int mipMapCountOrAux; // number of mip-map levels requested (in this context) - int alphaBitDepth; // depth of alpha buffer requested - int reserved1; // reserved - int surface; // pointer to the associated surface memory - // NOTE: following two entries are from DDCOLORKEY data structure - // Are overlaid with color for empty cubemap faces (unused in this reader) - int colorSpaceLowValue; - int colorSpaceHighValue; - int destBltColorSpaceLowValue; - int destBltColorSpaceHighValue; - int srcOverlayColorSpaceLowValue; - int srcOverlayColorSpaceHighValue; - int srcBltColorSpaceLowValue; - int srcBltColorSpaceHighValue; - // NOTE: following entries are from DDPIXELFORMAT data structure - // Are overlaid with flexible vertex format description of vertex - // buffers (unused in this reader) - int pfSize; // size of DDPIXELFORMAT structure - int pfFlags; // pixel format flags - int pfFourCC; // (FOURCC code) - // Following five entries have multiple interpretations, not just - // RGBA (but that's all we support right now) - int pfRGBBitCount; // how many bits per pixel - int pfRBitMask; // mask for red bits - int pfGBitMask; // mask for green bits - int pfBBitMask; // mask for blue bits - int pfABitMask; // mask for alpha channel - int ddsCaps1; // Texture and mip-map flags - int ddsCaps2; // Advanced capabilities including cubemap support - int ddsCapsReserved1; - int ddsCapsReserved2; - int textureStage; // stage in multitexture cascade - - void read(LEDataInputStream input) throws IOException { - int magic = input.readInt(); - if (magic != MAGIC) { - throw new IOException("Incorrect magic number 0x" + - Integer.toHexString(magic) + - " (expected " + MAGIC + ")"); - } - - size = input.readInt(); - flags = input.readInt(); - height = input.readInt(); - width = input.readInt(); - pitchOrLinearSize = input.readInt(); - backBufferCountOrDepth = input.readInt(); - mipMapCountOrAux = input.readInt(); - alphaBitDepth = input.readInt(); - reserved1 = input.readInt(); - surface = input.readInt(); - colorSpaceLowValue = input.readInt(); - colorSpaceHighValue = input.readInt(); - destBltColorSpaceLowValue = input.readInt(); - destBltColorSpaceHighValue = input.readInt(); - srcOverlayColorSpaceLowValue = input.readInt(); - srcOverlayColorSpaceHighValue = input.readInt(); - srcBltColorSpaceLowValue = input.readInt(); - srcBltColorSpaceHighValue = input.readInt(); - pfSize = input.readInt(); - pfFlags = input.readInt(); - pfFourCC = input.readInt(); - pfRGBBitCount = input.readInt(); - pfRBitMask = input.readInt(); - pfGBitMask = input.readInt(); - pfBBitMask = input.readInt(); - pfABitMask = input.readInt(); - ddsCaps1 = input.readInt(); - ddsCaps2 = input.readInt(); - ddsCapsReserved1 = input.readInt(); - ddsCapsReserved2 = input.readInt(); - textureStage = input.readInt(); - } - - // buf must be in little-endian byte order - void write(LEDataOutputStream output) throws IOException { - output.writeInt(MAGIC); - output.writeInt(size); - output.writeInt(flags); - output.writeInt(height); - output.writeInt(width); - output.writeInt(pitchOrLinearSize); - output.writeInt(backBufferCountOrDepth); - output.writeInt(mipMapCountOrAux); - output.writeInt(alphaBitDepth); - output.writeInt(reserved1); - output.writeInt(surface); - output.writeInt(colorSpaceLowValue); - output.writeInt(colorSpaceHighValue); - output.writeInt(destBltColorSpaceLowValue); - output.writeInt(destBltColorSpaceHighValue); - output.writeInt(srcOverlayColorSpaceLowValue); - output.writeInt(srcOverlayColorSpaceHighValue); - output.writeInt(srcBltColorSpaceLowValue); - output.writeInt(srcBltColorSpaceHighValue); - output.writeInt(pfSize); - output.writeInt(pfFlags); - output.writeInt(pfFourCC); - output.writeInt(pfRGBBitCount); - output.writeInt(pfRBitMask); - output.writeInt(pfGBitMask); - output.writeInt(pfBBitMask); - output.writeInt(pfABitMask); - output.writeInt(ddsCaps1); - output.writeInt(ddsCaps2); - output.writeInt(ddsCapsReserved1); - output.writeInt(ddsCapsReserved2); - output.writeInt(textureStage); - } - - private static int size() { - return 124; - } - - private static int pfSize() { - return 32; - } - - private static int writtenSize() { - return 128; - } - } - - private DDSImage() { - } - - private void readFromFile(File file) throws IOException { - readFromStream(new BufferedInputStream(new FileInputStream(file))); - } - - private void readFromStream(InputStream input) throws IOException { - LEDataInputStream leInput = new LEDataInputStream(input); - header = new Header(); - header.read(leInput); - fixupHeader(); - buf = StreamUtil.readAll2Buffer(input); - } - - private void initFromData(int d3dFormat, - int width, - int height, - ByteBuffer[] mipmapData) throws IllegalArgumentException { - // Check size of mipmap data compared against format, width and - // height - int topmostMipmapSize = width * height; - int pitchOrLinearSize = width; - boolean isCompressed = false; - switch (d3dFormat) { - case D3DFMT_R8G8B8: topmostMipmapSize *= 3; pitchOrLinearSize *= 3; break; - case D3DFMT_A8R8G8B8: topmostMipmapSize *= 4; pitchOrLinearSize *= 4; break; - case D3DFMT_X8R8G8B8: topmostMipmapSize *= 4; pitchOrLinearSize *= 4; break; - case D3DFMT_DXT1: - case D3DFMT_DXT2: - case D3DFMT_DXT3: - case D3DFMT_DXT4: - case D3DFMT_DXT5: - topmostMipmapSize = computeCompressedBlockSize(width, height, 1, d3dFormat); - pitchOrLinearSize = topmostMipmapSize; - isCompressed = true; - break; - default: - throw new IllegalArgumentException("d3dFormat must be one of the known formats"); - } - - // Now check the mipmaps against this size - int curSize = topmostMipmapSize; - int totalSize = 0; - for (int i = 0; i < mipmapData.length; i++) { - if (mipmapData[i].remaining() != curSize) { - throw new IllegalArgumentException("Mipmap level " + i + - " didn't match expected data size (expected " + curSize + ", got " + - mipmapData[i].remaining() + ")"); - } - curSize /= 4; - totalSize += mipmapData[i].remaining(); - } - - // OK, create one large byte array to hold all of the mipmap data - byte[] data = new byte[totalSize]; - ByteBuffer buf = ByteBuffer.wrap(data); - for (int i = 0; i < mipmapData.length; i++) { - buf.put(mipmapData[i]); - } - this.buf = buf; - - // Allocate and initialize a Header - header = new Header(); - header.size = Header.size(); - header.flags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT; - if (mipmapData.length > 1) { - header.flags |= DDSD_MIPMAPCOUNT; - header.mipMapCountOrAux = mipmapData.length; - } - header.width = width; - header.height = height; - if (isCompressed) { - header.flags |= DDSD_LINEARSIZE; - header.pfFlags |= DDPF_FOURCC; - header.pfFourCC = d3dFormat; - } else { - header.flags |= DDSD_PITCH; - // Figure out the various settings from the pixel format - header.pfFlags |= DDPF_RGB; - switch (d3dFormat) { - case D3DFMT_R8G8B8: header.pfRGBBitCount = 24; break; - case D3DFMT_A8R8G8B8: header.pfRGBBitCount = 32; header.pfFlags |= DDPF_ALPHAPIXELS; break; - case D3DFMT_X8R8G8B8: header.pfRGBBitCount = 32; break; - } - header.pfRBitMask = 0x00FF0000; - header.pfGBitMask = 0x0000FF00; - header.pfBBitMask = 0x000000FF; - if (d3dFormat == D3DFMT_A8R8G8B8) { - header.pfABitMask = 0xFF000000; - } - } - header.pitchOrLinearSize = pitchOrLinearSize; - header.pfSize = Header.pfSize(); - // Not sure whether we can get away with leaving the rest of the - // header blank - } - - // Microsoft doesn't follow their own specifications and the - // simplest conversion using the DxTex tool to e.g. a DXT3 texture - // results in an illegal .dds file without either DDSD_PITCH or - // DDSD_LINEARSIZE set in the header's flags. This code, adapted - // from the DevIL library, fixes up the header in these situations. - private void fixupHeader() { - if (isCompressed() && !isSurfaceDescFlagSet(DDSD_LINEARSIZE)) { - // Figure out how big the linear size should be - int depth = header.backBufferCountOrDepth; - if (depth == 0) { - depth = 1; - } - - header.pitchOrLinearSize = computeCompressedBlockSize(getWidth(), getHeight(), depth, getCompressionFormat()); - header.flags |= DDSD_LINEARSIZE; - } - } - - private static int computeCompressedBlockSize(int width, - int height, - int depth, - int compressionFormat) { - int blockSize = ((width + 3)/4) * ((height + 3)/4) * ((depth + 3)/4); - switch (compressionFormat) { - case D3DFMT_DXT1: blockSize *= 8; break; - default: blockSize *= 16; break; - } - return blockSize; - } - - private int mipMapWidth(int map) { - int width = getWidth(); - for (int i = 0; i < map; i++) { - width >>= 1; - } - return Math.max(width, 1); - } - - private int mipMapHeight(int map) { - int height = getHeight(); - for (int i = 0; i < map; i++) { - height >>= 1; - } - return Math.max(height, 1); - } - - private int mipMapSizeInBytes(int map) { - int width = mipMapWidth(map); - int height = mipMapHeight(map); - if (isCompressed()) { - int blockSize = (getCompressionFormat() == D3DFMT_DXT1 ? 8 : 16); - return ((width+3)/4)*((height+3)/4)*blockSize; - } else { - return width * height * (getDepth() / 8); - } - } - - private int sideSizeInBytes() { - int numLevels = getNumMipMaps(); - if (numLevels == 0) { - numLevels = 1; - } - - int size = 0; - for (int i = 0; i < numLevels; i++) { - size += mipMapSizeInBytes(i); - } - - return size; - } - - private int sideShiftInBytes(int side) { - int[] sides = { - DDSCAPS2_CUBEMAP_POSITIVEX, - DDSCAPS2_CUBEMAP_NEGATIVEX, - DDSCAPS2_CUBEMAP_POSITIVEY, - DDSCAPS2_CUBEMAP_NEGATIVEY, - DDSCAPS2_CUBEMAP_POSITIVEZ, - DDSCAPS2_CUBEMAP_NEGATIVEZ - }; - - int shift = 0; - int sideSize = sideSizeInBytes(); - for (int i = 0; i < sides.length; i++) { - int temp = sides[i]; - if ((temp & side) != 0) { - return shift; - } - - shift += sideSize; - } - - throw new RuntimeException("Illegal side: " + side); - } - - private boolean printIfRecognized(PrintStream tty, int flags, int flag, String what) { - if ((flags & flag) != 0) { - tty.println(what); - return true; - } - return false; - } -} diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java.javase b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java index 16ba538b5..16ba538b5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java.javase +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp deleted file mode 100644 index 6e6e4ab04..000000000 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/TGAImage.java.javame_cdc_fp +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package com.jogamp.opengl.util.texture.spi; - -import java.io.*; -import java.nio.*; -import javax.media.opengl.*; -import com.jogamp.opengl.util.*; -import com.jogamp.opengl.util.texture.spi.*; -import com.jogamp.opengl.util.texture.*; - -/** - * Targa image reader and writer adapted from sources of the <a href = - * "http://java.sun.com/products/jimi/">Jimi</a> image I/O class library. - * - * <P> - * - * Image decoder for image data stored in TGA file format. - * Currently only the original TGA file format is supported. This is - * because the new TGA format has data at the end of the file, getting - * to the end of a file in an InputStream orient environment presents - * several difficulties which are avoided at the moment. - * - * <P> - * - * This is a simple decoder and is only setup to load a single image - * from the input stream - * - * <P> - * - * @author Robin Luiten - * @author Kenneth Russell - * @version $Revision: 1768 $ - */ - -public class TGAImage { - private Header header; - private int format; - private int bpp; - private ByteBuffer data; - - private TGAImage(Header header) { - this.header = header; - } - - /** - * This class reads in all of the TGA image header in addition it also - * reads in the imageID field as it is convenient to handle that here. - * - * @author Robin Luiten - * @version 1.1 - */ - public static class Header { - /** Set of possible file format TGA types */ - public final static int TYPE_NEW = 0; - public final static int TYPE_OLD = 1; - public final static int TYPE_UNK = 2; // cant rewind stream so unknown for now. - - /** Set of possible image types in TGA file */ - public final static int NO_IMAGE = 0; // no image data - public final static int UCOLORMAPPED = 1; // uncompressed color mapped image - public final static int UTRUECOLOR = 2; // uncompressed true color image - public final static int UBLACKWHITE = 3; // uncompressed black and white image - public final static int COLORMAPPED = 9; // compressed color mapped image - public final static int TRUECOLOR = 10; // compressed true color image - public final static int BLACKWHITE = 11; // compressed black and white image - - /** Field image descriptor bitfield values definitions */ - public final static int ID_ATTRIBPERPIXEL = 0xF; - public final static int ID_RIGHTTOLEFT = 0x10; - public final static int ID_TOPTOBOTTOM = 0x20; - public final static int ID_INTERLEAVE = 0xC0; - - /** Field image descriptor / interleave values */ - public final static int I_NOTINTERLEAVED = 0; - public final static int I_TWOWAY = 1; - public final static int I_FOURWAY = 2; - - /** Type of this TGA file format */ - private int tgaType; - - /** initial TGA image data fields */ - private int idLength; // byte value - private int colorMapType; // byte value - private int imageType; // byte value - - /** TGA image colour map fields */ - private int firstEntryIndex; - private int colorMapLength; - private byte colorMapEntrySize; - - /** TGA image specification fields */ - private int xOrigin; - private int yOrigin; - private int width; - private int height; - private byte pixelDepth; - private byte imageDescriptor; - - private byte[] imageIDbuf; - private String imageID; - - // For construction from user data - Header() { - tgaType = TYPE_OLD; // dont try and get footer. - } - - Header(LEDataInputStream in) throws IOException { - int ret; - - tgaType = TYPE_OLD; // dont try and get footer. - - // initial header fields - idLength = in.readUnsignedByte(); - colorMapType = in.readUnsignedByte(); - imageType = in.readUnsignedByte(); - - // color map header fields - firstEntryIndex = in.readUnsignedShort(); - colorMapLength = in.readUnsignedShort(); - colorMapEntrySize = in.readByte(); - - // TGA image specification fields - xOrigin = in.readUnsignedShort(); - yOrigin = in.readUnsignedShort(); - width = in.readUnsignedShort(); - height = in.readUnsignedShort(); - pixelDepth = in.readByte(); - imageDescriptor = in.readByte(); - - if (idLength > 0) { - imageIDbuf = new byte[idLength]; - in.read(imageIDbuf, 0, idLength); - imageID = new String(imageIDbuf, "US-ASCII"); - } - } - - public int tgaType() { return tgaType; } - - /** initial TGA image data fields */ - public int idLength() { return idLength; } - public int colorMapType() { return colorMapType; } - public int imageType() { return imageType; } - - /** TGA image colour map fields */ - public int firstEntryIndex() { return firstEntryIndex; } - public int colorMapLength() { return colorMapLength; } - public byte colorMapEntrySize() { return colorMapEntrySize; } - - /** TGA image specification fields */ - public int xOrigin() { return xOrigin; } - public int yOrigin() { return yOrigin; } - public int width() { return width; } - public int height() { return height; } - public byte pixelDepth() { return pixelDepth; } - public byte imageDescriptor() { return imageDescriptor; } - - /** bitfields in imageDescriptor */ - public byte attribPerPixel() { return (byte)(imageDescriptor & ID_ATTRIBPERPIXEL); } - public boolean rightToLeft() { return ((imageDescriptor & ID_RIGHTTOLEFT) != 0); } - public boolean topToBottom() { return ((imageDescriptor & ID_TOPTOBOTTOM) != 0); } - public byte interleave() { return (byte)((imageDescriptor & ID_INTERLEAVE) >> 6); } - - public byte[] imageIDbuf() { return imageIDbuf; } - public String imageID() { return imageID; } - - public String toString() { - return "TGA Header " + - " id length: " + idLength + - " color map type: "+ colorMapType + - " image type: "+ imageType + - " first entry index: " + firstEntryIndex + - " color map length: " + colorMapLength + - " color map entry size: " + colorMapEntrySize + - " x Origin: " + xOrigin + - " y Origin: " + yOrigin + - " width: "+ width + - " height: "+ height + - " pixel depth: "+ pixelDepth + - " image descriptor: "+ imageDescriptor + - (imageIDbuf == null ? "" : (" ID String: " + imageID)); - } - - public int size() { return 18 + idLength; } - - private void write(LEDataOutputStream output) throws IOException { - output.write(idLength); - output.write(colorMapType); - output.write(imageType); - output.writeShort(firstEntryIndex); - output.writeShort(colorMapLength); - output.write(colorMapEntrySize); - output.writeShort(xOrigin); - output.writeShort(yOrigin); - output.writeShort(width); - output.writeShort(height); - output.write(pixelDepth); - output.write(imageDescriptor); - if (idLength > 0) { - try { - byte[] chars = imageID.getBytes("US-ASCII"); - output.write(chars); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } - } - } - - - /** - * Identifies the image type of the tga image data and loads - * it into the JimiImage structure. This was taken from the - * prototype and modified for the new Jimi structure - */ - private void decodeImage(LEDataInputStream dIn) throws IOException { - switch (header.imageType()) { - case Header.UCOLORMAPPED: - throw new IOException("TGADecoder Uncompressed Colormapped images not supported"); - - case Header.UTRUECOLOR: // pixelDepth 15, 16, 24 and 32 - switch (header.pixelDepth) { - case 16: - throw new IOException("TGADecoder Compressed 16-bit True Color images not supported"); - - case 24: - case 32: - decodeRGBImageU24_32(dIn); - break; - } - break; - - case Header.UBLACKWHITE: - throw new IOException("TGADecoder Uncompressed Grayscale images not supported"); - - case Header.COLORMAPPED: - throw new IOException("TGADecoder Compressed Colormapped images not supported"); - - case Header.TRUECOLOR: - throw new IOException("TGADecoder Compressed True Color images not supported"); - - case Header.BLACKWHITE: - throw new IOException("TGADecoder Compressed Grayscale images not supported"); - } - } - - /** - * This assumes that the body is for a 24 bit or 32 bit for a - * RGB or ARGB image respectively. - */ - private void decodeRGBImageU24_32(LEDataInputStream dIn) throws IOException { - int i; // row index - int j; // column index - int y; // output row index - int raw; // index through the raw input buffer - int rawWidth = header.width() * (header.pixelDepth() / 8); - byte[] rawBuf = new byte[rawWidth]; - byte[] tmpData = new byte[rawWidth * header.height()]; - - for (i = 0; i < header.height(); ++i) { - dIn.readFully(rawBuf, 0, rawWidth); - - if (header.topToBottom()) - y = header.height - i - 1; // range 0 to (header.height - 1) - else - y = i; - - System.arraycopy(rawBuf, 0, tmpData, y * rawWidth, rawBuf.length); - } - - GL gl = GLContext.getCurrentGL(); - if (header.pixelDepth() == 24) { - bpp=3; - if(gl.isGL2GL3()) { - format = GL2GL3.GL_BGR; - } else { - format = GL.GL_RGB; - swapBGR(tmpData, rawWidth, header.height(), bpp); - } - } else { - assert header.pixelDepth() == 32; - bpp=4; - - if(gl.isGL2GL3()) { - format = GL2GL3.GL_BGRA; - } else { - format = GL.GL_RGBA; - swapBGR(tmpData, rawWidth, header.height(), bpp); - } - } - - data = ByteBuffer.wrap(tmpData); - } - - private static void swapBGR(byte[] data, int bWidth, int height, int bpp) { - byte r,b; - int k; - for(int i=0; i<height; ++i) { - for(int j=0; j<bWidth; j+=bpp) { - k=i*bWidth+j; - b=data[k+0]; - r=data[k+2]; - data[k+0]=r; - data[k+2]=b; - } - } - } - - /** Returns the width of the image. */ - public int getWidth() { return header.width(); } - - /** Returns the height of the image. */ - public int getHeight() { return header.height(); } - - /** Returns the OpenGL format for this texture; e.g. GL.GL_BGR or GL.GL_BGRA. */ - public int getGLFormat() { return format; } - - /** Returns the bytes per pixel */ - public int getBytesPerPixel() { return bpp; } - - /** Returns the raw data for this texture in the correct - (bottom-to-top) order for calls to glTexImage2D. */ - public ByteBuffer getData() { return data; } - - /** Reads a Targa image from the specified file. */ - public static TGAImage read(String filename) throws IOException { - return read(new FileInputStream(filename)); - } - - /** Reads a Targa image from the specified InputStream. */ - public static TGAImage read(InputStream in) throws IOException { - LEDataInputStream dIn = new LEDataInputStream(new BufferedInputStream(in)); - - Header header = new Header(dIn); - TGAImage res = new TGAImage(header); - res.decodeImage(dIn); - return res; - } - - /** Writes the image in Targa format to the specified file name. */ - public void write(String filename) throws IOException { - write(new File(filename)); - } - - /** Writes the image in Targa format to the specified file. */ - public void write(File file) throws IOException { - LEDataOutputStream output = - new LEDataOutputStream(new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)))); - header.write(output); - if (!data.isDirect()) { - output.write(data.array()); - } else { - for (int i = 0; i < data.limit(); i++) { - output.write(data.get(i)); - } - } - output.close(); - } - - /** Creates a TGAImage from data supplied by the end user. Shares - data with the passed ByteBuffer. Assumes the data is already in - the correct byte order for writing to disk, i.e., BGR or - BGRA. */ - public static TGAImage createFromData(int width, - int height, - boolean hasAlpha, - boolean topToBottom, - ByteBuffer data) { - Header header = new Header(); - header.imageType = Header.UTRUECOLOR; - header.width = width; - header.height = height; - header.pixelDepth = (byte) (hasAlpha ? 32 : 24); - header.imageDescriptor = (byte) (topToBottom ? Header.ID_TOPTOBOTTOM : 0); - // Note ID not supported - TGAImage ret = new TGAImage(header); - ret.data = data; - return ret; - } -} diff --git a/src/jogl/classes/jogamp/opengl/SystemUtil.java.javase b/src/jogl/classes/jogamp/opengl/SystemUtil.java index befe1a315..befe1a315 100644 --- a/src/jogl/classes/jogamp/opengl/SystemUtil.java.javase +++ b/src/jogl/classes/jogamp/opengl/SystemUtil.java diff --git a/src/jogl/classes/jogamp/opengl/SystemUtil.java.javame_cdc_fp b/src/jogl/classes/jogamp/opengl/SystemUtil.java.javame_cdc_fp deleted file mode 100644 index ab42de359..000000000 --- a/src/jogl/classes/jogamp/opengl/SystemUtil.java.javame_cdc_fp +++ /dev/null @@ -1,10 +0,0 @@ -package jogamp.opengl; - -public class SystemUtil { - - /** Wrapper for System.getenv(), which doesn't work on platforms - earlier than JDK 5 */ - public static String getenv(String variableName) { - return null; - } -} |