More progress, Windows build is definitely broken for now

This commit is contained in:
Michael Pfaff 2022-08-09 21:59:46 -04:00
parent 119cfd7369
commit 134263f5cd
Signed by: michael
GPG Key ID: CF402C4A012AA9D4
33 changed files with 592 additions and 547 deletions

3
.gitignore vendored
View File

@ -6,6 +6,5 @@
/src/native/common/Release /src/native/common/Release
/src/native/windows/Debug /src/native/windows/Debug
/src/native/windows/Release /src/native/windows/Release
/src/native/*/org_lwjgl_*.h /src/native/**/*.h
/src/native/*/*/org_lwjgl_*.h
/src/native/linux/org_lwjgl_opengl_Display.c /src/native/linux/org_lwjgl_opengl_Display.c

View File

@ -1 +1 @@
java adoptopenjdk-8.0.322+6 java temurin-17.0.3+7

357
build.xml
View File

@ -16,6 +16,8 @@
<!-- ================================================================== --> <!-- ================================================================== -->
<target name="-initialize"> <target name="-initialize">
<mkdir dir="${lwjgl.target.bundle}" taskname="initialiazing bundle folder" /> <mkdir dir="${lwjgl.target.bundle}" taskname="initialiazing bundle folder" />
<mkdir dir="${lwjgl.target.natives}" taskname="initialiazing native libs folder" />
<mkdir dir="${lwjgl.target.jars}" taskname="initialiazing java libs folder" />
</target> </target>
<!-- Cleans up any files created during the execution of this script --> <!-- Cleans up any files created during the execution of this script -->
@ -25,8 +27,6 @@
<!-- Creates a distribution of LWJGL --> <!-- Creates a distribution of LWJGL -->
<target name="release" description="Creates a distribution of LWJGL using supplied native binaries"> <target name="release" description="Creates a distribution of LWJGL using supplied native binaries">
<!-- Warn user -->
<echo message="Before running the release target, please manually compile all platforms and place required files in ${lwjgl.lib}/windows, ${lwjgl.lib}/linux, ${lwjgl.lib}/freebsd and ${lwjgl.lib}/macosx${line.separator}Missing files will result in a successfull built, but with incomplete release zips"/>
<input <input
message="All data in the ${lwjgl.target} folder will be deleted. Continue? " message="All data in the ${lwjgl.target} folder will be deleted. Continue? "
validargs="yes,no" validargs="yes,no"
@ -51,7 +51,6 @@
<antcall target="compile" /> <antcall target="compile" />
<antcall target="-createjars" /> <antcall target="-createjars" />
<antcall target="-jars_NoDEP" />
<antcall target="javadoc" /> <antcall target="javadoc" />
<!-- copy resources to res folder --> <!-- copy resources to res folder -->
@ -76,21 +75,11 @@
<!-- Create ONLY the jar archives --> <!-- Create ONLY the jar archives -->
<target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, generate-all, compile, -createjars"> <target name="jars" description="Creates the Java archives ONLY and places them in libs/" depends="-initialize, generate-all, compile, -createjars">
<antcall target="-jars_NoDEP" />
</target> </target>
<!-- Create ONLY the jar archives for the ES build --> <!-- Create ONLY the jar archives for the ES build -->
<target name="jars_es" description="Creates the Java archives ONLY for the ES build and places them in libs/" <target name="jars_es" description="Creates the Java archives ONLY for the ES build and places them in libs/"
depends="-initialize, generate-all, compile, -createjars_es"> depends="-initialize, generate-all, compile, -createjars_es">
<antcall target="-jars_NoDEP"/>
</target>
<target name="-jars_NoDEP">
<move todir="libs/">
<fileset dir="${lwjgl.target.staging}/jar">
<include name="*.jar"/>
</fileset>
</move>
</target> </target>
<!-- Packages the java files --> <!-- Packages the java files -->
@ -108,7 +97,7 @@
<!-- Packages the java files --> <!-- Packages the java files -->
<target name="-createjars"> <target name="-createjars">
<!-- Create lwjgl.jar --> <!-- Create lwjgl.jar -->
<jar destfile="${lwjgl.target.staging}/jar/lwjgl.jar" taskname="lwjgl.jar"> <jar destfile="${lwjgl.target.jars}/lwjgl.jar" taskname="lwjgl.jar">
<fileset refid="lwjgl.fileset" /> <fileset refid="lwjgl.fileset" />
<fileset refid="lwjgl.fileset.dependencies"/> <fileset refid="lwjgl.fileset.dependencies"/>
<manifest> <manifest>
@ -117,13 +106,13 @@
</jar> </jar>
<!-- Create lwjgl_test.jar --> <!-- Create lwjgl_test.jar -->
<jar destfile="${lwjgl.target.staging}/jar/lwjgl_test.jar" taskname="lwjgl_test.jar"> <jar destfile="${lwjgl.target.jars}/lwjgl_test.jar" taskname="lwjgl_test.jar">
<fileset refid="lwjgl_test.fileset" /> <fileset refid="lwjgl_test.fileset" />
<fileset refid="lwjgl_test_extra.fileset" /> <fileset refid="lwjgl_test_extra.fileset" />
</jar> </jar>
<!-- Create lwjgl_util.jar --> <!-- Create lwjgl_util.jar -->
<jar destfile="${lwjgl.target.staging}/jar/lwjgl_util.jar" taskname="lwjgl_util.jar"> <jar destfile="${lwjgl.target.jars}/lwjgl_util.jar" taskname="lwjgl_util.jar">
<fileset refid="lwjgl_util.fileset" /> <fileset refid="lwjgl_util.fileset" />
</jar> </jar>
</target> </target>
@ -175,144 +164,202 @@
</jar> </jar>
</target> </target>
<!-- Distributes files -->
<target name="-distribute">
<delete>
<fileset dir="${lwjgl.target.staging}/native/" includes="**/*"/>
</delete>
<copy todir="${lwjgl.target.staging}/jar">
<fileset dir="${lwjgl.lib}/" includes="*.jar"/>
</copy>
<copy todir="${lwjgl.target.staging}/native/windows">
<fileset dir="${lwjgl.lib}/windows">
<patternset refid="lwjgl-windows.fileset" />
</fileset>
</copy>
<copy todir="${lwjgl.target.staging}/native/linux">
<fileset dir="${lwjgl.lib}/linux">
<patternset refid="lwjgl-linux.fileset" />
</fileset>
</copy>
<copy todir="${lwjgl.target.staging}/native/freebsd" failonerror="false">
<fileset dir="${lwjgl.lib}/freebsd">
<patternset refid="lwjgl-freebsd.fileset" />
</fileset>
</copy>
<copy todir="${lwjgl.target.staging}/native/openbsd" failonerror="false">
<fileset dir="${lwjgl.lib}/openbsd">
<patternset refid="lwjgl-openbsd.fileset" />
</fileset>
</copy>
<copy todir="${lwjgl.target.staging}/native/macosx">
<fileset dir="${lwjgl.lib}/macosx">
<patternset refid="lwjgl-macosx.fileset" />
</fileset>
</copy>
<copy todir="${lwjgl.target.staging}/native/solaris">
<fileset dir="${lwjgl.lib}/solaris">
<patternset refid="lwjgl-solaris.fileset" />
</fileset>
</copy>
<!-- create base package -->
<zip destfile="${lwjgl.target.bundle}/lwjgl-${lwjgl.version}.zip">
<zipfileset dir="${lwjgl.target.staging}" prefix="lwjgl-${lwjgl.version}/">
<patternset refid="lwjgl_base"/>
</zipfileset>
</zip>
</target>
<!-- Creates a versioned distribution of javadocs -->
<target name="-distribution_javadoc">
<zip destfile="${lwjgl.target.bundle}/lwjgl-docs-${lwjgl.version}.zip" basedir="${lwjgl.target.doc}" includes="javadoc/**" />
</target>
<!-- Creates a versioned distribution of the source code -->
<target name="-distribution_source">
<zip destfile="${lwjgl.target.bundle}/lwjgl-source-${lwjgl.version}.zip">
<fileset refid="lwjgl.source.fileset" />
</zip>
</target>
<!-- Generates the native headers from source files --> <!-- Generates the native headers from source files -->
<target name="headers" description="invokes javah on java classes" depends="compile"> <target name="headers" description="invokes javah on java classes" depends="compile">
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.native}/linux"> <javac
<class name="org.lwjgl.LinuxSysImplementation" /> srcdir="${lwjgl.target.gen.java}"
<class name="org.lwjgl.opengl.LinuxEvent" /> source="1.8"
<class name="org.lwjgl.opengl.LinuxMouse" /> target="1.8"
<class name="org.lwjgl.opengl.LinuxKeyboard" /> fork="true"
<class name="org.lwjgl.opengl.LinuxDisplay" /> taskname="headers">
<class name="org.lwjgl.opengl.LinuxPeerInfo" /> <compilerarg value="-cp"/>
</javah> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-h"/>
<compilerarg value="${lwjgl.src.native}/linux"/>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.native}/linux/opengl"> <src>
<class name="org.lwjgl.opengl.LinuxPbufferPeerInfo"/> <fileset dir="${lwjgl.target.gen.java}">
<class name="org.lwjgl.opengl.LinuxDisplayPeerInfo"/> <include name="org/lwjgl/LinuxSysImplementation.java"/>
<class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo"/> <include name="org/lwjgl/opengl/LinuxEvent.java"/>
<class name="org.lwjgl.opengl.LinuxContextImplementation"/> <include name="org/lwjgl/opengl/LinuxMouse.java"/>
<class name="org.lwjgl.opengl.LinuxCanvasImplementation"/> <include name="org/lwjgl/opengl/LinuxKeyboard.java"/>
</javah> <include name="org/lwjgl/opengl/LinuxDisplay.java"/>
<include name="org/lwjgl/opengl/LinuxPeerInfo.java"/>
</fileset>
</src>
</javac>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.native}/windows"> <javac
<class name="org.lwjgl.WindowsSysImplementation"/> srcdir="${lwjgl.target.gen.java}"
<class name="org.lwjgl.opengl.WindowsKeyboard" /> source="1.8"
<class name="org.lwjgl.opengl.WindowsRegistry" /> target="1.8"
<class name="org.lwjgl.opengl.WindowsDisplay"/> fork="true"
<class name="org.lwjgl.opengl.WindowsDisplayPeerInfo"/> taskname="headers">
<class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo"/> <compilerarg value="-cp"/>
</javah> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-h"/>
<compilerarg value="${lwjgl.src.native}/linux/opengl"/>
<src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/opengl/LinuxPbufferPeerInfo.java"/>
<include name="org/lwjgl/opengl/LinuxDisplayPeerInfo.java"/>
<include name="org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java"/>
<include name="org/lwjgl/opengl/LinuxContextImplementation.java"/>
<include name="org/lwjgl/opengl/LinuxCanvasImplementation.java"/>
</fileset>
</src>
</javac>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.native}/windows/opengl"> <javac
<class name="org.lwjgl.opengl.WindowsPbufferPeerInfo"/> srcdir="${lwjgl.target.gen.java}"
<class name="org.lwjgl.opengl.WindowsPeerInfo"/> source="1.8"
<class name="org.lwjgl.opengl.WindowsContextImplementation"/> target="1.8"
</javah> fork="true"
taskname="headers">
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-h"/>
<compilerarg value="${lwjgl.src.native}/windows"/>
<src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/WindowsSysImplementation.java"/>
<include name="org/lwjgl/opengl/WindowsKeyboard.java"/>
<include name="org/lwjgl/opengl/WindowsRegistry.java"/>
<include name="org/lwjgl/opengl/WindowsDisplay.java"/>
<include name="org/lwjgl/opengl/WindowsDisplayPeerInfo.java"/>
<include name="org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java"/>
</fileset>
</src>
</javac>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.native}/windows/opengles"> <javac
<class name="org.lwjgl.opengl.WindowsPeerInfo"/> srcdir="${lwjgl.target.gen.java}"
</javah> source="1.8"
target="1.8"
fork="true"
taskname="headers">
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-h"/>
<compilerarg value="${lwjgl.src.native}/windows/opengl"/>
<src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/opengl/WindowsPbufferPeerInfo.java"/>
<include name="org/lwjgl/opengl/WindowsPeerInfo.java"/>
<include name="org/lwjgl/opengl/WindowsContextImplementation.java"/>
</fileset>
</src>
</javac>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.native}/macosx"> <javac
<class name="org.lwjgl.MacOSXSysImplementation" /> srcdir="${lwjgl.target.gen.java}"
<class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" /> source="1.8"
<class name="org.lwjgl.opengl.MacOSXPeerInfo" /> target="1.8"
<class name="org.lwjgl.opengl.MacOSXPbufferPeerInfo" /> fork="true"
<class name="org.lwjgl.opengl.MacOSXDisplay" /> taskname="headers">
<class name="org.lwjgl.opengl.MacOSXContextImplementation" /> <compilerarg value="-cp"/>
<class name="org.lwjgl.opengl.MacOSXNativeKeyboard" /> <compilerarg path="${lwjgl.target.gen.classes}"/>
<class name="org.lwjgl.opengl.MacOSXNativeMouse" /> <compilerarg value="-h"/>
<class name="org.lwjgl.opengl.MacOSXMouseEventQueue" /> <compilerarg value="${lwjgl.src.native}/windows/opengles"/>
</javah> <src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/opengl/WindowsPeerInfo.java"/>
</fileset>
</src>
</javac>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.headers}"> <javac
<class name="org.lwjgl.opengl.AWTSurfaceLock" /> srcdir="${lwjgl.target.gen.java}"
<class name="org.lwjgl.DefaultSysImplementation" /> source="1.8"
<class name="org.lwjgl.input.Cursor" /> target="1.8"
<class name="org.lwjgl.input.Keyboard" /> fork="true"
<class name="org.lwjgl.input.Mouse" /> taskname="headers">
<class name="org.lwjgl.openal.AL" /> <compilerarg value="-cp"/>
<class name="org.lwjgl.opencl.CL" /> <compilerarg path="${lwjgl.target.gen.classes}"/>
<class name="org.lwjgl.opencl.CallbackUtil" /> <compilerarg value="-h"/>
<class name="org.lwjgl.BufferUtils" /> <compilerarg value="${lwjgl.src.native}/macosx"/>
</javah> <src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/MacOSXSysImplementation.java"/>
<include name="org/lwjgl/opengl/MacOSXCanvasPeerInfo.java"/>
<include name="org/lwjgl/opengl/MacOSXPeerInfo.java"/>
<include name="org/lwjgl/opengl/MacOSXPbufferPeerInfo.java"/>
<include name="org/lwjgl/opengl/MacOSXDisplay.java"/>
<include name="org/lwjgl/opengl/MacOSXContextImplementation.java"/>
<include name="org/lwjgl/opengl/MacOSXNativeKeyboard.java"/>
<include name="org/lwjgl/opengl/MacOSXNativeMouse.java"/>
<include name="org/lwjgl/opengl/MacOSXMouseEventQueue.java"/>
</fileset>
</src>
</javac>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.headers}/opengl"> <javac
<class name="org.lwjgl.opengl.GLContext"/> srcdir="${lwjgl.target.gen.java}"
<class name="org.lwjgl.opengl.Pbuffer"/> source="1.8"
<class name="org.lwjgl.opengl.CallbackUtil"/> target="1.8"
<class name="org.lwjgl.opengl.NVPresentVideoUtil"/> fork="true"
<class name="org.lwjgl.opengl.NVVideoCaptureUtil"/> taskname="headers">
</javah> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-h"/>
<compilerarg value="${lwjgl.src.headers}"/>
<src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/opengl/AWTSurfaceLock.java"/>
<include name="org/lwjgl/DefaultSysImplementation.java"/>
<include name="org/lwjgl/input/Cursor.java"/>
<include name="org/lwjgl/input/Keyboard.java"/>
<include name="org/lwjgl/input/Mouse.java"/>
<include name="org/lwjgl/openal/AL.java"/>
<include name="org/lwjgl/opencl/CL.java"/>
<include name="org/lwjgl/opencl/CallbackUtil.java"/>
<include name="org/lwjgl/BufferUtils.java"/>
</fileset>
</src>
</javac>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.headers}/opengles"> <javac
<class name="org.lwjgl.opengles.EGL"/> srcdir="${lwjgl.target.gen.java}"
<class name="org.lwjgl.opengles.EGLKHRFenceSync"/> source="1.8"
<class name="org.lwjgl.opengles.EGLKHRReusableSync"/> target="1.8"
<class name="org.lwjgl.opengles.EGLNVSync"/> fork="true"
<class name="org.lwjgl.opengles.GLContext"/> taskname="headers">
<class name="org.lwjgl.opengles.CallbackUtil"/> <compilerarg value="-cp"/>
</javah> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-h"/>
<compilerarg value="${lwjgl.src.headers}/opengl"/>
<src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/opengl/GLContext.java"/>
<include name="org/lwjgl/opengl/Pbuffer.java"/>
<include name="org/lwjgl/opengl/CallbackUtil.java"/>
<include name="org/lwjgl/opengl/NVPresentVideoUtil.java"/>
<include name="org/lwjgl/opengl/NVVideoCaptureUtil.java"/>
</fileset>
</src>
</javac>
<javac
srcdir="${lwjgl.target.gen.java}"
source="1.8"
target="1.8"
fork="true"
taskname="headers">
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-h"/>
<compilerarg value="${lwjgl.src.headers}/opengles"/>
<src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/opengles/EGL.java"/>
<include name="org/lwjgl/opengles/EGLKHRFenceSync.java"/>
<include name="org/lwjgl/opengles/EGLKHRReusableSync.java"/>
<include name="org/lwjgl/opengles/EGLNVSync.java"/>
<include name="org/lwjgl/opengles/GLContext.java"/>
<include name="org/lwjgl/opengles/CallbackUtil.java"/>
</fileset>
</src>
</javac>
</target> </target>
<target name="touch-version"> <target name="touch-version">
@ -452,35 +499,23 @@
<!-- Compiles LWJGL on Win32 platforms --> <!-- Compiles LWJGL on Win32 platforms -->
<target name="-compile_native_win32" if="lwjgl.platform.windows"> <target name="-compile_native_win32" if="lwjgl.platform.windows">
<ant antfile="platform_build/windows_ant/build.xml"/> <ant antfile="platform_build/windows_ant/build.xml"/>
<copy todir="${lwjgl.lib}/windows">
<fileset dir="${lwjgl.target.gen.classes}/lwjgl" includes="lwjgl*.dll"/>
</copy>
<version-check platform="windows"/> <version-check platform="windows"/>
</target> </target>
<!-- Compiles LWJGL on Linux platforms --> <!-- Compiles LWJGL on Linux platforms -->
<target name="-compile_native_linux" if="lwjgl.platform.linux"> <target name="-compile_native_linux" if="lwjgl.platform.linux">
<ant antfile="platform_build/linux_ant/build.xml"/> <ant antfile="platform_build/linux_ant/build.xml"/>
<copy todir="${lwjgl.lib}/linux">
<fileset dir="${lwjgl.target.gen.classes}/lwjgl" includes="liblwjgl*.so"/>
</copy>
<!-- headless issues <version-check platform="linux"/> --> <!-- headless issues <version-check platform="linux"/> -->
</target> </target>
<!-- Compiles LWJGL on FreeBSD platforms --> <!-- Compiles LWJGL on FreeBSD platforms -->
<target name="-compile_native_freebsd" if="lwjgl.platform.freebsd"> <target name="-compile_native_freebsd" if="lwjgl.platform.freebsd">
<ant antfile="platform_build/bsd_ant/build.xml"/> <ant antfile="platform_build/bsd_ant/build.xml"/>
<copy todir="${lwjgl.lib}/freebsd">
<fileset dir="${lwjgl.target.gen.classes}/lwjgl" includes="liblwjgl*.so"/>
</copy>
</target> </target>
<!-- Compiles LWJGL on OpenBSD platforms --> <!-- Compiles LWJGL on OpenBSD platforms -->
<target name="-compile_native_openbsd" if="lwjgl.platform.openbsd"> <target name="-compile_native_openbsd" if="lwjgl.platform.openbsd">
<ant antfile="platform_build/bsd_ant/build.xml"/> <ant antfile="platform_build/bsd_ant/build.xml"/>
<copy todir="${lwjgl.lib}/openbsd">
<fileset dir="${lwjgl.target.gen.classes}/lwjgl" includes="liblwjgl*.so"/>
</copy>
</target> </target>
@ -488,16 +523,12 @@
<target name="-compile_native_solaris" if="lwjgl.platform.solaris"> <target name="-compile_native_solaris" if="lwjgl.platform.solaris">
<!-- Reusing the linux ant task, but copy the output to solaris --> <!-- Reusing the linux ant task, but copy the output to solaris -->
<ant antfile="platform_build/linux_ant/build.xml"/> <ant antfile="platform_build/linux_ant/build.xml"/>
<copy todir="${lwjgl.lib}/solaris">
<fileset dir="${lwjgl.target.gen.classes}/lwjgl" includes="liblwjgl*.so"/>
</copy>
<version-check platform="solaris"/> <version-check platform="solaris"/>
</target> </target>
<!-- Compiles LWJGL on Mac platforms --> <!-- Compiles LWJGL on Mac platforms -->
<target name="-compile_native_macosx" if="lwjgl.platform.macosx"> <target name="-compile_native_macosx" if="lwjgl.platform.macosx">
<ant antfile="platform_build/macosx_ant/build.xml"/> <ant antfile="platform_build/macosx_ant/build.xml"/>
<copy file="${lwjgl.target.bundle}/liblwjgl.dylib" todir="${lwjgl.lib}/macosx"/>
<version-check platform="macosx"/> <version-check platform="macosx"/>
</target> </target>
@ -516,17 +547,11 @@
<!-- Compiles LWJGL ES on Win32 platforms --> <!-- Compiles LWJGL ES on Win32 platforms -->
<target name="-compile_native_win32_es" if="lwjgl.platform.windows"> <target name="-compile_native_win32_es" if="lwjgl.platform.windows">
<ant antfile="platform_build/windows_ant/build_es.xml"/> <ant antfile="platform_build/windows_ant/build_es.xml"/>
<copy todir="${lwjgl.lib}/windows">
<fileset dir="${lwjgl.target.gen.classes}/lwjgles" includes="lwjgl*.dll"/>
</copy>
</target> </target>
<!-- Compiles LWJGL ES on Linux platforms --> <!-- Compiles LWJGL ES on Linux platforms -->
<target name="-compile_native_linux_es" if="lwjgl.platform.linux"> <target name="-compile_native_linux_es" if="lwjgl.platform.linux">
<ant antfile="platform_build/linux_ant/build_es.xml"/> <ant antfile="platform_build/linux_ant/build_es.xml"/>
<copy todir="${lwjgl.lib}/linux">
<fileset dir="${lwjgl.target.gen.classes}/lwjgles" includes="liblwjgl*.so"/>
</copy>
</target> </target>
<target name="repack200" description="Pack200-repack a jar file"> <target name="repack200" description="Pack200-repack a jar file">

