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/windows/Debug
/src/native/windows/Release
/src/native/*/org_lwjgl_*.h
/src/native/*/*/org_lwjgl_*.h
/src/native/**/*.h
/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">
<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>
<!-- Cleans up any files created during the execution of this script -->
@ -25,8 +27,6 @@
<!-- Creates a distribution of LWJGL -->
<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
message="All data in the ${lwjgl.target} folder will be deleted. Continue? "
validargs="yes,no"
@ -51,7 +51,6 @@
<antcall target="compile" />
<antcall target="-createjars" />
<antcall target="-jars_NoDEP" />
<antcall target="javadoc" />
<!-- copy resources to res folder -->
@ -76,21 +75,11 @@
<!-- 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">
<antcall target="-jars_NoDEP" />
</target>
<!-- 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/"
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>
<!-- Packages the java files -->
@ -108,7 +97,7 @@
<!-- Packages the java files -->
<target name="-createjars">
<!-- 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.dependencies"/>
<manifest>
@ -117,13 +106,13 @@
</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_extra.fileset" />
</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" />
</jar>
</target>
@ -175,144 +164,202 @@
</jar>
</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 -->
<target name="headers" description="invokes javah on java classes" depends="compile">
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.native}/linux">
<class name="org.lwjgl.LinuxSysImplementation" />
<class name="org.lwjgl.opengl.LinuxEvent" />
<class name="org.lwjgl.opengl.LinuxMouse" />
<class name="org.lwjgl.opengl.LinuxKeyboard" />
<class name="org.lwjgl.opengl.LinuxDisplay" />
<class name="org.lwjgl.opengl.LinuxPeerInfo" />
</javah>
<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.native}/linux"/>
<javah classpath="${lwjgl.target.gen.classes}" destdir="${lwjgl.src.native}/linux/opengl">
<class name="org.lwjgl.opengl.LinuxPbufferPeerInfo"/>
<class name="org.lwjgl.opengl.LinuxDisplayPeerInfo"/>
<class name="org.lwjgl.opengl.LinuxAWTGLCanvasPeerInfo"/>
<class name="org.lwjgl.opengl.LinuxContextImplementation"/>
<class name="org.lwjgl.opengl.LinuxCanvasImplementation"/>
</javah>
<src>
<fileset dir="${lwjgl.target.gen.java}">
<include name="org/lwjgl/LinuxSysImplementation.java"/>
<include name="org/lwjgl/opengl/LinuxEvent.java"/>
<include name="org/lwjgl/opengl/LinuxMouse.java"/>
<include name="org/lwjgl/opengl/LinuxKeyboard.java"/>
<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">
<class name="org.lwjgl.WindowsSysImplementation"/>
<class name="org.lwjgl.opengl.WindowsKeyboard" />
<class name="org.lwjgl.opengl.WindowsRegistry" />
<class name="org.lwjgl.opengl.WindowsDisplay"/>
<class name="org.lwjgl.opengl.WindowsDisplayPeerInfo"/>
<class name="org.lwjgl.opengl.WindowsAWTGLCanvasPeerInfo"/>
</javah>
<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.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">
<class name="org.lwjgl.opengl.WindowsPbufferPeerInfo"/>
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
<class name="org.lwjgl.opengl.WindowsContextImplementation"/>
</javah>
<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.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">
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
</javah>
<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.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">
<class name="org.lwjgl.MacOSXSysImplementation" />
<class name="org.lwjgl.opengl.MacOSXCanvasPeerInfo" />
<class name="org.lwjgl.opengl.MacOSXPeerInfo" />
<class name="org.lwjgl.opengl.MacOSXPbufferPeerInfo" />
<class name="org.lwjgl.opengl.MacOSXDisplay" />
<class name="org.lwjgl.opengl.MacOSXContextImplementation" />
<class name="org.lwjgl.opengl.MacOSXNativeKeyboard" />
<class name="org.lwjgl.opengl.MacOSXNativeMouse" />
<class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
</javah>
<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.native}/windows/opengles"/>
<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}">
<class name="org.lwjgl.opengl.AWTSurfaceLock" />
<class name="org.lwjgl.DefaultSysImplementation" />
<class name="org.lwjgl.input.Cursor" />
<class name="org.lwjgl.input.Keyboard" />
<class name="org.lwjgl.input.Mouse" />
<class name="org.lwjgl.openal.AL" />
<class name="org.lwjgl.opencl.CL" />
<class name="org.lwjgl.opencl.CallbackUtil" />
<class name="org.lwjgl.BufferUtils" />
</javah>
<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.native}/macosx"/>
<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">
<class name="org.lwjgl.opengl.GLContext"/>
<class name="org.lwjgl.opengl.Pbuffer"/>
<class name="org.lwjgl.opengl.CallbackUtil"/>
<class name="org.lwjgl.opengl.NVPresentVideoUtil"/>
<class name="org.lwjgl.opengl.NVVideoCaptureUtil"/>
</javah>
<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}"/>
<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">
<class name="org.lwjgl.opengles.EGL"/>
<class name="org.lwjgl.opengles.EGLKHRFenceSync"/>
<class name="org.lwjgl.opengles.EGLKHRReusableSync"/>
<class name="org.lwjgl.opengles.EGLNVSync"/>
<class name="org.lwjgl.opengles.GLContext"/>
<class name="org.lwjgl.opengles.CallbackUtil"/>
</javah>
<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}/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 name="touch-version">
@ -452,35 +499,23 @@
<!-- Compiles LWJGL on Win32 platforms -->
<target name="-compile_native_win32" if="lwjgl.platform.windows">
<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"/>
</target>
<!-- Compiles LWJGL on Linux platforms -->
<target name="-compile_native_linux" if="lwjgl.platform.linux">
<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"/> -->
</target>
<!-- Compiles LWJGL on FreeBSD platforms -->
<target name="-compile_native_freebsd" if="lwjgl.platform.freebsd">
<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>
<!-- Compiles LWJGL on OpenBSD platforms -->
<target name="-compile_native_openbsd" if="lwjgl.platform.openbsd">
<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>
@ -488,16 +523,12 @@
<target name="-compile_native_solaris" if="lwjgl.platform.solaris">
<!-- Reusing the linux ant task, but copy the output to solaris -->
<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"/>
</target>
<!-- Compiles LWJGL on Mac platforms -->
<target name="-compile_native_macosx" if="lwjgl.platform.macosx">
<ant antfile="platform_build/macosx_ant/build.xml"/>
<copy file="${lwjgl.target.bundle}/liblwjgl.dylib" todir="${lwjgl.lib}/macosx"/>
<version-check platform="macosx"/>
</target>
@ -516,17 +547,11 @@
<!-- Compiles LWJGL ES on Win32 platforms -->
<target name="-compile_native_win32_es" if="lwjgl.platform.windows">
<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>
<!-- Compiles LWJGL ES on Linux platforms -->
<target name="-compile_native_linux_es" if="lwjgl.platform.linux">
<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 name="repack200" description="Pack200-repack a jar file">

