diff options
-rw-r--r-- | make/build-jogl.xml | 75 | ||||
-rw-r--r-- | make/build.xml | 6 | ||||
-rw-r--r-- | make/lib/gluegen.compiler.linux-32bit.xml | 31 | ||||
-rw-r--r-- | make/make.jogl.all.linux-x86.sh | 1 | ||||
-rw-r--r-- | make/make.jogl.cdcfp.linux-x86.sh | 1 | ||||
-rwxr-xr-x | src/jogl/classes/com/sun/opengl/util/texture/TextureData.java | 64 | ||||
-rwxr-xr-x | src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java | 45 |
7 files changed, 200 insertions, 23 deletions
diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 6f97a336e..ba92540b8 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -215,6 +215,7 @@ <target name="base.init.sourcelevel.1"> <property name="jogl.sourcelevel" value="1.4" /> + <property name="junit.sourcelevel" value="1.5" /> </target> <!--target name="base.init.sourcelevel.2" if="gluegen.nsig"> @@ -264,6 +265,7 @@ </condition> <property name="rootrel.build.jogl" value="${rootrel.build}/jogl" /> <property name="rootrel.src.java" value="src/jogl/classes" /> + <property name="rootrel.src.junit" value="src/jogl/junit" /> <property name="rootrel.src.c" value="src/jogl/native" /> <property name="rootrel.src.c.openmax" value="src/jogl/native/openmax" /> @@ -283,16 +285,22 @@ <property name="gluegen.build.xml" value="${gluegen.make.dir}/build.xml" /> <property name="gluegen.jar" value="${gluegen.root}/${rootrel.build}/gluegen.jar" /> <property name="gluegen-rt.jar" value="${gluegen.root}/${rootrel.build}/gluegen-rt.jar" /> + <property name="gluegen.so.dir" value="${gluegen.root}/${rootrel.build}/obj" /> + <property name="junit.jar" value="${gluegen.make.dir}/lib/junit-4.5.jar" /> <property name="nativewindow.core.jar" value="../${rootrel.build}/nativewindow/nativewindow.core.jar" /> <property name="nativewindow.x11.jar" value="../${rootrel.build}/nativewindow/nativewindow.x11.jar" /> <property name="nativewindow.awt.jar" value="../${rootrel.build}/nativewindow/nativewindow.awt.jar" /> + <property name="nativewindow.so.dir" value="../${rootrel.build}/nativewindow/obj" /> <property name="gluegen-rt-cdc.jar" value="${gluegen.root}/${rootrel.build}/gluegen-rt-cdc.jar" /> <property name="nativewindow.core.cdc.jar" value="../${rootrel.build}/nativewindow/nativewindow.core.cdc.jar" /> <property name="nativewindow.x11.cdc.jar" value="../${rootrel.build}/nativewindow/nativewindow.x11.cdc.jar" /> + <property name="newt.so.dir" value="../${rootrel.build}/newt/obj" /> + <!-- The source directories. --> <property name="src.java" value="${project.root}/${rootrel.src.java}" /> + <property name="src.junit" value="${project.root}/${rootrel.src.junit}" /> <property name="src.c" value="${project.root}/${rootrel.src.c}" /> <property name="build" value="${project.root}/${rootrel.build.jogl}" /> <property name="tempdir" value="${project.root}/build-temp" /> @@ -313,6 +321,8 @@ <property name="obj.jogl" value="${project.root}/${rootrel.obj.jogl}" /> <property name="obj.cg" value="${project.root}/${rootrel.obj.cg}" /> + <property name="all.so.dir" value="${gluegen.so.dir}:${nativewindow.so.dir}:${obj}:${newt.so.dir}" /> + <!-- The GL headers from which Java files are generated --> <property name="config" value="${make}/config/jogl" /> <property name="stub.includes" value="${make}/stub_includes" /> @@ -411,6 +421,7 @@ <property name="jogl.sdk.jar" value="${build}/jogl.sdk.jar" /> <property name="jogl.all.jar" value="${build}/jogl.all.jar"/> <property name="jogl.all-noawt.jar" value="${build}/jogl.all-noawt.jar"/> + <property name="jogl.test.jar" value="${build}/jogl.test.jar"/> <!-- The resulting CDC jogl.jar. --> <property name="jogl.core.cdc.jar" value="${build}/jogl.core.cdc.jar" /> @@ -428,6 +439,25 @@ <property name="jogl.util.fixedfuncemu.cdc.jar" value="${build}/jogl.util.fixedfuncemu.cdc.jar" /> <property name="jogl.all.cdc.jar" value="${build}/jogl.all.cdc.jar"/> + <path id="jogl_junit.compile.classpath"> + <pathelement location="${junit.jar}" /> + <pathelement location="${gluegen-rt.jar}" /> + <pathelement location="${nativewindow.core.jar}" /> + <pathelement location="${nativewindow.x11.jar}" /> + <pathelement location="${nativewindow.awt.jar}" /> + <pathelement location="${jogl.all.jar}" /> + </path> + + <path id="jogl_junit.run.classpath"> + <pathelement location="${junit.jar}" /> + <pathelement location="${gluegen-rt.jar}" /> + <pathelement location="${nativewindow.core.jar}" /> + <pathelement location="${nativewindow.x11.jar}" /> + <pathelement location="${nativewindow.awt.jar}" /> + <pathelement location="${jogl.all.jar}" /> + <pathelement location="${jogl.test.jar}" /> + </path> + <!-- The javadoc dirs. --> <property name="javadoc" value="${project.root}/javadoc_jogl_public" /> <property name="javadoc.spec" value="${project.root}/javadoc_jogl_spec" /> @@ -2041,9 +2071,52 @@ <!-- ================================================================== --> <!-- + - Build/run junit. + --> + <target name="junit.compile"> + <!-- Perform the junit pass Java compile --> + <javac destdir="${classes}" + source="${junit.sourcelevel}" + fork="yes" + memoryMaximumSize="${javac.memorymax}" + debug="${javacdebug}" debuglevel="${javacdebuglevel}"> + <classpath refid="jogl_junit.compile.classpath"/> + <src path="${src.junit}" /> + </javac> + <jar destfile="${jogl.test.jar}" filesonly="true"> + <fileset dir="${classes}"> + <include name="com/jogamp/opengl/test/**" /> + </fileset> + </jar> + </target> + + <target name="junit.run" depends="declare.common"> + <condition property="system.env.library.path" + value="LD_LIBRARY_PATH"> + <not> + <isset property="isWindows"/> + </not> + </condition> + <condition property="system.env.library.path" + value="PATH"> + <isset property="isWindows"/> + </condition> + + <!-- Perform the junit pass Java compile --> + <java fork="true" + classname="org.junit.runner.JUnitCore" + failonerror="true"> + <env key="${system.env.library.path}" path="${all.so.dir}"/> + <arg value="com.jogamp.opengl.test.junit.texture.awt.Texture1"/> + <classpath refid="jogl_junit.run.classpath"/> + </java> + </target> + + <!-- ================================================================== --> + <!-- - Build everything. --> - <target name="all" description="Build JOGL JAR file(s) and native libraries." depends="load.user.properties,init,jar,c.build.jogl,generate.version.txt" /> + <target name="all" description="Build JOGL JAR file(s) and native libraries." depends="load.user.properties,init,jar,c.build.jogl,generate.version.txt,junit.compile" /> <target name="setup-version-RI" if="jogl.ri"> <property name="tmp.version" value="${jogl_base_version}" /> diff --git a/make/build.xml b/make/build.xml index b3a77945c..b8b3872ca 100644 --- a/make/build.xml +++ b/make/build.xml @@ -74,6 +74,10 @@ <ant antfile="${jogl.build.xml}" dir="${jogl.make.dir}" target="all" inheritAll="false"/> </target> + <target name="junit.run.jogl" depends="init"> + <ant antfile="${jogl.build.xml}" dir="${jogl.make.dir}" target="junit.run" inheritAll="false"/> + </target> + <target name="build.newt" depends="init"> <ant antfile="${newt.build.xml}" dir="${newt.make.dir}" target="all" inheritAll="false"/> </target> @@ -178,6 +182,8 @@ <target name="all" description="Build nativewindow, jogl and newt projects" depends="init,build.nativewindow,build.jogl,build.newt,one-lib-dir,developer-zip-archive,source-archive" /> + <target name="junit.run" description="Run JUNIT tests in nativewindow, jogl and newt projects" depends="init,junit.run.jogl" /> + <target name="clean" depends="init"> <ant antfile="${nativewindow.build.xml}" dir="${nativewindow.make.dir}" target="clean" inheritAll="false"/> <ant antfile="${jogl.build.xml}" dir="${jogl.make.dir}" target="clean" inheritAll="false"/> diff --git a/make/lib/gluegen.compiler.linux-32bit.xml b/make/lib/gluegen.compiler.linux-32bit.xml new file mode 100644 index 000000000..344d9da27 --- /dev/null +++ b/make/lib/gluegen.compiler.linux-32bit.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + This is an example of how to add custom compiler/linker + arguments for a crosscompiler. + + You can use such files with setting the property 'gluegen.user.compiler.file', ie: + + -Dgluegen.user.compiler.file=`pwd`/lib/gluegen.compiler.xml + + or by having such file in your home directory, ie: + + ~/gluegen.compiler.xml + --> + +<project name="GlueGen-cpptasks" basedir="." > + +<target name="gluegen.cpptasks.configure.compiler" depends="setup.java.home.dir"> + <compiler id="compiler.cfg.linux" name="gcc"> + <compilerarg value="-m32" /> + <compilerarg value="-Wall" /> + <defineset> + <define name="LINUX" /> + </defineset> + </compiler> + + <linker id="linker.cfg.linux" name="gcc"> + <linkerarg value="-m32" /> + </linker> +</target> +</project> diff --git a/make/make.jogl.all.linux-x86.sh b/make/make.jogl.all.linux-x86.sh index 081d8328b..5387cf97a 100644 --- a/make/make.jogl.all.linux-x86.sh +++ b/make/make.jogl.all.linux-x86.sh @@ -17,6 +17,7 @@ fi # -Djogl.cg=1 -Dx11.cg.lib=../../lib-linux-x86 \ ant \ + -Dgluegen.user.compiler.file=`pwd`/lib/gluegen.compiler.linux-32bit.xml \ -Dbuild.noarchives=true \ -Djogl.cg=1 -Dx11.cg.lib=../../lib-linux-x86 \ -Drootrel.build=build-x86 \ diff --git a/make/make.jogl.cdcfp.linux-x86.sh b/make/make.jogl.cdcfp.linux-x86.sh index 4a2241669..d212bd81d 100644 --- a/make/make.jogl.cdcfp.linux-x86.sh +++ b/make/make.jogl.cdcfp.linux-x86.sh @@ -15,6 +15,7 @@ fi BUILD_SUBDIR=build-cdcfp-x86 ant -v \ + -Dgluegen.user.compiler.file=`pwd`/lib/gluegen.compiler.linux-32bit.xml \ -Dbuild.noarchives=true \ -Drootrel.build=$BUILD_SUBDIR \ -Dsetup.cdcfp=true \ diff --git a/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java b/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java index 8ac4b9b84..81124b060 100755 --- a/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/sun/opengl/util/texture/TextureData.java @@ -71,6 +71,10 @@ public class TextureData { protected int alignment; // 1, 2, or 4 bytes protected int estimatedMemorySize; + // specialization of this class might need GL dependent post initialization + protected Object glPostInitSync = new Object(); + protected volatile boolean glPostInitDone = false; + // These booleans are a concession to the AWTTextureData subclass protected boolean haveEXTABGR; protected boolean haveGL12; @@ -207,45 +211,71 @@ public class TextureData { } /** Used only by subclasses */ - protected TextureData() { - } + protected TextureData() { } /** Returns the width in pixels of the texture data. */ public int getWidth() { return width; } /** Returns the height in pixels of the texture data. */ public int getHeight() { return height; } /** Returns the border in pixels of the texture data. */ - public int getBorder() { return border; } + public int getBorder() { + glPostInitInt(); + return border; + } /** Returns the intended OpenGL pixel format of the texture data. */ public int getPixelFormat() { + glPostInitInt(); return pixelFormat; } /** Returns the intended OpenGL pixel type of the texture data. */ public int getPixelType() { + glPostInitInt(); return pixelType; } /** Returns the intended OpenGL internal format of the texture data. */ - public int getInternalFormat() { return internalFormat; } + public int getInternalFormat() { + glPostInitInt(); + return internalFormat; + } /** Returns whether mipmaps should be generated for the texture data. */ - public boolean getMipmap() { return mipmap; } + public boolean getMipmap() { + glPostInitInt(); + return mipmap; + } /** Indicates whether the texture data is in compressed form. */ - public boolean isDataCompressed() { return dataIsCompressed; } + public boolean isDataCompressed() { + glPostInitInt(); + return dataIsCompressed; + } /** Indicates whether the texture coordinates must be flipped vertically for proper display. */ - public boolean getMustFlipVertically() { return mustFlipVertically; } + public boolean getMustFlipVertically() { + glPostInitInt(); + return mustFlipVertically; + } /** Returns the texture data, or null if it is specified as a set of mipmaps. */ public Buffer getBuffer() { + glPostInitInt(); return buffer; } /** Returns all mipmap levels for the texture data, or null if it is specified as a single image. */ - public Buffer[] getMipmapData() { return mipmapData; } + public Buffer[] getMipmapData() { + glPostInitInt(); + return mipmapData; + } /** Returns the required byte alignment for the texture data. */ - public int getAlignment() { return alignment; } + public int getAlignment() { + glPostInitInt(); + return alignment; + } /** Returns the row length needed for correct GL_UNPACK_ROW_LENGTH specification. This is currently only supported for non-mipmapped, non-compressed textures. */ - public int getRowLength() { return rowLength; } + public int getRowLength() { + glPostInitInt(); + return rowLength; + } /** Sets the width in pixels of the texture data. */ public void setWidth(int width) { this.width = width; } @@ -303,6 +333,7 @@ public class TextureData { /** Flushes resources associated with this TextureData by calling Flusher.flush(). */ public void flush() { + glPostInitInt(); if (flusher != null) { flusher.flush(); flusher = null; @@ -333,6 +364,19 @@ public class TextureData { // Internals only below this point // + protected void glPostInit() { } + + protected final void glPostInitInt() { + if(glPostInitDone) return; + synchronized(glPostInitSync) { + if(!glPostInitDone) { + glPostInit(); + glPostInitDone = true; + } + glPostInitSync.notifyAll(); + } + } + protected static int estimatedMemorySize(Buffer buffer) { if (buffer == null) { return 0; diff --git a/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java b/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java index b3cf537f6..e949883ed 100755 --- a/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java +++ b/src/jogl/classes/com/sun/opengl/util/texture/awt/AWTTextureData.java @@ -56,6 +56,9 @@ public class AWTTextureData extends TextureData { private boolean expectingEXTABGR; private boolean expectingGL12; + private int scanlineStride; + private BufferedImage glDependingImage; // indicator wheather GL depening initialization has been passed + private static final ColorModel rgbaColorModel = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), new int[] {8, 8, 8, 8}, true, true, @@ -99,20 +102,14 @@ public class AWTTextureData extends TextureData { } else { this.internalFormat = internalFormat; } - createFromImage(image); + createFromImagePre(image); + this.mipmap = mipmap; - if (buffer != null) { - estimatedMemorySize = estimatedMemorySize(buffer); - } else { - // In the lazy custom conversion case we don't yet have a buffer - if (imageForLazyCustomConversion != null) { - estimatedMemorySize = estimatedMemorySize(wrapImageDataBuffer(imageForLazyCustomConversion)); - } - } } /** Returns the intended OpenGL pixel format of the texture data. */ public int getPixelFormat() { + glPostInitInt(); if (imageForLazyCustomConversion != null) { if (!((expectingEXTABGR && haveEXTABGR) || (expectingGL12 && haveGL12))) { @@ -123,6 +120,7 @@ public class AWTTextureData extends TextureData { } /** Returns the intended OpenGL pixel type of the texture data. */ public int getPixelType() { + glPostInitInt(); if (imageForLazyCustomConversion != null) { if (!((expectingEXTABGR && haveEXTABGR) || (expectingGL12 && haveGL12))) { @@ -134,6 +132,7 @@ public class AWTTextureData extends TextureData { /** Returns the texture data, or null if it is specified as a set of mipmaps. */ public Buffer getBuffer() { + glPostInitInt(); if (imageForLazyCustomConversion != null) { if (!((expectingEXTABGR && haveEXTABGR) || (expectingGL12 && haveGL12))) { @@ -146,14 +145,13 @@ public class AWTTextureData extends TextureData { return buffer; } - private void createFromImage(BufferedImage image) { + private void createFromImagePre(BufferedImage image) { pixelType = 0; // Determine from image mustFlipVertically = true; width = image.getWidth(); height = image.getHeight(); - int scanlineStride; SampleModel sm = image.getRaster().getSampleModel(); if (sm instanceof SinglePixelPackedSampleModel) { scanlineStride = @@ -169,8 +167,22 @@ public class AWTTextureData extends TextureData { setupLazyCustomConversion(image); return; } + glDependingImage = image; // earmark for post init + } + + protected void glPostInit() { + if(null == glDependingImage) return; + + GLContext current = GLContext.getCurrent(); + if(null == current) return; - GLProfile glp = GLContext.getCurrentGL().getGLProfile(); + BufferedImage image = glDependingImage; + glDependingImage = null; + + GLProfile glp = current.getGL().getGLProfile(); + + width = image.getWidth(); + height = image.getHeight(); if (glp.isGL2()) { switch (image.getType()) { @@ -365,6 +377,15 @@ public class AWTTextureData extends TextureData { } createNIOBufferFromImage(image); + + if (buffer != null) { + estimatedMemorySize = estimatedMemorySize(buffer); + } else { + // In the lazy custom conversion case we don't yet have a buffer + if (imageForLazyCustomConversion != null) { + estimatedMemorySize = estimatedMemorySize(wrapImageDataBuffer(imageForLazyCustomConversion)); + } + } } private void setupLazyCustomConversion(BufferedImage image) { |