View File

@ -2,23 +2,31 @@
<!-- ================================================================== --> <!-- ================================================================== -->
<!-- Global properties for build --> <!-- Global properties for build -->
<!-- ================================================================== --> <!-- ================================================================== -->
<property name="lwjgl.version" value="2.9.4" />
<property name="lwjgl.web" location="www" />
<property name="lwjgl.lib" location="libs" />
<property name="lwjgl.target" location="target" />
<!-- Intermediates -->
<property name="lwjgl.target.gen" location="${lwjgl.target}/gen" />
<property name="lwjgl.target.gen.classes" location="${lwjgl.target.gen}/classes" />
<property name="lwjgl.target.gen.java" location="${lwjgl.target.gen}/java" />
<property name="lwjgl.target.gen.native" location="${lwjgl.target.gen}/native" />
<property name="lwjgl.target.gen.obj" location="${lwjgl.target.gen}/obj" />
<property name="lwjgl.target.staging" location="${lwjgl.target}/staging" />
<!-- Artifacts -->
<property name="lwjgl.target.jars" location="${lwjgl.target}/jars" />
<property name="lwjgl.target.natives" location="${lwjgl.target}/natives" />
<property name="lwjgl.target.doc" location="${lwjgl.target}/doc" />
<property name="lwjgl.target.bundle" location="${lwjgl.target}/bundle" />
<!-- Sources -->
<property name="lwjgl.src" location="src" /> <property name="lwjgl.src" location="src" />
<property name="lwjgl.src.java" location="${lwjgl.src}/java" /> <property name="lwjgl.src.java" location="${lwjgl.src}/java" />
<property name="lwjgl.src.native" location="${lwjgl.src}/native" /> <property name="lwjgl.src.native" location="${lwjgl.src}/native" />
<property name="lwjgl.src.headers" location="${lwjgl.src.native}/common" /> <property name="lwjgl.src.headers" location="${lwjgl.src.native}/common" />
<property name="lwjgl.src.templates" location="${lwjgl.src}/templates" /> <property name="lwjgl.src.templates" location="${lwjgl.src}/templates" />
<property name="lwjgl.target" location="target" />
<property name="lwjgl.target.gen" location="${lwjgl.target}/gen" />
<property name="lwjgl.target.gen.classes" location="${lwjgl.target.gen}/classes" />
<property name="lwjgl.target.gen.java" location="${lwjgl.target.gen}/java" />
<property name="lwjgl.target.gen.native" location="${lwjgl.target.gen}/native" />
<property name="lwjgl.target.gen.obj" location="${lwjgl.target.gen}/obj" />
<property name="lwjgl.target.bundle" location="${lwjgl.target}/bundle" />
<property name="lwjgl.target.staging" location="${lwjgl.target}/staging" />
<property name="lwjgl.target.doc" location="${lwjgl.target}/doc" />
<property name="lwjgl.lib" location="libs" />
<property name="lwjgl.version" value="2.9.4" />
<property name="lwjgl.web" location="www" />
<property name="lwjgl.src.templates.al" location="${lwjgl.src.templates}/org/lwjgl/openal"/> <property name="lwjgl.src.templates.al" location="${lwjgl.src.templates}/org/lwjgl/openal"/>
<property name="lwjgl.src.templates.gl" location="${lwjgl.src.templates}/org/lwjgl/opengl"/> <property name="lwjgl.src.templates.gl" location="${lwjgl.src.templates}/org/lwjgl/opengl"/>