View File

@ -2,23 +2,31 @@
<!-- ================================================================== -->
<!-- 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.java" location="${lwjgl.src}/java" />
<property name="lwjgl.src.native" location="${lwjgl.src}/native" />
<property name="lwjgl.src.headers" location="${lwjgl.src.native}/common" />
<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.gl" location="${lwjgl.src.templates}/org/lwjgl/opengl"/>

View File

@ -3,7 +3,7 @@
<!-- Compiles the Java generator source code -->
<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}"/>
</condition>
@ -35,17 +35,19 @@
<compilerarg value="-Xlint:none"/>
</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="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<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 path="${lwjgl.target.gen.java}"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.target.gen.native}/openal"/>
<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="${javac.args.debug}"/>
<src>
@ -83,13 +85,14 @@
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<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 path="${lwjgl.target.gen.java}"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.target.gen.native}/opengl"/>
<compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/>
<compilerarg value="-Agenpath=${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
<compilerarg value="-Acontextspecific"/>
@ -105,8 +108,10 @@
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<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 path="${lwjgl.target.gen.java}"/>
<src>
@ -121,8 +126,10 @@
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<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 path="${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/>
@ -160,13 +167,14 @@
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<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 path="${lwjgl.target.gen.java}"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.target.gen.native}/opengles"/>
<compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/>
<compilerarg value="-Agenpath=${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/>
<!--<compilerarg value="-Acontextspecific"/>-->
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
@ -182,8 +190,10 @@
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<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 path="${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/>
@ -228,13 +238,14 @@
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<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 path="${lwjgl.target.gen.java}"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.target.gen.native}/opencl"/>
<compilerarg value="-Abinpath=${lwjgl.target.gen.classes}"/>
<compilerarg value="-Agenpath=${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/>
<compilerarg value="-Acontextspecific"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
@ -250,8 +261,10 @@
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
<compilerarg value="-processorpath"/>
<compilerarg path="${lwjgl.target.gen.classes}"/>
<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 path="${lwjgl.target.gen.java}"/>
<compilerarg value="${javac.args.debug}"/>