View File

@ -3,7 +3,7 @@
<!-- Compiles the Java generator source code --> <!-- Compiles the Java generator source code -->
<target name="-generate-common" description="Performs up for the generators and compiles common classes for the templates."> <target name="-generate-common" description="Performs up for the generators and compiles common classes for the templates.">
<condition property="javac.args.debug" value="-Ageneratechecks" else=""> <condition property="javac.args.debug" value="-Ageneratechecks" else="-Anogeneratechecks">
<istrue value="${enable_debug}"/> <istrue value="${enable_debug}"/>
</condition> </condition>
@ -35,17 +35,19 @@
<compilerarg value="-Xlint:none"/> <compilerarg value="-Xlint:none"/>
</javac> </javac>
<javac destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor"> <!--<javac destdir="${lwjgl.target.gen.classes}" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor">-->
<javac destdir="${lwjgl.target.gen.native}/openal" source="1.8" target="1.8" srcdir="${lwjgl.src.templates.al}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/> <compilerarg value="-proc:only"/>
<compilerarg value="-processor"/> <compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/> <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-cp"/> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.target.gen.classes}:${java.class.path}"/> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-s"/> <compilerarg value="-s"/>
<compilerarg path="${lwjgl.target.gen.java}"/> <compilerarg path="${lwjgl.target.gen.java}"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.target.gen.native}/openal"/>
<compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/> <compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/>
<compilerarg value="-Agenpath=${lwjgl.target.gen.java}"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/> <compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
<compilerarg value="${javac.args.debug}"/> <compilerarg value="${javac.args.debug}"/>
<src> <src>
@ -83,13 +85,14 @@
<compilerarg value="-proc:only"/> <compilerarg value="-proc:only"/>
<compilerarg value="-processor"/> <compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/> <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-cp"/> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.target.gen.classes}:${java.class.path}"/> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-s"/> <compilerarg value="-s"/>
<compilerarg path="${lwjgl.target.gen.java}"/> <compilerarg path="${lwjgl.target.gen.java}"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.target.gen.native}/opengl"/>
<compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/> <compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/>
<compilerarg value="-Agenpath=${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/> <compilerarg value="${javac.args.debug}"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/> <compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
<compilerarg value="-Acontextspecific"/> <compilerarg value="-Acontextspecific"/>
@ -105,8 +108,10 @@
<compilerarg value="-proc:only"/> <compilerarg value="-proc:only"/>
<compilerarg value="-processor"/> <compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessor"/> <compilerarg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-cp"/> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.target.gen.classes}:${java.class.path}"/> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-s"/> <compilerarg value="-s"/>
<compilerarg path="${lwjgl.target.gen.java}"/> <compilerarg path="${lwjgl.target.gen.java}"/>
<src> <src>
@ -121,8 +126,10 @@
<compilerarg value="-proc:only"/> <compilerarg value="-proc:only"/>
<compilerarg value="-processor"/> <compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/> <compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-cp"/> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.target.gen.classes}:${java.class.path}"/> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-s"/> <compilerarg value="-s"/>
<compilerarg path="${lwjgl.target.gen.java}"/> <compilerarg path="${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/> <compilerarg value="${javac.args.debug}"/>
@ -160,13 +167,14 @@
<compilerarg value="-proc:only"/> <compilerarg value="-proc:only"/>
<compilerarg value="-processor"/> <compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/> <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-cp"/> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.target.gen.classes}:${java.class.path}"/> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-s"/> <compilerarg value="-s"/>
<compilerarg path="${lwjgl.target.gen.java}"/> <compilerarg path="${lwjgl.target.gen.java}"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.target.gen.native}/opengles"/>
<compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/> <compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/>
<compilerarg value="-Agenpath=${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/> <compilerarg value="${javac.args.debug}"/>
<!--<compilerarg value="-Acontextspecific"/>--> <!--<compilerarg value="-Acontextspecific"/>-->
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/> <compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
@ -182,8 +190,10 @@
<compilerarg value="-proc:only"/> <compilerarg value="-proc:only"/>
<compilerarg value="-processor"/> <compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/> <compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-cp"/> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.target.gen.classes}:${java.class.path}"/> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-s"/> <compilerarg value="-s"/>
<compilerarg path="${lwjgl.target.gen.java}"/> <compilerarg path="${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/> <compilerarg value="${javac.args.debug}"/>
@ -228,13 +238,14 @@
<compilerarg value="-proc:only"/> <compilerarg value="-proc:only"/>
<compilerarg value="-processor"/> <compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/> <compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-cp"/> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.target.gen.classes}:${java.class.path}"/> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-s"/> <compilerarg value="-s"/>
<compilerarg path="${lwjgl.target.gen.java}"/> <compilerarg path="${lwjgl.target.gen.java}"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.target.gen.native}/opencl"/>
<compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/> <compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/>
<compilerarg value="-Agenpath=${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/> <compilerarg value="${javac.args.debug}"/>
<compilerarg value="-Acontextspecific"/> <compilerarg value="-Acontextspecific"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/> <compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
@ -250,8 +261,10 @@
<compilerarg value="-proc:only"/> <compilerarg value="-proc:only"/>
<compilerarg value="-processor"/> <compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/> <compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-cp"/> <compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.target.gen.classes}:${java.class.path}"/> <compilerarg path="${lwjgl.target.gen.classes}"/>
<compilerarg value="-s"/> <compilerarg value="-s"/>
<compilerarg path="${lwjgl.target.gen.java}"/> <compilerarg path="${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/> <compilerarg value="${javac.args.debug}"/>

View File

@ -3,8 +3,8 @@
<project name="lwjgl native code, linux" basedir="/dev/null" default="compile"> <project name="lwjgl native code, linux" basedir="/dev/null" default="compile">
<property name="libname32" value="liblwjgl.so"/> <property name="libname32" value="liblwjgl.so"/>
<property name="libname64" value="liblwjgl64.so"/> <property name="libname64" value="liblwjgl64.so"/>
<property name="libs32" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/i386 -ljawt" /> <property name="libs32" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib -L${java.home}/lib/i386 -ljawt" />
<property name="libs64" value="-L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/amd64 -ljawt" /> <property name="libs64" value="-L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib -L${java.home}/lib/amd64 -ljawt" />
<property name="cflags32" value="-O3 -Wall -c -fPIC -std=c99 -Wunused"/> <property name="cflags32" value="-O3 -Wall -c -fPIC -std=c99 -Wunused"/>
<target name="compile"> <target name="compile">
@ -52,7 +52,7 @@
<target name="compile32" unless="build.64bit.only"> <target name="compile32" unless="build.64bit.only">
<mkdir dir="${lwjgl.target.gen.obj}/i386"/> <mkdir dir="${lwjgl.target.gen.obj}/i386"/>
<apply dir="${lwjgl.target.gen.obj}/i386" executable="gcc" skipemptyfilesets="true" failonerror="true" parallel="true"> <apply dir="${lwjgl.target.gen.obj}/i386" executable="gcc" failonerror="true" parallel="true">
<arg line="${cflags32} ${cflags_pthread}"/> <arg line="${cflags32} ${cflags_pthread}"/>
<arg value="-I${java.home}/include"/> <arg value="-I${java.home}/include"/>
<arg value="-I${java.home}/include/linux"/> <arg value="-I${java.home}/include/linux"/>
@ -72,19 +72,19 @@
<fileset dir="${lwjgl.src.native}/linux" includes="*.c"/> <fileset dir="${lwjgl.src.native}/linux" includes="*.c"/>
<fileset dir="${lwjgl.src.native}/linux/opengl" includes="*.c"/> <fileset dir="${lwjgl.src.native}/linux/opengl" includes="*.c"/>
</apply> </apply>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="gcc" failonerror="true"> <apply dir="${lwjgl.target.natives}" parallel="true" executable="gcc" failonerror="true">
<srcfile/> <srcfile/>
<arg line="${linker_flags32}"/> <arg line="${linker_flags32}"/>
<fileset dir="${lwjgl.target.gen.obj}/i386" includes="*.o"/> <fileset dir="${lwjgl.target.gen.obj}/i386" includes="*.o"/>
</apply> </apply>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="strip" failonerror="true"> <apply dir="${lwjgl.target.natives}" parallel="true" executable="strip" failonerror="true">
<fileset file="${libname32}"/> <fileset file="${libname32}"/>
</apply> </apply>
</target> </target>
<target name="compile64" unless="build.32bit.only"> <target name="compile64" unless="build.32bit.only">
<mkdir dir="${lwjgl.target.gen.obj}/x86_64"/> <mkdir dir="${lwjgl.target.gen.obj}/x86_64"/>
<apply dir="${lwjgl.target.gen.obj}/x86_64" executable="gcc" skipemptyfilesets="true" failonerror="true" parallel="true"> <apply dir="${lwjgl.target.gen.obj}/x86_64" executable="gcc" failonerror="true" parallel="true">
<arg line="${cflags64} ${cflags_pthread}"/> <arg line="${cflags64} ${cflags_pthread}"/>
<arg value="-I${java.home}/include"/> <arg value="-I${java.home}/include"/>
<arg value="-I${java.home}/include/linux"/> <arg value="-I${java.home}/include/linux"/>
@ -104,13 +104,13 @@
<fileset dir="${lwjgl.src.native}/linux" includes="*.c"/> <fileset dir="${lwjgl.src.native}/linux" includes="*.c"/>
<fileset dir="${lwjgl.src.native}/linux/opengl" includes="*.c"/> <fileset dir="${lwjgl.src.native}/linux/opengl" includes="*.c"/>
</apply> </apply>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="gcc" failonerror="true"> <apply dir="${lwjgl.target.natives}" parallel="true" executable="gcc" failonerror="true">
<srcfile/> <srcfile/>
<arg line="${linker_flags64}"/> <arg line="${linker_flags64}"/>
<fileset dir="${lwjgl.target.gen.obj}/x86_64" includes="*.o"/> <fileset dir="${lwjgl.target.gen.obj}/x86_64" includes="*.o"/>
</apply> </apply>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="strip" failonerror="true"> <apply dir="${lwjgl.target.natives}" parallel="true" executable="strip" failonerror="true">
<fileset file="${libname64}"/> <fileset file="${lwjgl.target.natives}/${libname64}"/>
</apply> </apply>
</target> </target>
</project> </project>

View File

@ -5,8 +5,8 @@
<property name="libname32" value="liblwjgl.so"/> <property name="libname32" value="liblwjgl.so"/>
<property name="libname64" value="liblwjgl64.so"/> <property name="libname64" value="liblwjgl64.so"/>
<property name="lib_folder" value="${lwjgl.lib}/linux"/> <property name="lib_folder" value="${lwjgl.lib}/linux"/>
<property name="libs32" value="-L${lib_folder} -lEGL -L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/i386 -ljawt" /> <property name="libs32" value="-L${lib_folder} -lEGL -L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib -L${java.home}/lib/i386 -ljawt" />
<property name="libs64" value="-L${lib_folder}/x64 -lEGL -L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib/amd64 -ljawt" /> <property name="libs64" value="-L${lib_folder}/x64 -lEGL -L/usr/X11R6/lib64 -L/usr/X11/lib64 -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -lpthread -L${java.home}/lib -L${java.home}/lib/amd64 -ljawt" />
<property name="cflags32" value="-O3 -Wall -c -fPIC -std=c99 -Wunused"/> <property name="cflags32" value="-O3 -Wall -c -fPIC -std=c99 -Wunused"/>
<target name="clean"> <target name="clean">

View File

@ -95,7 +95,7 @@
<target name="compile" depends="init"> <target name="compile" depends="init">
<mkdir dir="${dstdir}" taskname="initializing ${dstdir} folder"/> <mkdir dir="${dstdir}" taskname="initializing ${dstdir} folder"/>
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}"> <apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" failonerror="true" dest="${dstdir}">
<arg line="${cflags} -ObjC -O3 -Wall -Wunused -c -fPIC -I${javavmroot}/${jvm_headers_path_md} -I${javavmroot}/${jvm_headers_path} -I${lwjgl.src.native}/common -I${lwjgl.src.native}/common/opengl -I${lwjgl.src.native}/macosx"/> <arg line="${cflags} -ObjC -O3 -Wall -Wunused -c -fPIC -I${javavmroot}/${jvm_headers_path_md} -I${javavmroot}/${jvm_headers_path} -I${lwjgl.src.native}/common -I${lwjgl.src.native}/common/opengl -I${lwjgl.src.native}/macosx"/>
<!-- Map from *.m and *.c to .o --> <!-- Map from *.m and *.c to .o -->
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/> <mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
@ -117,12 +117,12 @@
<not><isset property="jdk_lib"/></not> <not><isset property="jdk_lib"/></not>
</condition> </condition>
<apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true" skipemptyfilesets="false"> <apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true">
<arg line="${linkerflags} -exported_symbols_list lwjgl.symbols -dynamiclib -o ${lwjgl.target.bundle}/${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt -L${sdkroot}/usr/lib"/> <arg line="${linkerflags} -exported_symbols_list lwjgl.symbols -dynamiclib -o ${lwjgl.target.natives}/${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt -L${sdkroot}/usr/lib"/>
<fileset dir="${objdir}" includes="*.o"/> <fileset dir="${objdir}" includes="*.o"/>
</apply> </apply>
<echo message="Linked library"/> <echo message="Linked library"/>
<apply dir="${lwjgl.target.bundle}" executable="strip" os="Mac OS X" failonerror="true" skipemptyfilesets="false"> <apply dir="${lwjgl.target.natives}" executable="strip" os="Mac OS X" failonerror="true">
<arg line="-S -X"/> <arg line="-S -X"/>
<fileset file="${libname}"/> <fileset file="${libname}"/>
</apply> </apply>
@ -173,7 +173,7 @@
<param name="libname" value="liblwjgl-x86_64.dylib"/> <param name="libname" value="liblwjgl-x86_64.dylib"/>
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/> <param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
</antcall> </antcall>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="false"> <apply dir="${lwjgl.target.natives}" parallel="true" executable="lipo" os="Mac OS X" failonerror="true">
<arg value="-create"/> <arg value="-create"/>
<srcfile/> <srcfile/>
<arg value="-output"/> <arg value="-output"/>
@ -198,12 +198,12 @@
<param name="libname" value="liblwjgl-x86_64.dylib"/> <param name="libname" value="liblwjgl-x86_64.dylib"/>
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/> <param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
</antcall> </antcall>
<apply parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="false"> <apply parallel="true" executable="lipo" os="Mac OS X" failonerror="true">
<arg value="-create"/> <arg value="-create"/>
<srcfile/> <srcfile/>
<arg value="-output"/> <arg value="-output"/>
<arg path="${lwjgl.target.bundle}/liblwjgl.dylib"/> <arg path="${lwjgl.target.natives}/liblwjgl.dylib"/>
<fileset file="${lwjgl.target.bundle}/liblwjgl-x86_64.dylib"/> <fileset file="${lwjgl.target.natives}/liblwjgl-x86_64.dylib"/>
</apply> </apply>
</target> </target>
</project> </project>

View File

@ -268,6 +268,32 @@ public class LWJGLUtil {
private static final int PLATFORM; private static final int PLATFORM;
private static StupidSimpleLogger logger = msg -> {
//if (DEBUG) {
System.err.println("[LWJGL] " + msg);
//}
};
public static StupidSimpleLogger logger() {
return logger;
}
public static void logger(StupidSimpleLogger newLogger) {
logger = newLogger;
}
/**
* Logs the given message.
*
* @param msg Message to print
*
* @deprecated Use {@link #logger} instead.
*/
@Deprecated
public static void log(CharSequence msg) {
logger().log(() -> msg.toString());
}
static { static {
final String osName = getPrivilegedProperty("os.name"); final String osName = getPrivilegedProperty("os.name");
if ( osName.startsWith("Windows") ) if ( osName.startsWith("Windows") )
@ -504,17 +530,6 @@ public class LWJGLUtil {
}); });
} }
/**
* Prints the given message to System.err if DEBUG is true.
*
* @param msg Message to print
*/
public static void log(CharSequence msg) {
if (DEBUG) {
System.err.println("[LWJGL] " + msg);
}
}
/** /**
* Method to determine if the current system is running a version of * Method to determine if the current system is running a version of
* Mac OS X better than the given version. This is only useful for Mac OS X * Mac OS X better than the given version. This is only useful for Mac OS X

View File

@ -31,13 +31,14 @@
*/ */
package org.lwjgl; package org.lwjgl;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.nio.Buffer; import java.nio.Buffer;
import sun.misc.Unsafe; import sun.misc.Unsafe;
import sun.reflect.FieldAccessor;
/** /**
* MemoryUtil.Accessor implementations that depend on sun.misc. * MemoryUtil.Accessor implementations that depend on sun.misc.
@ -103,33 +104,35 @@ final class MemoryUtilSun {
} }
/** Implementation using reflection on ByteBuffer, FieldAccessor is used directly. */ /** Implementation using {@link java.lang.MethodHandle}s on ByteBuffer. Reflection is used to acquire the handle. */
private static class AccessorReflectFast implements MemoryUtil.Accessor { private static class AccessorReflectFast implements MemoryUtil.Accessor {
private final FieldAccessor addressAccessor; private final MethodHandle addressAccessor;
AccessorReflectFast() { AccessorReflectFast() {
Field address; Field addressField;
try { try {
address = MemoryUtil.getAddressField(); addressField = MemoryUtil.getAddressField();
} catch (NoSuchFieldException e) { } catch (NoSuchFieldException e) {
throw new UnsupportedOperationException(e); throw new UnsupportedOperationException(e);
} }
address.setAccessible(true); addressField.setAccessible(true);
try { try {
Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class); addressAccessor = MethodHandles.lookup().unreflectGetter(addressField);
m.setAccessible(true); } catch (ReflectiveOperationException e) {
addressAccessor = (FieldAccessor)m.invoke(address, true);
} catch (Exception e) {
throw new UnsupportedOperationException(e); throw new UnsupportedOperationException(e);
} }
} }
public long getAddress(final Buffer buffer) { public long getAddress(final Buffer buffer) {
return addressAccessor.getLong(buffer); try {
return (long) addressAccessor.invokeExact(buffer);
} catch (Throwable e) {
throw new RuntimeException(e);
}
} }
} }
} }

View File

@ -0,0 +1,58 @@
package org.lwjgl;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.function.Supplier;
/**
* A (mostly) stupidly simple logger.
*/
@FunctionalInterface
public interface StupidSimpleLogger {
/**
* Logs a message provided lazily.
*/
void log(Supplier<String> message);
/**
* Logs a message.
*/
default void log(String message) {
log(() -> message);
}
/**
* Logs a message provided lazily and an error.
*/
default void log(Supplier<String> message, Throwable throwable) {
log(() -> {
StringWriter buf = new StringWriter().append(message.get()).append('\n');
throwable.printStackTrace(new PrintWriter(buf));
return buf.toString();
});
}
/**
* Logs a message and an error.
*/
default void log(String message, Throwable throwable) {
log(() -> message, throwable);
}
/**
* A No-Op implementation of the logger. All default forwarding methods are overidden with No-Op implementations.
*/
public static final StupidSimpleLogger NOOP = new StupidSimpleLogger() {
@Override
public void log(Supplier<String> message) {}
@Override
public void log(String message) {}
@Override
public void log(Supplier<String> message, Throwable throwable) {}
@Override
public void log(String message, Throwable throwable) {}
};
}

View File

@ -216,7 +216,7 @@ public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListe
} }
/** Set swap interval. */ /** Set swap interval. */
public void setSwapInterval(int swap_interval) { public void setSwapInterval(int swap_interval) throws LWJGLException {
synchronized ( SYNC_LOCK ) { synchronized ( SYNC_LOCK ) {
if ( context == null ) if ( context == null )
throw new IllegalStateException("Canvas not yet displayable"); throw new IllegalStateException("Canvas not yet displayable");
@ -225,7 +225,7 @@ public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListe
} }
/** Enable vsync */ /** Enable vsync */
public void setVSyncEnabled(boolean enabled) { public void setVSyncEnabled(boolean enabled) throws LWJGLException {
setSwapInterval(enabled ? 1 : 0); setSwapInterval(enabled ? 1 : 0);
} }
@ -411,4 +411,4 @@ public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListe
setUpdate(); setUpdate();
} }
} }

View File

@ -228,7 +228,7 @@ final class ContextGL implements Context {
* <p/> * <p/>
* A video frame period is the time required to display a full frame of video data. * A video frame period is the time required to display a full frame of video data.
*/ */
public static void setSwapInterval(int value) { public static void setSwapInterval(int value) throws LWJGLException {
implementation.setSwapInterval(value); implementation.setSwapInterval(value);
} }
@ -296,4 +296,4 @@ final class ContextGL implements Context {
} }
} }
} }