View File

@ -3,8 +3,8 @@
<project name="lwjgl native code, linux" basedir="/dev/null" default="compile">
<property name="libname32" value="liblwjgl.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="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="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 -L${java.home}/lib/amd64 -ljawt" />
<property name="cflags32" value="-O3 -Wall -c -fPIC -std=c99 -Wunused"/>
<target name="compile">
@ -52,7 +52,7 @@
<target name="compile32" unless="build.64bit.only">
<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 value="-I${java.home}/include"/>
<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/opengl" includes="*.c"/>
</apply>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="gcc" failonerror="true">
<apply dir="${lwjgl.target.natives}" parallel="true" executable="gcc" failonerror="true">
<srcfile/>
<arg line="${linker_flags32}"/>
<fileset dir="${lwjgl.target.gen.obj}/i386" includes="*.o"/>
</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}"/>
</apply>
</target>
<target name="compile64" unless="build.32bit.only">
<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 value="-I${java.home}/include"/>
<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/opengl" includes="*.c"/>
</apply>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="gcc" failonerror="true">
<apply dir="${lwjgl.target.natives}" parallel="true" executable="gcc" failonerror="true">
<srcfile/>
<arg line="${linker_flags64}"/>
<fileset dir="${lwjgl.target.gen.obj}/x86_64" includes="*.o"/>
</apply>
<apply dir="${lwjgl.target.bundle}" parallel="true" executable="strip" failonerror="true">
<fileset file="${libname64}"/>
<apply dir="${lwjgl.target.natives}" parallel="true" executable="strip" failonerror="true">
<fileset file="${lwjgl.target.natives}/${libname64}"/>
</apply>
</target>
</project>

View File

@ -5,8 +5,8 @@
<property name="libname32" value="liblwjgl.so"/>
<property name="libname64" value="liblwjgl64.so"/>
<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="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="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 -L${java.home}/lib/amd64 -ljawt" />
<property name="cflags32" value="-O3 -Wall -c -fPIC -std=c99 -Wunused"/>
<target name="clean">

View File

@ -95,7 +95,7 @@
<target name="compile" depends="init">
<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"/>
<!-- Map from *.m and *.c to .o -->
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
@ -117,12 +117,12 @@
<not><isset property="jdk_lib"/></not>
</condition>
<apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true" skipemptyfilesets="false">
<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"/>
<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.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"/>
</apply>
<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"/>
<fileset file="${libname}"/>
</apply>
@ -173,7 +173,7 @@
<param name="libname" value="liblwjgl-x86_64.dylib"/>
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
</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"/>
<srcfile/>
<arg value="-output"/>
@ -198,12 +198,12 @@
<param name="libname" value="liblwjgl-x86_64.dylib"/>
<param name="linkerflags" value="-isysroot ${sdkroot} -arch x86_64 -mmacosx-version-min=${macos_link_ver}"/>
</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"/>
<srcfile/>
<arg value="-output"/>
<arg path="${lwjgl.target.bundle}/liblwjgl.dylib"/>
<fileset file="${lwjgl.target.bundle}/liblwjgl-x86_64.dylib"/>
<arg path="${lwjgl.target.natives}/liblwjgl.dylib"/>
<fileset file="${lwjgl.target.natives}/liblwjgl-x86_64.dylib"/>
</apply>
</target>
</project>

View File