View File

@ -81,7 +81,7 @@ interface ContextImplementation {
*/ */
boolean isCurrent(ByteBuffer handle) throws LWJGLException; boolean isCurrent(ByteBuffer handle) throws LWJGLException;
void setSwapInterval(int value); void setSwapInterval(int value) throws LWJGLException;
/** /**
* Destroys the Context. * Destroys the Context.

View File

@ -328,7 +328,7 @@ public final class Display {
context.releaseDrawable(); context.releaseDrawable();
} }
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Exception occurred while trying to release context: " + e); LWJGLUtil.logger().log("Exception occurred while trying to release context", e);
} }
} }
@ -413,16 +413,12 @@ public final class Display {
/** @return the title of the window */ /** @return the title of the window */
public static String getTitle() { public static String getTitle() {
synchronized ( GlobalLock.lock ) { return title;
return title;
}
} }
/** Return the last parent set with setParent(). */ /** Return the last parent set with setParent(). */
public static Canvas getParent() { public static Canvas getParent() {
synchronized ( GlobalLock.lock ) { return parent;
return parent;
}
} }
/** /**
@ -521,9 +517,7 @@ public final class Display {
/** @return whether the Display is in fullscreen mode */ /** @return whether the Display is in fullscreen mode */
public static boolean isFullscreen() { public static boolean isFullscreen() {
synchronized ( GlobalLock.lock ) { return fullscreen && current_mode.isFullscreenCapable();
return fullscreen && current_mode.isFullscreenCapable();
}
} }
/** /**
@ -1026,7 +1020,7 @@ public final class Display {
try { try {
drawable.checkGLError(); drawable.checkGLError();
} catch (OpenGLException e) { } catch (OpenGLException e) {
LWJGLUtil.log("OpenGL error during context creation: " + e.getMessage()); LWJGLUtil.logger().log("OpenGL error during context creation", e);
} }
setSwapInterval(swap_interval); setSwapInterval(swap_interval);
} }
@ -1042,20 +1036,19 @@ public final class Display {
/** Gets a boolean property as a privileged action. */ /** Gets a boolean property as a privileged action. */
static boolean getPrivilegedBoolean(final String property_name) { static boolean getPrivilegedBoolean(final String property_name) {
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() { String s = getPrivilegedString(property_name);
public Boolean run() { if (s == null || s.equals("false")) return false;
return Boolean.getBoolean(property_name); if (LWJGLUtil.DEBUG) {
if (!s.equals("true")) {
LWJGLUtil.logger().log(() -> "Value of boolean property " + property_name + " is not one of [true, false]: " + s);
} }
}); }
return true;
} }
/** Gets a string property as a privileged action. */ /** Gets a string property as a privileged action. */
static String getPrivilegedString(final String property_name) { static String getPrivilegedString(final String property_name) {
return AccessController.doPrivileged(new PrivilegedAction<String>() { return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property_name));
public String run() {
return System.getProperty(property_name);
}
});
} }
private static void initControls() { private static void initControls() {
@ -1065,22 +1058,14 @@ public final class Display {
try { try {
Mouse.create(); Mouse.create();
} catch (LWJGLException e) { } catch (LWJGLException e) {
if ( LWJGLUtil.DEBUG ) { LWJGLUtil.logger().log("Failed to create Mouse", e);
e.printStackTrace(System.err);
} else {
LWJGLUtil.log("Failed to create Mouse: " + e);
}
} }
} }
if ( !Keyboard.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nokeyboard") ) { if ( !Keyboard.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nokeyboard") ) {
try { try {
Keyboard.create(); Keyboard.create();
} catch (LWJGLException e) { } catch (LWJGLException e) {
if ( LWJGLUtil.DEBUG ) { LWJGLUtil.logger().log("Failed to create Keyboard", e);
e.printStackTrace(System.err);
} else {
LWJGLUtil.log("Failed to create Keyboard: " + e);
}
} }
} }
} }
@ -1091,7 +1076,7 @@ public final class Display {
* regardless of whether the Display was the current rendering context. * regardless of whether the Display was the current rendering context.
*/ */
public static void destroy() { public static void destroy() {
if(isCreated()) { if (isCreated()) {
drawable.destroy(); drawable.destroy();
} }
} }
@ -1108,9 +1093,7 @@ public final class Display {
/** @return true if the window's native peer has been created */ /** @return true if the window's native peer has been created */
public static boolean isCreated() { public static boolean isCreated() {
synchronized ( GlobalLock.lock ) { return window_created;
return window_created;
}
} }
/** /**
@ -1122,7 +1105,7 @@ public final class Display {
* *
* @param value The swap interval in frames, 0 to disable * @param value The swap interval in frames, 0 to disable
*/ */
public static void setSwapInterval(int value) { public static void setSwapInterval(int value) throws LWJGLException {
synchronized ( GlobalLock.lock ) { synchronized ( GlobalLock.lock ) {
swap_interval = value; swap_interval = value;
if ( isCreated() ) if ( isCreated() )
@ -1137,10 +1120,8 @@ public final class Display {
* *
* @param sync true to synchronize; false to ignore synchronization * @param sync true to synchronize; false to ignore synchronization
*/ */
public static void setVSyncEnabled(boolean sync) { public static void setVSyncEnabled(boolean sync) throws LWJGLException {
synchronized ( GlobalLock.lock ) { setSwapInterval(sync ? 1 : 0);
setSwapInterval(sync ? 1 : 0);
}
} }
/** /**
@ -1178,9 +1159,7 @@ public final class Display {
* @return a String * @return a String
*/ */
public static String getAdapter() { public static String getAdapter() {
synchronized ( GlobalLock.lock ) { return display_impl.getAdapter();
return display_impl.getAdapter();
}
} }
/** /**
@ -1190,9 +1169,7 @@ public final class Display {
* @return a String * @return a String
*/ */
public static String getVersion() { public static String getVersion() {
synchronized ( GlobalLock.lock ) { return display_impl.getVersion();
return display_impl.getVersion();
}
} }
/** /**

View File

@ -82,7 +82,7 @@ abstract class DrawableGL implements DrawableLWJGL {
Util.checkGLError(); Util.checkGLError();
} }
public void setSwapInterval(final int swap_interval) { public void setSwapInterval(final int swap_interval) throws LWJGLException {
ContextGL.setSwapInterval(swap_interval); ContextGL.setSwapInterval(swap_interval);
} }

View File

@ -62,10 +62,10 @@ interface DrawableLWJGL extends Drawable {
void checkGLError(); void checkGLError();
void setSwapInterval(int swap_interval); void setSwapInterval(int swap_interval) throws LWJGLException;
void swapBuffers() throws LWJGLException; void swapBuffers() throws LWJGLException;
void initContext(final float r, final float g, final float b); void initContext(final float r, final float g, final float b);
} }

View File

@ -102,8 +102,7 @@ final class LinuxCanvasImplementation implements AWTCanvasImplementation {
} }
private static int findVisualIDFromFormat(int screen, PixelFormat pixel_format) throws LWJGLException { private static int findVisualIDFromFormat(int screen, PixelFormat pixel_format) throws LWJGLException {
try { try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
LinuxDisplay.lockAWT();
try { try {
GLContext.loadOpenGLLibrary(); GLContext.loadOpenGLLibrary();
try { try {
@ -115,8 +114,6 @@ final class LinuxCanvasImplementation implements AWTCanvasImplementation {
} finally { } finally {
GLContext.unloadOpenGLLibrary(); GLContext.unloadOpenGLLibrary();
} }
} finally {
LinuxDisplay.unlockAWT();
} }
} }
private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException; private static native int nFindVisualIDFromFormat(long display, int screen, PixelFormat pixel_format) throws LWJGLException;

View File

@ -44,16 +44,13 @@ import java.nio.IntBuffer;
final class LinuxContextImplementation implements ContextImplementation { final class LinuxContextImplementation implements ContextImplementation {
public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException { public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
ByteBuffer peer_handle = peer_info.lockAndGetHandle(); ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try { try {
return nCreate(peer_handle, attribs, shared_context_handle); return nCreate(peer_handle, attribs, shared_context_handle);
} finally { } finally {
peer_info.unlock(); peer_info.unlock();
} }
} finally {
LinuxDisplay.unlockAWT();
} }
} }
@ -72,16 +69,13 @@ final class LinuxContextImplementation implements ContextImplementation {
throw new IllegalStateException("No context is current"); throw new IllegalStateException("No context is current");
synchronized ( current_context ) { synchronized ( current_context ) {
PeerInfo current_peer_info = current_context.getPeerInfo(); PeerInfo current_peer_info = current_context.getPeerInfo();
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
try { try {
nSwapBuffers(peer_handle); nSwapBuffers(peer_handle);
} finally { } finally {
current_peer_info.unlock(); current_peer_info.unlock();
} }
} finally {
LinuxDisplay.unlockAWT();
} }
} }
} }
@ -94,16 +88,13 @@ final class LinuxContextImplementation implements ContextImplementation {
throw new IllegalStateException("No context is current"); throw new IllegalStateException("No context is current");
synchronized ( current_context ) { synchronized ( current_context ) {
PeerInfo current_peer_info = current_context.getPeerInfo(); PeerInfo current_peer_info = current_context.getPeerInfo();
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle(); ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
try { try {
nReleaseCurrentContext(peer_handle); nReleaseCurrentContext(peer_handle);
} finally { } finally {
current_peer_info.unlock(); current_peer_info.unlock();
} }
} finally {
LinuxDisplay.unlockAWT();
} }
} }
} }
@ -114,34 +105,29 @@ final class LinuxContextImplementation implements ContextImplementation {
} }
public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { public void makeCurrent(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
ByteBuffer peer_handle = peer_info.lockAndGetHandle(); ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try { try {
nMakeCurrent(peer_handle, handle); nMakeCurrent(peer_handle, handle);
} finally { } finally {
peer_info.unlock(); peer_info.unlock();
} }
} finally {
LinuxDisplay.unlockAWT();
} }
} }
private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException; private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException;
public boolean isCurrent(ByteBuffer handle) throws LWJGLException { public boolean isCurrent(ByteBuffer handle) throws LWJGLException {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
boolean result = nIsCurrent(handle); boolean result = nIsCurrent(handle);
return result; return result;
} finally {
LinuxDisplay.unlockAWT();
} }
} }
private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException; private static native boolean nIsCurrent(ByteBuffer context_handle) throws LWJGLException;
public void setSwapInterval(int value) { @Override
public void setSwapInterval(int value) throws LWJGLException {
ContextGL current_context = ContextGL.getCurrentContext(); ContextGL current_context = ContextGL.getCurrentContext();
if ( current_context == null ) if ( current_context == null )
@ -150,19 +136,13 @@ final class LinuxContextImplementation implements ContextImplementation {
PeerInfo peer_info = current_context.getPeerInfo(); PeerInfo peer_info = current_context.getPeerInfo();
synchronized ( current_context ) { synchronized ( current_context ) {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
ByteBuffer peer_handle = peer_info.lockAndGetHandle(); ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try { try {
nSetSwapInterval(peer_handle, current_context.getHandle(), value); nSetSwapInterval(peer_handle, current_context.getHandle(), value);
} finally { } finally {
peer_info.unlock(); peer_info.unlock();
} }
} catch (LWJGLException e) {
// API CHANGE - this methods should throw LWJGLException
e.printStackTrace();
} finally {
LinuxDisplay.unlockAWT();
} }
} }
} }
@ -170,16 +150,13 @@ final class LinuxContextImplementation implements ContextImplementation {
private static native void nSetSwapInterval(ByteBuffer peer_handle, ByteBuffer context_handle, int value); private static native void nSetSwapInterval(ByteBuffer peer_handle, ByteBuffer context_handle, int value);
public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException { public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
ByteBuffer peer_handle = peer_info.lockAndGetHandle(); ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try { try {
nDestroy(peer_handle, handle); nDestroy(peer_handle, handle);
} finally { } finally {
peer_info.unlock(); peer_info.unlock();
} }
} finally {
LinuxDisplay.unlockAWT();
} }
} }

View File

@ -178,8 +178,7 @@ final class LinuxDisplay implements DisplayImplementation {
}; };
private static ByteBuffer getCurrentGammaRamp() throws LWJGLException { private static ByteBuffer getCurrentGammaRamp() throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
if (isXF86VidModeSupported()) if (isXF86VidModeSupported())
@ -189,8 +188,6 @@ final class LinuxDisplay implements DisplayImplementation {
} finally { } finally {
decDisplay(); decDisplay();
} }
} finally {
unlockAWT();
} }
} }
private static native ByteBuffer nGetCurrentGammaRamp(long display, int screen) throws LWJGLException; private static native ByteBuffer nGetCurrentGammaRamp(long display, int screen) throws LWJGLException;
@ -213,8 +210,7 @@ final class LinuxDisplay implements DisplayImplementation {
private static boolean isXrandrSupported() { private static boolean isXrandrSupported() {
if (Display.getPrivilegedBoolean("LWJGL_DISABLE_XRANDR")) if (Display.getPrivilegedBoolean("LWJGL_DISABLE_XRANDR"))
return false; return false;
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
return nIsXrandrSupported(getDisplay()); return nIsXrandrSupported(getDisplay());
@ -224,15 +220,12 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Got exception while querying Xrandr support: " + e); LWJGLUtil.log("Got exception while querying Xrandr support: " + e);
return false; return false;
} finally {
unlockAWT();
} }
} }
private static native boolean nIsXrandrSupported(long display) throws LWJGLException; private static native boolean nIsXrandrSupported(long display) throws LWJGLException;
private static boolean isXF86VidModeSupported() { private static boolean isXF86VidModeSupported() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
return nIsXF86VidModeSupported(getDisplay()); return nIsXF86VidModeSupported(getDisplay());
@ -242,8 +235,6 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Got exception while querying XF86VM support: " + e); LWJGLUtil.log("Got exception while querying XF86VM support: " + e);
return false; return false;
} finally {
unlockAWT();
} }
} }
private static native boolean nIsXF86VidModeSupported(long display) throws LWJGLException; private static native boolean nIsXF86VidModeSupported(long display) throws LWJGLException;
@ -251,8 +242,7 @@ final class LinuxDisplay implements DisplayImplementation {
private static boolean isNetWMFullscreenSupported() throws LWJGLException { private static boolean isNetWMFullscreenSupported() throws LWJGLException {
if (Display.getPrivilegedBoolean("LWJGL_DISABLE_NETWM")) if (Display.getPrivilegedBoolean("LWJGL_DISABLE_NETWM"))
return false; return false;
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
return nIsNetWMFullscreenSupported(getDisplay(), getDefaultScreen()); return nIsNetWMFullscreenSupported(getDisplay(), getDefaultScreen());
@ -262,32 +252,38 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Got exception while querying NetWM support: " + e); LWJGLUtil.log("Got exception while querying NetWM support: " + e);
return false; return false;
} finally {
unlockAWT();
} }
} }
private static native boolean nIsNetWMFullscreenSupported(long display, int screen) throws LWJGLException; private static native boolean nIsNetWMFullscreenSupported(long display, int screen) throws LWJGLException;
public static final class AWTLock implements AutoCloseable {
private static final AWTLock INSTANCE = new AWTLock();
@Override
public void close() {
try {
nUnlockAWT();
} catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while unlocking AWT: " + e);
}
}
}
/* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL /* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL
* Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to * Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to
* do just that. * do just that.
*/ */
static void lockAWT() { static AWTLock awtLock() {
try { try {
nLockAWT(); nLockAWT();
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while locking AWT: " + e); LWJGLUtil.log("Caught exception while locking AWT: " + e);
} }
return AWTLock.INSTANCE;
} }
private static native void nLockAWT() throws LWJGLException; private static native void nLockAWT() throws LWJGLException;
static void unlockAWT() {
try {
nUnlockAWT();
} catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while unlocking AWT: " + e);
}
}
private static native void nUnlockAWT() throws LWJGLException; private static native void nUnlockAWT() throws LWJGLException;
/** /**
@ -452,8 +448,7 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException { public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
if ( drawable instanceof DrawableGLES ) if ( drawable instanceof DrawableGLES )
@ -527,8 +522,6 @@ final class LinuxDisplay implements DisplayImplementation {
decDisplay(); decDisplay();
throw e; throw e;
} }
} finally {
unlockAWT();
} }
} }
private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y, boolean undecorated, long parent_handle, boolean resizable) throws LWJGLException; private static native long nCreateWindow(long display, int screen, ByteBuffer peer_info_handle, DisplayMode mode, int window_mode, int x, int y, boolean undecorated, long parent_handle, boolean resizable) throws LWJGLException;
@ -576,8 +569,7 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public void destroyWindow() { public void destroyWindow() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
if (parent != null) { if (parent != null) {
parent.removeFocusListener(focus_listener); parent.removeFocusListener(focus_listener);
} }
@ -594,19 +586,14 @@ final class LinuxDisplay implements DisplayImplementation {
if ( current_window_mode != WINDOWED ) if ( current_window_mode != WINDOWED )
Compiz.setLegacyFullscreenSupport(false); Compiz.setLegacyFullscreenSupport(false);
} finally {
unlockAWT();
} }
} }
static native void nDestroyWindow(long display, long window); static native void nDestroyWindow(long display, long window);
public void switchDisplayMode(DisplayMode mode) throws LWJGLException { public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
switchDisplayModeOnTmpDisplay(mode); switchDisplayModeOnTmpDisplay(mode);
current_mode = mode; current_mode = mode;
} finally {
unlockAWT();
} }
} }
@ -636,8 +623,7 @@ final class LinuxDisplay implements DisplayImplementation {
static native long nInternAtom(long display, String atom_name, boolean only_if_exists); static native long nInternAtom(long display, String atom_name, boolean only_if_exists);
public void resetDisplayMode() { public void resetDisplayMode() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
if( current_displaymode_extension == XRANDR ) if( current_displaymode_extension == XRANDR )
{ {
AccessController.doPrivileged(new PrivilegedAction<Object>() { AccessController.doPrivileged(new PrivilegedAction<Object>() {
@ -657,16 +643,13 @@ final class LinuxDisplay implements DisplayImplementation {
Compiz.setLegacyFullscreenSupport(false); Compiz.setLegacyFullscreenSupport(false);
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while resetting mode: " + e); LWJGLUtil.log("Caught exception while resetting mode: " + e);
} finally {
unlockAWT();
} }
} }
public int getGammaRampLength() { public int getGammaRampLength() {
if (!isXF86VidModeSupported()) if (!isXF86VidModeSupported())
return 0; return 0;
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
try { try {
incDisplay(); incDisplay();
try { try {
@ -681,8 +664,6 @@ final class LinuxDisplay implements DisplayImplementation {
LWJGLUtil.log("Failed to get gamma ramp length: " + e); LWJGLUtil.log("Failed to get gamma ramp length: " + e);
return 0; return 0;
} }
} finally {
unlockAWT();
} }
} }
private static native int nGetGammaRampLength(long display, int screen) throws LWJGLException; private static native int nGetGammaRampLength(long display, int screen) throws LWJGLException;
@ -694,12 +675,9 @@ final class LinuxDisplay implements DisplayImplementation {
} }
private void doSetGamma(ByteBuffer native_gamma) throws LWJGLException { private void doSetGamma(ByteBuffer native_gamma) throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
setGammaRampOnTmpDisplay(native_gamma); setGammaRampOnTmpDisplay(native_gamma);
current_gamma = native_gamma; current_gamma = native_gamma;
} finally {
unlockAWT();
} }
} }
@ -727,8 +705,7 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public DisplayMode init() throws LWJGLException { public DisplayMode init() throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
Compiz.init(); Compiz.init();
delete_atom = internAtom("WM_DELETE_WINDOW", false); delete_atom = internAtom("WM_DELETE_WINDOW", false);
@ -756,22 +733,17 @@ final class LinuxDisplay implements DisplayImplementation {
saved_gamma = getCurrentGammaRamp(); saved_gamma = getCurrentGammaRamp();
current_gamma = saved_gamma; current_gamma = saved_gamma;
return saved_mode; return saved_mode;
} finally {
unlockAWT();
} }
} }
private static DisplayMode getCurrentXRandrMode() throws LWJGLException { private static DisplayMode getCurrentXRandrMode() throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
return nGetCurrentXRandrMode(getDisplay(), getDefaultScreen()); return nGetCurrentXRandrMode(getDisplay(), getDefaultScreen());
} finally { } finally {
decDisplay(); decDisplay();
} }
} finally {
unlockAWT();
} }
} }
@ -779,26 +751,20 @@ final class LinuxDisplay implements DisplayImplementation {
private static native DisplayMode nGetCurrentXRandrMode(long display, int screen) throws LWJGLException; private static native DisplayMode nGetCurrentXRandrMode(long display, int screen) throws LWJGLException;
public void setTitle(String title) { public void setTitle(String title) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
final ByteBuffer titleText = MemoryUtil.encodeUTF8(title); final ByteBuffer titleText = MemoryUtil.encodeUTF8(title);
nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1); nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1);
} finally {
unlockAWT();
} }
} }
private static native void nSetTitle(long display, long window, long title, int len); private static native void nSetTitle(long display, long window, long title, int len);
/** the WM_CLASS hint is needed by some WM's e.g. gnome shell */ /** the WM_CLASS hint is needed by some WM's e.g. gnome shell */
private void setClassHint(String wm_name, String wm_class) { private void setClassHint(String wm_name, String wm_class) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
final ByteBuffer nameText = MemoryUtil.encodeUTF8(wm_name); final ByteBuffer nameText = MemoryUtil.encodeUTF8(wm_name);
final ByteBuffer classText = MemoryUtil.encodeUTF8(wm_class); final ByteBuffer classText = MemoryUtil.encodeUTF8(wm_class);
nSetClassHint(getDisplay(), getWindow(), MemoryUtil.getAddress(nameText), MemoryUtil.getAddress(classText)); nSetClassHint(getDisplay(), getWindow(), MemoryUtil.getAddress(nameText), MemoryUtil.getAddress(classText));
} finally {
unlockAWT();
} }
} }
private static native void nSetClassHint(long display, long window, long wm_name, long wm_class); private static native void nSetClassHint(long display, long window, long wm_name, long wm_class);
@ -916,28 +882,21 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public void update() { public void update() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
processEvents(); processEvents();
checkInput(); checkInput();
} finally {
unlockAWT();
} }
} }
public void reshape(int x, int y, int width, int height) { public void reshape(int x, int y, int width, int height) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
nReshape(getDisplay(), getWindow(), x, y, width, height); nReshape(getDisplay(), getWindow(), x, y, width, height);
} finally {
unlockAWT();
} }
} }
private static native void nReshape(long display, long window, int x, int y, int width, int height); private static native void nReshape(long display, long window, int x, int y, int width, int height);
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException { public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
if (current_displaymode_extension == XRANDR) { if (current_displaymode_extension == XRANDR) {
// nGetAvailableDisplayModes cannot be trusted. Use it only for bitsPerPixel // nGetAvailableDisplayModes cannot be trusted. Use it only for bitsPerPixel
@ -961,8 +920,6 @@ final class LinuxDisplay implements DisplayImplementation {
decDisplay(); decDisplay();
} }
} }
} finally {
unlockAWT();
} }
} }
private static native DisplayMode[] nGetAvailableDisplayModes(long display, int screen, int extension) throws LWJGLException; private static native DisplayMode[] nGetAvailableDisplayModes(long display, int screen, int extension) throws LWJGLException;
@ -977,11 +934,8 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public void createMouse() throws LWJGLException { public void createMouse() throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
mouse = new LinuxMouse(getDisplay(), getWindow(), getWindow()); mouse = new LinuxMouse(getDisplay(), getWindow(), getWindow());
} finally {
unlockAWT();
} }
} }
@ -991,29 +945,20 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) { public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
mouse.poll(grab, coord_buffer, buttons); mouse.poll(grab, coord_buffer, buttons);
} finally {
unlockAWT();
} }
} }
public void readMouse(ByteBuffer buffer) { public void readMouse(ByteBuffer buffer) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
mouse.read(buffer); mouse.read(buffer);
} finally {
unlockAWT();
} }
} }
public void setCursorPosition(int x, int y) { public void setCursorPosition(int x, int y) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
mouse.setCursorPosition(x, y); mouse.setCursorPosition(x, y);
} finally {
unlockAWT();
} }
} }
@ -1165,15 +1110,12 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public void grabMouse(boolean new_grab) { public void grabMouse(boolean new_grab) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
if (new_grab != grab) { if (new_grab != grab) {
grab = new_grab; grab = new_grab;
updateInputGrab(); updateInputGrab();
mouse.changeGrabbed(grab, shouldWarpPointer()); mouse.changeGrabbed(grab, shouldWarpPointer());
} }
} finally {
unlockAWT();
} }
} }
@ -1182,8 +1124,7 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public int getNativeCursorCapabilities() { public int getNativeCursorCapabilities() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
return nGetNativeCursorCapabilities(getDisplay()); return nGetNativeCursorCapabilities(getDisplay());
@ -1192,25 +1133,19 @@ final class LinuxDisplay implements DisplayImplementation {
} }
} catch (LWJGLException e) { } catch (LWJGLException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} finally {
unlockAWT();
} }
} }
private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException; private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException;
public void setNativeCursor(Object handle) throws LWJGLException { public void setNativeCursor(Object handle) throws LWJGLException {
current_cursor = getCursorHandle(handle); current_cursor = getCursorHandle(handle);
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
updateCursor(); updateCursor();
} finally {
unlockAWT();
} }
} }
public int getMinCursorSize() { public int getMinCursorSize() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
return nGetMinCursorSize(getDisplay(), getWindow()); return nGetMinCursorSize(getDisplay(), getWindow());
@ -1220,15 +1155,12 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Exception occurred in getMinCursorSize: " + e); LWJGLUtil.log("Exception occurred in getMinCursorSize: " + e);
return 0; return 0;
} finally {
unlockAWT();
} }
} }
private static native int nGetMinCursorSize(long display, long window); private static native int nGetMinCursorSize(long display, long window);
public int getMaxCursorSize() { public int getMaxCursorSize() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
return nGetMaxCursorSize(getDisplay(), getWindow()); return nGetMaxCursorSize(getDisplay(), getWindow());
@ -1238,47 +1170,33 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Exception occurred in getMaxCursorSize: " + e); LWJGLUtil.log("Exception occurred in getMaxCursorSize: " + e);
return 0; return 0;
} finally {
unlockAWT();
} }
} }
private static native int nGetMaxCursorSize(long display, long window); private static native int nGetMaxCursorSize(long display, long window);
/* Keyboard */ /* Keyboard */
public void createKeyboard() throws LWJGLException { public void createKeyboard() throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
keyboard = new LinuxKeyboard(getDisplay(), getWindow()); keyboard = new LinuxKeyboard(getDisplay(), getWindow());
} finally {
unlockAWT();
} }
} }
public void destroyKeyboard() { public void destroyKeyboard() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
keyboard.destroy(getDisplay()); keyboard.destroy(getDisplay());
keyboard = null; keyboard = null;
} finally {
unlockAWT();
} }
} }
public void pollKeyboard(ByteBuffer keyDownBuffer) { public void pollKeyboard(ByteBuffer keyDownBuffer) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
keyboard.poll(keyDownBuffer); keyboard.poll(keyDownBuffer);
} finally {
unlockAWT();
} }
} }
public void readKeyboard(ByteBuffer buffer) { public void readKeyboard(ByteBuffer buffer) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
keyboard.read(buffer); keyboard.read(buffer);
} finally {
unlockAWT();
} }
} }
@ -1290,8 +1208,7 @@ final class LinuxDisplay implements DisplayImplementation {
static native long nCreateBlankCursor(long display, long window); static native long nCreateBlankCursor(long display, long window);
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
long cursor = nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1); long cursor = nCreateCursor(getDisplay(), width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
@ -1300,8 +1217,6 @@ final class LinuxDisplay implements DisplayImplementation {
decDisplay(); decDisplay();
throw e; throw e;
} }
} finally {
unlockAWT();
} }
} }
@ -1310,19 +1225,15 @@ final class LinuxDisplay implements DisplayImplementation {
} }
public void destroyCursor(Object cursorHandle) { public void destroyCursor(Object cursorHandle) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
nDestroyCursor(getDisplay(), getCursorHandle(cursorHandle)); nDestroyCursor(getDisplay(), getCursorHandle(cursorHandle));
decDisplay(); decDisplay();
} finally {
unlockAWT();
} }
} }
static native void nDestroyCursor(long display, long cursorHandle); static native void nDestroyCursor(long display, long cursorHandle);
public int getPbufferCapabilities() { public int getPbufferCapabilities() {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
return nGetPbufferCapabilities(getDisplay(), getDefaultScreen()); return nGetPbufferCapabilities(getDisplay(), getDefaultScreen());
@ -1332,8 +1243,6 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Exception occurred in getPbufferCapabilities: " + e); LWJGLUtil.log("Exception occurred in getPbufferCapabilities: " + e);
return 0; return 0;
} finally {
unlockAWT();
} }
} }
private static native int nGetPbufferCapabilities(long display, int screen); private static native int nGetPbufferCapabilities(long display, int screen);
@ -1426,8 +1335,7 @@ final class LinuxDisplay implements DisplayImplementation {
* @return number of icons used. * @return number of icons used.
*/ */
public int setIcon(ByteBuffer[] icons) { public int setIcon(ByteBuffer[] icons) {
lockAWT(); try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay(); incDisplay();
try { try {
// get icons as cardinal ARGB format // get icons as cardinal ARGB format
@ -1441,8 +1349,6 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) { } catch (LWJGLException e) {
LWJGLUtil.log("Failed to set display icon: " + e); LWJGLUtil.log("Failed to set display icon: " + e);
return 0; return 0;
} finally {
unlockAWT();
} }
} }

View File

@ -52,8 +52,7 @@ final class LinuxDisplayPeerInfo extends LinuxPeerInfo {
LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException { LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException {
egl = false; egl = false;
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
GLContext.loadOpenGLLibrary(); GLContext.loadOpenGLLibrary();
try { try {
LinuxDisplay.incDisplay(); LinuxDisplay.incDisplay();
@ -67,18 +66,13 @@ final class LinuxDisplayPeerInfo extends LinuxPeerInfo {
GLContext.unloadOpenGLLibrary(); GLContext.unloadOpenGLLibrary();
throw e; throw e;
} }
} finally {
LinuxDisplay.unlockAWT();
} }
} }
private static native void initDefaultPeerInfo(long display, int screen, ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException; private static native void initDefaultPeerInfo(long display, int screen, ByteBuffer peer_info_handle, PixelFormat pixel_format) throws LWJGLException;
protected void doLockAndInitHandle() throws LWJGLException { protected void doLockAndInitHandle() throws LWJGLException {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
initDrawable(LinuxDisplay.getWindow(), getHandle()); initDrawable(LinuxDisplay.getWindow(), getHandle());
} finally {
LinuxDisplay.unlockAWT();
} }
} }
private static native void initDrawable(long window, ByteBuffer peer_info_handle); private static native void initDrawable(long window, ByteBuffer peer_info_handle);
@ -90,13 +84,13 @@ final class LinuxDisplayPeerInfo extends LinuxPeerInfo {
public void destroy() { public void destroy() {
super.destroy(); super.destroy();
if ( egl ) if (egl) {
org.lwjgl.opengles.GLContext.unloadOpenGLLibrary(); org.lwjgl.opengles.GLContext.unloadOpenGLLibrary();
else { } else {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
LinuxDisplay.decDisplay(); LinuxDisplay.decDisplay();
GLContext.unloadOpenGLLibrary(); GLContext.unloadOpenGLLibrary();
LinuxDisplay.unlockAWT(); }
} }
} }
} }

View File

@ -43,8 +43,7 @@ import org.lwjgl.LWJGLException;
*/ */
final class LinuxPbufferPeerInfo extends LinuxPeerInfo { final class LinuxPbufferPeerInfo extends LinuxPeerInfo {
LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException { LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
GLContext.loadOpenGLLibrary(); GLContext.loadOpenGLLibrary();
try { try {
LinuxDisplay.incDisplay(); LinuxDisplay.incDisplay();
@ -58,18 +57,16 @@ final class LinuxPbufferPeerInfo extends LinuxPeerInfo {
GLContext.unloadOpenGLLibrary(); GLContext.unloadOpenGLLibrary();
throw e; throw e;
} }
} finally {
LinuxDisplay.unlockAWT();
} }
} }
private static native void nInitHandle(long display, int screen, ByteBuffer handle, int width, int height, PixelFormat pixel_format) throws LWJGLException; private static native void nInitHandle(long display, int screen, ByteBuffer handle, int width, int height, PixelFormat pixel_format) throws LWJGLException;
public void destroy() { public void destroy() {
LinuxDisplay.lockAWT(); try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
nDestroy(getHandle()); nDestroy(getHandle());
LinuxDisplay.decDisplay(); LinuxDisplay.decDisplay();
GLContext.unloadOpenGLLibrary(); GLContext.unloadOpenGLLibrary();
LinuxDisplay.unlockAWT(); }
} }
private static native void nDestroy(ByteBuffer handle); private static native void nDestroy(ByteBuffer handle);