@ -268,6 +268,32 @@ public class LWJGLUtil {
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 {
final String osName = getPrivilegedProperty("os.name");
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
* 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;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.Buffer;
import sun.misc.Unsafe;
import sun.reflect.FieldAccessor;
/**
* 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 final FieldAccessor addressAccessor;
private final MethodHandle addressAccessor;
AccessorReflectFast() {
Field address;
Field addressField;
try {
address = MemoryUtil.getAddressField();
addressField = MemoryUtil.getAddressField();
} catch (NoSuchFieldException e) {
throw new UnsupportedOperationException(e);
}
address.setAccessible(true);
addressField.setAccessible(true);
try {
Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class);
m.setAccessible(true);
addressAccessor = (FieldAccessor)m.invoke(address, true);
} catch (Exception e) {
addressAccessor = MethodHandles.lookup().unreflectGetter(addressField);
} catch (ReflectiveOperationException e) {
throw new UnsupportedOperationException(e);
}
}
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. */
public void setSwapInterval(int swap_interval) {
public void setSwapInterval(int swap_interval) throws LWJGLException {
synchronized ( SYNC_LOCK ) {
if ( context == null )
throw new IllegalStateException("Canvas not yet displayable");
@ -225,7 +225,7 @@ public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListe
}
/** Enable vsync */
public void setVSyncEnabled(boolean enabled) {
public void setVSyncEnabled(boolean enabled) throws LWJGLException {
setSwapInterval(enabled ? 1 : 0);
}
@ -411,4 +411,4 @@ public class AWTGLCanvas extends Canvas implements DrawableLWJGL, ComponentListe
setUpdate();
}
}
}

View File

@ -228,7 +228,7 @@ final class ContextGL implements Context {
* <p/>
* 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);
}
@ -296,4 +296,4 @@ final class ContextGL implements Context {
}
}
}
}

View File

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

View File