View File

@ -35,6 +35,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Cursor; import org.lwjgl.input.Cursor;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse; import org.lwjgl.input.Mouse;
@ -389,7 +390,11 @@ public class HWCursorTest {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//sync frame (only works on windows) //sync frame (only works on windows)
Display.setVSyncEnabled(true); try {
Display.setVSyncEnabled(true);
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
} }
/** /**

View File

@ -267,8 +267,13 @@ public class FullScreenWindowedTest {
glViewport(0, 0, mode.getWidth(), mode.getHeight()); glViewport(0, 0, mode.getWidth(), mode.getHeight());
//set clear color to black //set clear color to black
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//sync frame (only works on windows)
Display.setVSyncEnabled(true); try {
//sync frame (only works on windows)
Display.setVSyncEnabled(true);
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
} }
/** /**
* Test entry point * Test entry point

View File

@ -367,8 +367,12 @@ public class PbufferTest {
* Initializes OGL * Initializes OGL
*/ */
private void glInit() { private void glInit() {
//sync frame (only works on windows) try {
Display.setVSyncEnabled(true); //sync frame (only works on windows)
Display.setVSyncEnabled(true);
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);

View File

@ -376,8 +376,12 @@ public final class PbufferTest {
* Initializes OGL * Initializes OGL
*/ */
private void glInit() { private void glInit() {
// Sync frame (only works on windows) try {
Display.setVSyncEnabled(true); // Sync frame (only works on windows)
Display.setVSyncEnabled(true);
} catch (LWJGLException e) {
throw new RuntimeException(e);
}
// Create shared texture // Create shared texture
IntBuffer buffer = BufferUtils.createIntBuffer(1); IntBuffer buffer = BufferUtils.createIntBuffer(1);

View File

@ -249,7 +249,7 @@ public final class SpriteShootout {
renderer.updateBalls(ballCount); renderer.updateBalls(ballCount);
} }
private void run() { private void run() throws LWJGLException {
long startTime = System.currentTimeMillis() + 5000; long startTime = System.currentTimeMillis() + 5000;
long fps = 0; long fps = 0;
@ -288,7 +288,7 @@ public final class SpriteShootout {
} }
} }
private void handleInput() { private void handleInput() throws LWJGLException {
if ( Display.isCloseRequested() ) if ( Display.isCloseRequested() )
run = false; run = false;
@ -746,4 +746,4 @@ public final class SpriteShootout {
} }
} }

View File

@ -247,7 +247,7 @@ public final class SpriteShootout2P {
renderer.updateBalls(ballCount); renderer.updateBalls(ballCount);
} }
private void run() { private void run() throws LWJGLException {
long startTime = System.currentTimeMillis() + 5000; long startTime = System.currentTimeMillis() + 5000;
long fps = 0; long fps = 0;
@ -284,7 +284,7 @@ public final class SpriteShootout2P {
} }
} }
private void handleInput() { private void handleInput() throws LWJGLException {
if ( Display.isCloseRequested() ) if ( Display.isCloseRequested() )
run = false; run = false;
@ -621,4 +621,4 @@ public final class SpriteShootout2P {
} }
} }

View File

@ -302,7 +302,7 @@ public final class SpriteShootoutCL {
renderer.updateBalls(ballCount); renderer.updateBalls(ballCount);
} }
private void run() { private void run() throws LWJGLException {
long startTime = System.currentTimeMillis() + 5000; long startTime = System.currentTimeMillis() + 5000;
long fps = 0; long fps = 0;
@ -338,7 +338,7 @@ public final class SpriteShootoutCL {
} }
} }
private void handleInput() { private void handleInput() throws LWJGLException {
if ( Display.isCloseRequested() ) if ( Display.isCloseRequested() )
run = false; run = false;
@ -595,4 +595,4 @@ public final class SpriteShootoutCL {
} }
} }

View File

@ -281,7 +281,7 @@ public final class SpriteShootoutMapped {
renderer.updateBalls(ballCount); renderer.updateBalls(ballCount);
} }
private void run() { private void run() throws LWJGLException {
long startTime = System.currentTimeMillis() + 5000; long startTime = System.currentTimeMillis() + 5000;
long fps = 0; long fps = 0;
@ -320,7 +320,7 @@ public final class SpriteShootoutMapped {
} }
} }
private void handleInput() { private void handleInput() throws LWJGLException {
if ( Display.isCloseRequested() ) if ( Display.isCloseRequested() )
run = false; run = false;
@ -835,4 +835,4 @@ public final class SpriteShootoutMapped {
} }
} }

View File

@ -279,7 +279,7 @@ public class FullScreenWindowedTest {
} }
/** Initializes OGL */ /** Initializes OGL */
private void glInit() { private void glInit() throws LWJGLException {
// Go into orthographic projection mode. // Go into orthographic projection mode.
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();

View File

@ -52,7 +52,7 @@ import javax.tools.Diagnostic;
*/ */
@SupportedAnnotationTypes({ "*" }) @SupportedAnnotationTypes({ "*" })
@SupportedSourceVersion(SourceVersion.RELEASE_8) @SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedOptions({ "binpath", "typemap", "generatechecks", "contextspecific" }) @SupportedOptions({ "binpath", "genpath", "typemap", "generatechecks", "nogeneratechecks", "contextspecific" })
public class GeneratorProcessor extends AbstractProcessor { public class GeneratorProcessor extends AbstractProcessor {
private static boolean first_round = true; private static boolean first_round = true;
@ -66,11 +66,16 @@ public class GeneratorProcessor extends AbstractProcessor {
Map<String, String> options = processingEnv.getOptions(); Map<String, String> options = processingEnv.getOptions();
String typemap_classname = options.get("typemap"); String typemap_classname = options.get("typemap");
String bin_path = options.get("binpath"); String bin_path = options.get("binpath");
boolean generate_error_checks = options.containsKey("generatechecks"); String gen_path = options.get("genpath");
boolean generate_error_checks = options.containsKey("generatechecks") && !options.containsKey("nogeneratechecks");
boolean context_specific = options.containsKey("contextspecific"); boolean context_specific = options.containsKey("contextspecific");
if ( bin_path == null ) { if ( bin_path == null ) {
throw new RuntimeException("No path specified for the bin directory with -Abinpath=<path>"); throw new RuntimeException("No path specified for the bin directory with -Abinpath=<path>");
} }
if ( gen_path == null ) {
throw new RuntimeException("No path specified for the gen directory with -Agenpath=<path>");
}
if ( typemap_classname == null ) { if ( typemap_classname == null ) {
throw new RuntimeException("No TypeMap class name specified with -Atypemap=<class-name>"); throw new RuntimeException("No TypeMap class name specified with -Atypemap=<class-name>");
@ -82,7 +87,7 @@ public class GeneratorProcessor extends AbstractProcessor {
TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance()); TypeMap type_map = (TypeMap)(Class.forName(typemap_classname).newInstance());
for ( Iterator<TypeElement> it = ElementFilter.typesIn(roundEnv.getRootElements()).iterator(); it.hasNext(); ) { for ( Iterator<TypeElement> it = ElementFilter.typesIn(roundEnv.getRootElements()).iterator(); it.hasNext(); ) {
lastFile = it.next(); lastFile = it.next();
lastFile.accept(new GeneratorVisitor(processingEnv, type_map, generate_error_checks, context_specific, generatorLM), null); lastFile.accept(new GeneratorVisitor(processingEnv, gen_path, type_map, generate_error_checks, context_specific, generatorLM), null);
} }
first_round = false; first_round = false;
return true; return true;

View File

@ -34,11 +34,18 @@ package org.lwjgl.util.generator;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.io.FileWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.nio.Buffer; import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.ProcessingEnvironment;
@ -60,13 +67,15 @@ import javax.tools.StandardLocation;
public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> { public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
private final ProcessingEnvironment env; private final ProcessingEnvironment env;
private final String gen_path;
private final TypeMap type_map; private final TypeMap type_map;
private final boolean generate_error_checks; private final boolean generate_error_checks;
private final boolean context_specific; private final boolean context_specific;
private final long generatorLM; private final long generatorLM;
public GeneratorVisitor(ProcessingEnvironment env, TypeMap type_map, boolean generate_error_checks, boolean context_specific, long generatorLM) { public GeneratorVisitor(ProcessingEnvironment env, String gen_path, TypeMap type_map, boolean generate_error_checks, boolean context_specific, long generatorLM) {
this.env = env; this.env = env;
this.gen_path = gen_path;
this.type_map = type_map; this.type_map = type_map;
this.generate_error_checks = generate_error_checks; this.generate_error_checks = generate_error_checks;
this.context_specific = context_specific; this.context_specific = context_specific;
@ -238,8 +247,6 @@ public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
} }
JavaMethodsGenerator.generateMethodsJava(env, type_map, java_writer, d, generate_error_checks, context_specific); JavaMethodsGenerator.generateMethodsJava(env, type_map, java_writer, d, generate_error_checks, context_specific);
java_writer.println("}"); java_writer.println("}");
String qualified_interface_name = Utils.getQualifiedClassName(d);
env.getMessager().printMessage(Diagnostic.Kind.NOTE, "Generated class " + qualified_interface_name);
} }
private void generateNativeSource(TypeElement d) throws IOException { private void generateNativeSource(TypeElement d) throws IOException {
@ -277,46 +284,92 @@ public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
env.getMessager().printMessage(Kind.NOTE, "Generated C source " + qualified_interface_name); env.getMessager().printMessage(Kind.NOTE, "Generated C source " + qualified_interface_name);
} }
private boolean isFileExistingAndIdentical(Path file, String expected) throws IOException {
if (!Files.exists(file)) return false;
try (Reader existingIs = Files.newBufferedReader(file, Charset.forName("UTF-8"))) {
int i = 0;
int c;
do {
c = existingIs.read();
if (c == -1) return i == expected.length();
if (expected.length() <= i || c != expected.charAt(i++)) {
if (expected.length() > (i-1)) {
env.getMessager().printMessage(Kind.NOTE, "mismatch at " + i + ": " + c);
} else {
env.getMessager().printMessage(Kind.NOTE, "mismatch at " + i + ": EOF");
}
return false;
}
} while (c != -1);
if (i != expected.length()) {
return false;
}
}
return true;
}
@Override @Override
public Void visitTypeAsInterface(TypeElement e, Void p) { public Void visitTypeAsInterface(TypeElement e, Void p) {
final File input = new File("src/templates/" + e.getQualifiedName().toString().replace('.', '/') + ".java"); final File input = new File("src/templates/" + e.getQualifiedName().toString().replace('.', '/') + ".java");
final Collection<? extends ExecutableElement> methods = Utils.getMethods(e); final Collection<? extends ExecutableElement> methods = Utils.getMethods(e);
if ( methods.isEmpty() && Utils.getFields(e).isEmpty() ) { if (methods.isEmpty() && Utils.getFields(e).isEmpty()) {
return DEFAULT_VALUE; return DEFAULT_VALUE;
} }
//env.getMessager().printMessage(Kind.NOTE, "methods count : " + Utils.getMethods(e).size() + " fields count : " + Utils.getFields(e).size(), e); //env.getMessager().printMessage(Kind.NOTE, "methods count : " + Utils.getMethods(e).size() + " fields count : " + Utils.getFields(e).size(), e);
for ( final ExecutableElement method : methods ) { for (ExecutableElement method : methods) {
validateMethod(method); validateMethod(method);
} }
// TODO: Back-port LWJGL 3's generation file handling (generate in-memory and avoid touching files if nothing has changed) // TODO: Back-port LWJGL 3's generation file handling (generate in-memory and avoid touching files if nothing has changed)
try (PrintWriter java_writer = new PrintWriter(env.getFiler().createSourceFile(Utils.getQualifiedClassName(e), env.getElementUtils().getPackageOf(e)).openWriter())) { StringWriter java_writer = new StringWriter();
generateJavaSource(e, java_writer); try {
generateJavaSource(e, new PrintWriter(java_writer));
} catch (IOException ex) {
throw new RuntimeException("Failed to generate the Java sources for " + e, ex);
}
if ( methods.size() > 0 ) { String qualified_interface_name = Utils.getQualifiedClassName(e);
boolean noNative = true; final Path output = Path.of(this.gen_path + "/" + qualified_interface_name.replace('.', '/') + ".java");
for ( final ExecutableElement method : methods ) { String newStr = java_writer.toString();
Alternate alt_annotation = method.getAnnotation(Alternate.class); try {
if ( (alt_annotation == null || alt_annotation.nativeAlt()) && method.getAnnotation(Reuse.class) == null ) { if (isFileExistingAndIdentical(output, newStr)) {
noNative = false; return DEFAULT_VALUE;
break;
}
}
if ( noNative ) {
return DEFAULT_VALUE;
}
try {
generateNativeSource(e);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
} }
return DEFAULT_VALUE; Files.createDirectories(output.getParent());
Files.createFile(output);
} catch (IOException ex) {
throw new RuntimeException("Failed to create the output file for " + e, ex);
}
//try (Writer java_file_writer = env.getFiler().createSourceFile(Utils.getQualifiedClassName(e), env.getElementUtils().getPackageOf(e)).openWriter()) {
try (Writer java_file_writer = new FileWriter(output.toFile())) {
java_file_writer.write(newStr);
env.getMessager().printMessage(Diagnostic.Kind.NOTE, "Generated class " + qualified_interface_name);
} catch (Exception ex) { } catch (Exception ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} }
if (methods.size() > 0) {
boolean noNative = true;
for (ExecutableElement method : methods) {
Alternate alt_annotation = method.getAnnotation(Alternate.class);
if ((alt_annotation == null || alt_annotation.nativeAlt()) && method.getAnnotation(Reuse.class) == null) {
noNative = false;
break;
}
}
if (noNative) {
return DEFAULT_VALUE;
}
try {
generateNativeSource(e);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
return DEFAULT_VALUE;
} }
private static ByteBuffer readFile(final File file) throws IOException { private static ByteBuffer readFile(final File file) throws IOException {