@ -328,7 +328,7 @@ public final class Display {
context.releaseDrawable();
}
} 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 */
public static String getTitle() {
synchronized ( GlobalLock.lock ) {
return title;
}
return title;
}
/** Return the last parent set with setParent(). */
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 */
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 {
drawable.checkGLError();
} catch (OpenGLException e) {
LWJGLUtil.log("OpenGL error during context creation: " + e.getMessage());
LWJGLUtil.logger().log("OpenGL error during context creation", e);
}
setSwapInterval(swap_interval);
}
@ -1042,20 +1036,19 @@ public final class Display {
/** Gets a boolean property as a privileged action. */
static boolean getPrivilegedBoolean(final String property_name) {
return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
return Boolean.getBoolean(property_name);
String s = getPrivilegedString(property_name);
if (s == null || s.equals("false")) return false;
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. */
static String getPrivilegedString(final String property_name) {
return AccessController.doPrivileged(new PrivilegedAction<String>() {
public String run() {
return System.getProperty(property_name);
}
});
return AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(property_name));
}
private static void initControls() {
@ -1065,22 +1058,14 @@ public final class Display {
try {
Mouse.create();
} catch (LWJGLException e) {
if ( LWJGLUtil.DEBUG ) {
e.printStackTrace(System.err);
} else {
LWJGLUtil.log("Failed to create Mouse: " + e);
}
LWJGLUtil.logger().log("Failed to create Mouse", e);
}
}
if ( !Keyboard.isCreated() && !getPrivilegedBoolean("org.lwjgl.opengl.Display.nokeyboard") ) {
try {
Keyboard.create();
} catch (LWJGLException e) {
if ( LWJGLUtil.DEBUG ) {
e.printStackTrace(System.err);
} else {
LWJGLUtil.log("Failed to create Keyboard: " + e);
}
LWJGLUtil.logger().log("Failed to create Keyboard", e);
}
}
}
@ -1091,7 +1076,7 @@ public final class Display {
* regardless of whether the Display was the current rendering context.
*/
public static void destroy() {
if(isCreated()) {
if (isCreated()) {
drawable.destroy();
}
}
@ -1108,9 +1093,7 @@ public final class Display {
/** @return true if the window's native peer has been created */
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
*/
public static void setSwapInterval(int value) {
public static void setSwapInterval(int value) throws LWJGLException {
synchronized ( GlobalLock.lock ) {
swap_interval = value;
if ( isCreated() )
@ -1137,10 +1120,8 @@ public final class Display {
*
* @param sync true to synchronize; false to ignore synchronization
*/
public static void setVSyncEnabled(boolean sync) {
synchronized ( GlobalLock.lock ) {
setSwapInterval(sync ? 1 : 0);
}
public static void setVSyncEnabled(boolean sync) throws LWJGLException {
setSwapInterval(sync ? 1 : 0);
}
/**
@ -1178,9 +1159,7 @@ public final class Display {
* @return a String
*/
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
*/
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();
}
public void setSwapInterval(final int swap_interval) {
public void setSwapInterval(final int swap_interval) throws LWJGLException {
ContextGL.setSwapInterval(swap_interval);
}

View File

@ -62,10 +62,10 @@ interface DrawableLWJGL extends Drawable {
void checkGLError();
void setSwapInterval(int swap_interval);
void setSwapInterval(int swap_interval) throws LWJGLException;
void swapBuffers() throws LWJGLException;
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 {
try {
LinuxDisplay.lockAWT();
try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
try {
GLContext.loadOpenGLLibrary();
try {
@ -115,8 +114,6 @@ final class LinuxCanvasImplementation implements AWTCanvasImplementation {
} finally {
GLContext.unloadOpenGLLibrary();
}
} finally {
LinuxDisplay.unlockAWT();
}
}
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 {
public ByteBuffer create(PeerInfo peer_info, IntBuffer attribs, ByteBuffer shared_context_handle) throws LWJGLException {
LinuxDisplay.lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try {
return nCreate(peer_handle, attribs, shared_context_handle);
} finally {
peer_info.unlock();
}
} finally {
LinuxDisplay.unlockAWT();
}
}
@ -72,16 +69,13 @@ final class LinuxContextImplementation implements ContextImplementation {
throw new IllegalStateException("No context is current");
synchronized ( current_context ) {
PeerInfo current_peer_info = current_context.getPeerInfo();
LinuxDisplay.lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
try {
nSwapBuffers(peer_handle);
} finally {
current_peer_info.unlock();
}
} finally {
LinuxDisplay.unlockAWT();
}
}
}
@ -94,16 +88,13 @@ final class LinuxContextImplementation implements ContextImplementation {
throw new IllegalStateException("No context is current");
synchronized ( current_context ) {
PeerInfo current_peer_info = current_context.getPeerInfo();
LinuxDisplay.lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
ByteBuffer peer_handle = current_peer_info.lockAndGetHandle();
try {
nReleaseCurrentContext(peer_handle);
} finally {
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 {
LinuxDisplay.lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try {
nMakeCurrent(peer_handle, handle);
} finally {
peer_info.unlock();
}
} finally {
LinuxDisplay.unlockAWT();
}
}
private static native void nMakeCurrent(ByteBuffer peer_handle, ByteBuffer context_handle) throws LWJGLException;
public boolean isCurrent(ByteBuffer handle) throws LWJGLException {
LinuxDisplay.lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
boolean result = nIsCurrent(handle);
return result;
} finally {
LinuxDisplay.unlockAWT();
}
}
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();
if ( current_context == null )
@ -150,19 +136,13 @@ final class LinuxContextImplementation implements ContextImplementation {
PeerInfo peer_info = current_context.getPeerInfo();
synchronized ( current_context ) {
LinuxDisplay.lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try {
nSetSwapInterval(peer_handle, current_context.getHandle(), value);
} finally {
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);
public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
LinuxDisplay.lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = LinuxDisplay.awtLock()) {
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
try {
nDestroy(peer_handle, handle);
} finally {
peer_info.unlock();
}
} finally {
LinuxDisplay.unlockAWT();
}
}

View File

@ -178,8 +178,7 @@ final class LinuxDisplay implements DisplayImplementation {
};
private static ByteBuffer getCurrentGammaRamp() throws LWJGLException {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
if (isXF86VidModeSupported())
@ -189,8 +188,6 @@ final class LinuxDisplay implements DisplayImplementation {
} finally {
decDisplay();
}
} finally {
unlockAWT();
}
}
private static native ByteBuffer nGetCurrentGammaRamp(long display, int screen) throws LWJGLException;
@ -213,8 +210,7 @@ final class LinuxDisplay implements DisplayImplementation {
private static boolean isXrandrSupported() {
if (Display.getPrivilegedBoolean("LWJGL_DISABLE_XRANDR"))
return false;
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
return nIsXrandrSupported(getDisplay());
@ -224,15 +220,12 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) {
LWJGLUtil.log("Got exception while querying Xrandr support: " + e);
return false;
} finally {
unlockAWT();
}
}
private static native boolean nIsXrandrSupported(long display) throws LWJGLException;
private static boolean isXF86VidModeSupported() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
return nIsXF86VidModeSupported(getDisplay());
@ -242,8 +235,6 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) {
LWJGLUtil.log("Got exception while querying XF86VM support: " + e);
return false;
} finally {
unlockAWT();
}
}
private static native boolean nIsXF86VidModeSupported(long display) throws LWJGLException;
@ -251,8 +242,7 @@ final class LinuxDisplay implements DisplayImplementation {
private static boolean isNetWMFullscreenSupported() throws LWJGLException {
if (Display.getPrivilegedBoolean("LWJGL_DISABLE_NETWM"))
return false;
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
return nIsNetWMFullscreenSupported(getDisplay(), getDefaultScreen());
@ -262,32 +252,38 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) {
LWJGLUtil.log("Got exception while querying NetWM support: " + e);
return false;
} finally {
unlockAWT();
}
}
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
* Xlib calls with AWT Xlib calls. Fortunately, JAWT implements Lock()/Unlock() to
* do just that.
*/
static void lockAWT() {
static AWTLock awtLock() {
try {
nLockAWT();
} catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while locking AWT: " + e);
}
return AWTLock.INSTANCE;
}
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;
/**
@ -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 {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
if ( drawable instanceof DrawableGLES )
@ -527,8 +522,6 @@ final class LinuxDisplay implements DisplayImplementation {
decDisplay();
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;
@ -576,8 +569,7 @@ final class LinuxDisplay implements DisplayImplementation {
}
public void destroyWindow() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
if (parent != null) {
parent.removeFocusListener(focus_listener);
}
@ -594,19 +586,14 @@ final class LinuxDisplay implements DisplayImplementation {
if ( current_window_mode != WINDOWED )
Compiz.setLegacyFullscreenSupport(false);
} finally {
unlockAWT();
}
}
static native void nDestroyWindow(long display, long window);
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
switchDisplayModeOnTmpDisplay(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);
public void resetDisplayMode() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
if( current_displaymode_extension == XRANDR )
{
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@ -657,16 +643,13 @@ final class LinuxDisplay implements DisplayImplementation {
Compiz.setLegacyFullscreenSupport(false);
} catch (LWJGLException e) {
LWJGLUtil.log("Caught exception while resetting mode: " + e);
} finally {
unlockAWT();
}
}
public int getGammaRampLength() {
if (!isXF86VidModeSupported())
return 0;
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
try {
incDisplay();
try {
@ -681,8 +664,6 @@ final class LinuxDisplay implements DisplayImplementation {
LWJGLUtil.log("Failed to get gamma ramp length: " + e);
return 0;
}
} finally {
unlockAWT();
}
}
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 {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
setGammaRampOnTmpDisplay(native_gamma);
current_gamma = native_gamma;
} finally {
unlockAWT();
}
}
@ -727,8 +705,7 @@ final class LinuxDisplay implements DisplayImplementation {
}
public DisplayMode init() throws LWJGLException {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
Compiz.init();
delete_atom = internAtom("WM_DELETE_WINDOW", false);
@ -756,22 +733,17 @@ final class LinuxDisplay implements DisplayImplementation {
saved_gamma = getCurrentGammaRamp();
current_gamma = saved_gamma;
return saved_mode;
} finally {
unlockAWT();
}
}
private static DisplayMode getCurrentXRandrMode() throws LWJGLException {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
return nGetCurrentXRandrMode(getDisplay(), getDefaultScreen());
} finally {
decDisplay();
}
} finally {
unlockAWT();
}
}
@ -779,26 +751,20 @@ final class LinuxDisplay implements DisplayImplementation {
private static native DisplayMode nGetCurrentXRandrMode(long display, int screen) throws LWJGLException;
public void setTitle(String title) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
final ByteBuffer titleText = MemoryUtil.encodeUTF8(title);
nSetTitle(getDisplay(), getWindow(), MemoryUtil.getAddress(titleText), titleText.remaining() - 1);
} finally {
unlockAWT();
}
}
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 */
private void setClassHint(String wm_name, String wm_class) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
final ByteBuffer nameText = MemoryUtil.encodeUTF8(wm_name);
final ByteBuffer classText = MemoryUtil.encodeUTF8(wm_class);
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);
@ -916,28 +882,21 @@ final class LinuxDisplay implements DisplayImplementation {
}
public void update() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
processEvents();
checkInput();
} finally {
unlockAWT();
}
}
public void reshape(int x, int y, int width, int height) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
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);
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
if (current_displaymode_extension == XRANDR) {
// nGetAvailableDisplayModes cannot be trusted. Use it only for bitsPerPixel
@ -961,8 +920,6 @@ final class LinuxDisplay implements DisplayImplementation {
decDisplay();
}
}
} finally {
unlockAWT();
}
}
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 {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
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) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
mouse.poll(grab, coord_buffer, buttons);
} finally {
unlockAWT();
}
}
public void readMouse(ByteBuffer buffer) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
mouse.read(buffer);
} finally {
unlockAWT();
}
}
public void setCursorPosition(int x, int y) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
mouse.setCursorPosition(x, y);
} finally {
unlockAWT();
}
}
@ -1165,15 +1110,12 @@ final class LinuxDisplay implements DisplayImplementation {
}
public void grabMouse(boolean new_grab) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
if (new_grab != grab) {
grab = new_grab;
updateInputGrab();
mouse.changeGrabbed(grab, shouldWarpPointer());
}
} finally {
unlockAWT();
}
}
@ -1182,8 +1124,7 @@ final class LinuxDisplay implements DisplayImplementation {
}
public int getNativeCursorCapabilities() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
return nGetNativeCursorCapabilities(getDisplay());
@ -1192,25 +1133,19 @@ final class LinuxDisplay implements DisplayImplementation {
}
} catch (LWJGLException e) {
throw new RuntimeException(e);
} finally {
unlockAWT();
}
}
private static native int nGetNativeCursorCapabilities(long display) throws LWJGLException;
public void setNativeCursor(Object handle) throws LWJGLException {
current_cursor = getCursorHandle(handle);
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
updateCursor();
} finally {
unlockAWT();
}
}
public int getMinCursorSize() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
return nGetMinCursorSize(getDisplay(), getWindow());
@ -1220,15 +1155,12 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) {
LWJGLUtil.log("Exception occurred in getMinCursorSize: " + e);
return 0;
} finally {
unlockAWT();
}
}
private static native int nGetMinCursorSize(long display, long window);
public int getMaxCursorSize() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
return nGetMaxCursorSize(getDisplay(), getWindow());
@ -1238,47 +1170,33 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) {
LWJGLUtil.log("Exception occurred in getMaxCursorSize: " + e);
return 0;
} finally {
unlockAWT();
}
}
private static native int nGetMaxCursorSize(long display, long window);
/* Keyboard */
public void createKeyboard() throws LWJGLException {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
keyboard = new LinuxKeyboard(getDisplay(), getWindow());
} finally {
unlockAWT();
}
}
public void destroyKeyboard() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
keyboard.destroy(getDisplay());
keyboard = null;
} finally {
unlockAWT();
}
}
public void pollKeyboard(ByteBuffer keyDownBuffer) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
keyboard.poll(keyDownBuffer);
} finally {
unlockAWT();
}
}
public void readKeyboard(ByteBuffer buffer) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
keyboard.read(buffer);
} finally {
unlockAWT();
}
}
@ -1290,8 +1208,7 @@ final class LinuxDisplay implements DisplayImplementation {
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 {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
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();
throw e;
}
} finally {
unlockAWT();
}
}
@ -1310,19 +1225,15 @@ final class LinuxDisplay implements DisplayImplementation {
}
public void destroyCursor(Object cursorHandle) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
nDestroyCursor(getDisplay(), getCursorHandle(cursorHandle));
decDisplay();
} finally {
unlockAWT();
}
}
static native void nDestroyCursor(long display, long cursorHandle);
public int getPbufferCapabilities() {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
return nGetPbufferCapabilities(getDisplay(), getDefaultScreen());
@ -1332,8 +1243,6 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) {
LWJGLUtil.log("Exception occurred in getPbufferCapabilities: " + e);
return 0;
} finally {
unlockAWT();
}
}
private static native int nGetPbufferCapabilities(long display, int screen);
@ -1426,8 +1335,7 @@ final class LinuxDisplay implements DisplayImplementation {
* @return number of icons used.
*/
public int setIcon(ByteBuffer[] icons) {
lockAWT();
try {
try (LinuxDisplay.AWTLock _lock = awtLock()) {
incDisplay();
try {
// get icons as cardinal ARGB format
@ -1441,8 +1349,6 @@ final class LinuxDisplay implements DisplayImplementation {
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to set display icon: " + e);
return 0;
} finally {
unlockAWT();
}
}

View File

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

View File

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

View File

@ -35,6 +35,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Cursor;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@ -389,7 +390,11 @@ public class HWCursorTest {
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//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());
//set clear color to black
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

View File

@ -367,8 +367,12 @@ public class PbufferTest {
* Initializes OGL
*/
private void glInit() {
//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);
}
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);

View File

@ -376,8 +376,12 @@ public final class PbufferTest {
* Initializes OGL
*/
private void glInit() {
// 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);
}
// Create shared texture
IntBuffer buffer = BufferUtils.createIntBuffer(1);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -52,7 +52,7 @@ import javax.tools.Diagnostic;
*/
@SupportedAnnotationTypes({ "*" })
@SupportedSourceVersion(SourceVersion.RELEASE_8)
@SupportedOptions({ "binpath", "typemap", "generatechecks", "contextspecific" })
@SupportedOptions({ "binpath", "genpath", "typemap", "generatechecks", "nogeneratechecks", "contextspecific" })
public class GeneratorProcessor extends AbstractProcessor {
private static boolean first_round = true;
@ -66,11 +66,16 @@ public class GeneratorProcessor extends AbstractProcessor {
Map<String, String> options = processingEnv.getOptions();
String typemap_classname = options.get("typemap");
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");
if ( bin_path == null ) {
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 ) {
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());
for ( Iterator<TypeElement> it = ElementFilter.typesIn(roundEnv.getRootElements()).iterator(); it.hasNext(); ) {
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;
return true;

View File

@ -34,11 +34,18 @@ package org.lwjgl.util.generator;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.annotation.Annotation;
import java.nio.Buffer;
import java.nio.ByteBuffer;
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.List;
import javax.annotation.processing.ProcessingEnvironment;
@ -60,13 +67,15 @@ import javax.tools.StandardLocation;
public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
private final ProcessingEnvironment env;
private final String gen_path;
private final TypeMap type_map;
private final boolean generate_error_checks;
private final boolean context_specific;
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.gen_path = gen_path;
this.type_map = type_map;
this.generate_error_checks = generate_error_checks;
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);
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 {
@ -277,46 +284,92 @@ public class GeneratorVisitor extends ElementKindVisitor6<Void, Void> {
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
public Void visitTypeAsInterface(TypeElement e, Void p) {
final File input = new File("src/templates/" + e.getQualifiedName().toString().replace('.', '/') + ".java");
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;
}
//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);
}
// 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())) {
generateJavaSource(e, java_writer);
StringWriter java_writer = new StringWriter();
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 ) {
boolean noNative = true;
for ( final 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);
}
String qualified_interface_name = Utils.getQualifiedClassName(e);
final Path output = Path.of(this.gen_path + "/" + qualified_interface_name.replace('.', '/') + ".java");
String newStr = java_writer.toString();
try {
if (isFileExistingAndIdentical(output, newStr)) {
return DEFAULT_VALUE;
}
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) {
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 {