Compare commits

..

No commits in common. "master" and "lwjgl2.8.1" have entirely different histories.

405 changed files with 6715 additions and 23686 deletions

View file

@ -1,17 +0,0 @@
## WARNING
This is the repository of the original LWJGL, which is no longer actively maintained. Unless you have released a product that uses LWJGL 2.x, you should probably be looking at [LWJGL 3](https://github.com/LWJGL/lwjgl3).
If you decide to proceed, it is very likely that:
- LWJGL maintainers won't be able to address your issue. Your best hope is an external contribution, which happens very rarely.
- Your issue is not an issue in LWJGL 3.
- Your issue has already been fixed in LWJGL 3.
If it is impossible for you to migrate to LWJGL 3, make sure to:
- Describe your issue as clearly as possible.
- Include information about your system/environment.
- Include a minimal code sample that reproduces the issue.
In any case, feature requests will almost certainly be ignored. If you need new features, you're very welcome to open an issue in the LWJGL 3 repository.

22
.gitignore vendored
View file

@ -1,22 +0,0 @@
*.*~
.*.sw[a-p]
/.classpath
/.nbattrs
/.project
/bin
/dist
/doc/javadoc
/libs
/src/generated
/src/native/generated
/src/native/common/Debug
/src/native/common/Release
/src/native/windows/Debug
/src/native/windows/Release
/temp
/src/native/*/org_lwjgl_*.h
/src/native/*/*/org_lwjgl_*.h
/src/native/linux/org_lwjgl_opengl_Display.c
nbproject/project.xml
/nbproject/private/

View file

@ -1,24 +0,0 @@
[LEGACY] LWJGL - Lightweight Java Game Library
======
> **WARNING**
>
> This is the repository of the original LWJGL, which is no longer actively maintained. Unless you have released a product that uses LWJGL 2.x, you should probably be looking at [LWJGL 3](https://github.com/LWJGL/lwjgl3).
The Lightweight Java Game Library (LWJGL) is a solution aimed directly at professional and amateur Java programmers alike to enable commercial quality games to be written in Java.
LWJGL provides developers access to high performance crossplatform libraries such as OpenGL (Open Graphics Library), OpenCL (Open Computing Language) and OpenAL (Open Audio Library) allowing for state of the art 3D games and 3D sound.
Additionally LWJGL provides access to controllers such as Gamepads, Steering wheel and Joysticks.
All in a simple and straight forward API.
Website: [http://legacy.lwjgl.org](http://legacy.lwjgl.org)
Forum: [http://forum.lwjgl.org](http://forum.lwjgl.org)
Bugs/Suggestions: [https://github.com/LWJGL/lwjgl/issues](https://github.com/LWJGL/lwjgl/issues)
Compilation
-----------
LWJGL requires a JDK and Ant installed to compile, as well as your platforms native compiler to compile the JNI.
* ant generate-all
* ant compile
* ant compile_native

330
build.xml
View file

@ -7,7 +7,6 @@
<import file="platform_build/build-applet.xml"/>
<import file="platform_build/build-webstart.xml"/>
<import file="platform_build/build-maven.xml"/>
<import file="eclipse-update/org.lwjgl.build/build-updatesite.xml"/>
<!-- ================================================================== -->
<!-- Everything below this line is targets. -->
@ -32,8 +31,6 @@
<mkdir dir="${lwjgl.temp}/native" taskname="initialiazing temp/native folder" />
<mkdir dir="${lwjgl.temp}/native/windows" taskname="initialiazing temp/windows folder" />
<mkdir dir="${lwjgl.temp}/native/linux" taskname="initialiazing temp/linux folder" />
<mkdir dir="${lwjgl.temp}/native/freebsd" taskname="initialiazing temp/freebsd folder" />
<mkdir dir="${lwjgl.temp}/native/openbsd" taskname="initialiazing temp/openbsd folder" />
<mkdir dir="${lwjgl.temp}/native/macosx" taskname="initialiazing temp/macosx folder" />
<mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" />
</target>
@ -58,7 +55,7 @@
<!-- 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"/>
<echo message="Before running the release target, please manually compile all platforms and place required files in ${lwjgl.lib}/windows, ${lwjgl.lib}/linux 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.dist} folder will be deleted. Continue? "
validargs="yes,no"
@ -88,8 +85,8 @@
<antcall target="-createjars" />
<antcall target="-jars_NoDEP" />
<!-- <antcall target="javadoc" /> -->
<!-- <antcall target="applet-release" /> -->
<antcall target="javadoc" />
<antcall target="applet-release" />
<!-- copy resources to res folder -->
<copy todir="${lwjgl.temp}/res">
@ -97,15 +94,15 @@
</copy>
<!-- copy docs -->
<!-- <copy todir="${lwjgl.temp}/doc"> -->
<!-- <fileset dir="${lwjgl.docs}"> -->
<!-- <patternset refid="lwjgl-docs.fileset" /> -->
<!-- </fileset> -->
<!-- </copy> -->
<copy todir="${lwjgl.temp}/doc">
<fileset dir="${lwjgl.docs}">
<patternset refid="lwjgl-docs.fileset" />
</fileset>
</copy>
<!-- create distribution from files in libs/ and temp/ -->
<!-- <antcall target="-distribution_javadoc" /> -->
<!-- <antcall target="-distribution_source" /> -->
<antcall target="-distribution_javadoc" />
<antcall target="-distribution_source" />
<antcall target="-distribute" />
</target>
@ -159,11 +156,6 @@
<fileset refid="lwjgl_util_applet.fileset" />
<manifest>
<attribute name="Sealed" value="true"/>
<attribute name="Trusted-Library" value="true"/>
<attribute name="Permissions" value="all-permissions"/>
<attribute name="Codebase" value="*"/>
<attribute name="Caller-Allowable-Codebase" value="*"/>
<attribute name="Application-Library-Allowable-Codebase" value="*"/>
</manifest>
</jar>
@ -184,7 +176,7 @@
<!-- ================================================================== -->
<!-- Generate a list of the OpenGL extension classes -->
<!-- ================================================================== -->
<fileset id="opengl-template-fileset" dir="${lwjgl.src}/generated/org/lwjgl/opengl" includes="${opengl-template-pattern}"/>
<fileset id="opengl-template-fileset" dir="${lwjgl.src}/generated" includes="${opengl-template-pattern}"/>
<property name="opengl-template-files" refid="opengl-template-fileset"/>
<tempfile property="temp.file"/>
@ -194,7 +186,7 @@
<filterchain>
<tokenfilter delimoutput=",">
<stringtokenizer delims=";"/>
<replaceregex pattern="(.+)[.]java"
<replaceregex pattern="org\${file.separator}lwjgl\${file.separator}opengl\${file.separator}(.+)[.]java"
replace="org/lwjgl/opengl/\1.class"/>
</tokenfilter>
</filterchain>
@ -245,16 +237,6 @@
<patternset refid="lwjgl-linux.fileset" />
</fileset>
</copy>
<copy todir="${lwjgl.temp}/native/freebsd" failonerror="false">
<fileset dir="${lwjgl.lib}/freebsd">
<patternset refid="lwjgl-freebsd.fileset" />
</fileset>
</copy>
<copy todir="${lwjgl.temp}/native/openbsd" failonerror="false">
<fileset dir="${lwjgl.lib}/openbsd">
<patternset refid="lwjgl-openbsd.fileset" />
</fileset>
</copy>
<copy todir="${lwjgl.temp}/native/macosx">
<fileset dir="${lwjgl.lib}/macosx">
<patternset refid="lwjgl-macosx.fileset" />
@ -295,88 +277,79 @@
<!-- Generates the native headers from source files -->
<target name="headers" description="invokes javah on java classes" depends="compile">
<!-- <javah classpath="${lwjgl.bin}" 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> -->
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux" force="yes">
<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>
<!-- <javah classpath="${lwjgl.bin}" 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> -->
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/linux/opengl" force="yes">
<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>
<!-- <javah classpath="${lwjgl.bin}" 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> -->
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes">
<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>
<!-- <javah classpath="${lwjgl.bin}" 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> -->
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengl" force="yes">
<class name="org.lwjgl.opengl.WindowsPbufferPeerInfo"/>
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
<class name="org.lwjgl.opengl.WindowsContextImplementation"/>
</javah>
<!-- <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengles"> -->
<!-- <class name="org.lwjgl.opengl.WindowsPeerInfo"/> -->
<!-- </javah> -->
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows/opengles" force="yes">
<class name="org.lwjgl.opengl.WindowsPeerInfo"/>
</javah>
<echo>lwjgl.src.headers = ${lwjgl.src.headers}</echo>
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes">
<class name="org.lwjgl.MacOSXSysImplementation" />
<class name="org.lwjgl.opengl.MacOSXMouseEventQueue" />
<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" />
</javah>
<javac classpath="${lwjgl.bin}" srcdir="${lwjgl.src}" nativeheaderdir="${lwjgl.src.native}/macosx">
<compilerarg line="-h ${lwjgl.src.native}/macosx" />
<include name="java/org/lwjgl/MacOSXSysImplementation.java" />
<include name="java/org/lwjgl/opengl/MacOSXCanvasPeerInfo.java" />
<include name="java/org/lwjgl/opengl/MacOSXPeerInfo.java" />
<include name="java/org/lwjgl/opengl/MacOSXPbufferPeerInfo.java" />
<include name="java/org/lwjgl/opengl/MacOSXDisplay.java" />
<include name="java/org/lwjgl/opengl/MacOSXContextImplementation.java" />
<include name="java/org/lwjgl/opengl/MacOSXNativeKeyboard.java" />
<include name="java/org/lwjgl/opengl/MacOSXNativeMouse.java" />
<include name="java/org/lwjgl/opengl/MacOSXMouseEventQueue.java" />
</javac>
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes">
<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 classpath="${lwjgl.bin}" srcdir="${lwjgl.src}" nativeheaderdir="${lwjgl.src.headers}">
<compilerarg line="-h ${lwjgl.src.headers}" />
<include name="java/org/lwjgl/opengl/AWTSurfaceLock.java" />
<include name="java/org/lwjgl/DefaultSysImplementation.java" />
<include name="java/org/lwjgl/input/Cursor.java" />
<include name="java/org/lwjgl/input/Keyboard.java" />
<include name="java/org/lwjgl/input/Mouse.java" />
<include name="java/org/lwjgl/openal/AL.java" />
<include name="java/org/lwjgl/opencl/CL.java" />
<include name="java/org/lwjgl/opencl/CallbackUtil.java" />
<include name="java/org/lwjgl/BufferUtils.java" />
</javac>
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengl" force="yes">
<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 classpath="${lwjgl.bin}" srcdir="${lwjgl.src}" nativeheaderdir="${lwjgl.src.headers}/opengl">
<compilerarg line="-h ${lwjgl.src.headers}/opengl" />
<include name="java/org/lwjgl/opengl/GLContext.java"/>
<include name="java/org/lwjgl/opengl/Pbuffer.java"/>
<include name="java/org/lwjgl/opengl/CallbackUtil.java"/>
<include name="java/org/lwjgl/opengl/NVPresentVideoUtil.java"/>
<include name="java/org/lwjgl/opengl/NVVideoCaptureUtil.java"/>
</javac>
<javac classpath="${lwjgl.bin}" srcdir="${lwjgl.src}" nativeheaderdir="${lwjgl.src.headers}/opengles">
<compilerarg line="-h ${lwjgl.src.headers}/opengles" />
<include name="java/org/lwjgl/opengles/EGL.java"/>
<include name="java/org/lwjgl/opengles/EGLKHRFenceSync.java"/>
<include name="java/org/lwjgl/opengles/EGLKHRReusableSync.java"/>
<include name="java/org/lwjgl/opengles/EGLNVSync.java"/>
<include name="java/org/lwjgl/opengles/GLContext.java"/>
<include name="java/org/lwjgl/opengles/CallbackUtil.java"/>
</javac>
<javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}/opengles" force="yes">
<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"/>
</javah>
</target>
<target name="touch-version">
@ -386,60 +359,56 @@
</target>
<target name="version-mismatch">
<!-- <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/WindowsSysImplementation.java" property="lwjgl.java.windows.version"> -->
<!-- <filterchain> -->
<!-- <tokenfilter> -->
<!-- <containsstring contains="JNI_VERSION ="/> -->
<!-- </tokenfilter> -->
<!-- </filterchain> -->
<!-- </loadfile> -->
<!-- <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/LinuxSysImplementation.java" property="lwjgl.java.linux.version"> -->
<!-- <filterchain> -->
<!-- <tokenfilter> -->
<!-- <containsstring contains="JNI_VERSION ="/> -->
<!-- </tokenfilter> -->
<!-- </filterchain> -->
<!-- </loadfile> -->
<!-- <loadfile srcfile="${lwjgl.src}/java/org/lwjgl/MacOSXSysImplementation.java" property="lwjgl.java.macosx.version"> -->
<!-- <filterchain> -->
<!-- <tokenfilter> -->
<!-- <containsstring contains="JNI_VERSION ="/> -->
<!-- </tokenfilter> -->
<!-- </filterchain> -->
<!-- </loadfile> -->
<!-- <loadfile srcfile="${lwjgl.src.native}/windows/org_lwjgl_WindowsSysImplementation.h" property="lwjgl.native.windows.version"> -->
<!-- <filterchain> -->
<!-- <tokenfilter> -->
<!-- <containsstring contains="#define org_lwjgl_WindowsSysImplementation_JNI_VERSION"/> -->
<!-- </tokenfilter> -->
<!-- </filterchain> -->
<!-- </loadfile> -->
<!-- <loadfile srcfile="${lwjgl.src.native}/linux/org_lwjgl_LinuxSysImplementation.h" property="lwjgl.native.linux.version"> -->
<!-- <filterchain> -->
<!-- <tokenfilter> -->
<!-- <containsstring contains="#define org_lwjgl_LinuxSysImplementation_JNI_VERSION"/> -->
<!-- </tokenfilter> -->
<!-- </filterchain> -->
<!-- </loadfile> -->
<!-- <loadfile srcfile="${lwjgl.src.native}/macosx/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version"> -->
<!-- <filterchain> -->
<!-- <tokenfilter> -->
<!-- <containsstring contains="#define org_lwjgl_MacOSXSysImplementation_JNI_VERSION"/> -->
<!-- </tokenfilter> -->
<!-- </filterchain> -->
<!-- </loadfile> -->
<!-- <echo> -->
<!-- lwjgl.java.windows.version = ${lwjgl.java.windows.version} -->
<!-- lwjgl.native.windows.version = ${lwjgl.native.windows.version} -->
<!-- lwjgl.java.linux.version = ${lwjgl.java.linux.version} -->
<!-- lwjgl.native.linux.version = ${lwjgl.native.linux.version} -->
<!-- lwjgl.java.freebsd.version = ${lwjgl.java.linux.version} -->
<!-- lwjgl.native.freebsd.version = ${lwjgl.native.linux.version} -->
<!-- lwjgl.java.openbsd.version = ${lwjgl.java.linux.version} -->
<!-- lwjgl.native.openbsd.version = ${lwjgl.native.linux.version} -->
<!-- lwjgl.java.macosx.version = ${lwjgl.java.macosx.version} -->
<!-- lwjgl.native.macosx.version = ${lwjgl.native.macosx.version} -->
<!-- </echo> -->
<loadfile srcfile="${lwjgl.src}/java/org/lwjgl/WindowsSysImplementation.java" property="lwjgl.java.windows.version">
<filterchain>
<tokenfilter>
<containsstring contains="JNI_VERSION ="/>
</tokenfilter>
</filterchain>
</loadfile>
<loadfile srcfile="${lwjgl.src}/java/org/lwjgl/LinuxSysImplementation.java" property="lwjgl.java.linux.version">
<filterchain>
<tokenfilter>
<containsstring contains="JNI_VERSION ="/>
</tokenfilter>
</filterchain>
</loadfile>
<loadfile srcfile="${lwjgl.src}/java/org/lwjgl/MacOSXSysImplementation.java" property="lwjgl.java.macosx.version">
<filterchain>
<tokenfilter>
<containsstring contains="JNI_VERSION ="/>
</tokenfilter>
</filterchain>
</loadfile>
<loadfile srcfile="${lwjgl.src.native}/windows/org_lwjgl_WindowsSysImplementation.h" property="lwjgl.native.windows.version">
<filterchain>
<tokenfilter>
<containsstring contains="#define org_lwjgl_WindowsSysImplementation_JNI_VERSION"/>
</tokenfilter>
</filterchain>
</loadfile>
<loadfile srcfile="${lwjgl.src.native}/linux/org_lwjgl_LinuxSysImplementation.h" property="lwjgl.native.linux.version">
<filterchain>
<tokenfilter>
<containsstring contains="#define org_lwjgl_LinuxSysImplementation_JNI_VERSION"/>
</tokenfilter>
</filterchain>
</loadfile>
<loadfile srcfile="${lwjgl.src.native}/macosx/org_lwjgl_MacOSXSysImplementation.h" property="lwjgl.native.macosx.version">
<filterchain>
<tokenfilter>
<containsstring contains="#define org_lwjgl_MacOSXSysImplementation_JNI_VERSION"/>
</tokenfilter>
</filterchain>
</loadfile>
<echo>
lwjgl.java.windows.version = ${lwjgl.java.windows.version}
lwjgl.native.windows.version = ${lwjgl.native.windows.version}
lwjgl.java.linux.version = ${lwjgl.java.linux.version}
lwjgl.native.linux.version = ${lwjgl.native.linux.version}
lwjgl.java.macosx.version = ${lwjgl.java.macosx.version}
lwjgl.native.macosx.version = ${lwjgl.native.macosx.version}
</echo>
</target>
<macrodef name="version-check">
@ -468,7 +437,7 @@
<!-- Compiles the Java source code -->
<target name="compile" description="Compiles the java source code" depends="-initialize">
<javac debug="yes" destdir="${lwjgl.bin}" source="1.7" target="1.7" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar" taskname="core">
<javac debug="yes" destdir="${lwjgl.bin}" source="1.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar:${lwjgl.lib}/asm-debug-all.jar" taskname="core">
<!--<compilerarg value="-Xlint:unchecked"/>-->
<src path="${lwjgl.src}/java/"/>
<src path="${lwjgl.src}/generated/"/>
@ -481,8 +450,8 @@
<include name="org/lwjgl/util/**"/>
<exclude name="org/lwjgl/util/generator/**"/>
</javac>
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.7" target="1.7" taskname="test" />
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.7" target="1.7" taskname="examples" />
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/test/**" source="1.5" target="1.5" taskname="test" />
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/examples/**" source="1.5" target="1.5" taskname="examples" />
</target>
<target name="compile_native" depends="-initialize, headers, touch-version, version-mismatch" description="Compiles the native files">
@ -496,16 +465,6 @@
</condition>
<antcall target="-compile_native_linux" />
<condition property="lwjgl.platform.freebsd">
<os name="FreeBSD" />
</condition>
<antcall target="-compile_native_freebsd" />
<condition property="lwjgl.platform.openbsd">
<os name="OpenBSD" />
</condition>
<antcall target="-compile_native_openbsd" />
<condition property="lwjgl.platform.solaris">
<os name="SunOS" />
</condition>
@ -535,23 +494,6 @@
<!-- 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" inheritAll="false"/>
<copy todir="${lwjgl.lib}/freebsd">
<fileset dir="${lwjgl.bin}/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" inheritAll="false"/>
<copy todir="${lwjgl.lib}/openbsd">
<fileset dir="${lwjgl.bin}/lwjgl" includes="liblwjgl*.so"/>
</copy>
</target>
<!-- Compiles LWJGL on solaris platforms -->
<target name="-compile_native_solaris" if="lwjgl.platform.solaris">
<!-- Reusing the linux ant task, but copy the output to solaris -->
@ -565,8 +507,8 @@
<!-- Compiles LWJGL on Mac platforms -->
<target name="-compile_native_macosx" if="lwjgl.platform.macosx">
<ant antfile="platform_build/macosx_ant/build.xml" inheritAll="false"/>
<copy file="${lwjgl.bin}/lwjgl/liblwjgl.dylib" todir="${lwjgl.lib}/macosx"/>
<!-- <version-check platform="macosx"/> -->
<copy file="${lwjgl.bin}/lwjgl/liblwjgl.jnilib" todir="${lwjgl.lib}/macosx"/>
<version-check platform="macosx"/>
</target>
<target name="compile_native_es" depends="-initialize, headers, touch-version, version-mismatch" description="Compiles the native files">
@ -683,16 +625,16 @@
<bottom><![CDATA[<i>Copyright &#169; 2002-2009 lwjgl.org. All Rights Reserved.</i>]]></bottom>
</javadoc>
</target>
<!-- get and copy nightly binaries into libs folder -->
<target name="copy-nightly-binaries" depends="-initialize" description="Copies latest successful nightly binaries into appropriate libs folder">
<delete file="${lwjgl.temp}/lwjgl-${lwjgl.version}.zip" failonerror="false"/>
<get src="http://ci.newdawnsoftware.com/job/LWJGL-git-dist/lastBuild/artifact/dist/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}" verbose="true"/>
<get src="http://www.newdawnsoftware.com/jenkins/view/LWJGL/job/LWJGL/lastSuccessfulBuild/artifact/dist/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.temp}" verbose="true"/>
<unzip src="${lwjgl.temp}/lwjgl-${lwjgl.version}.zip" dest="${lwjgl.lib}" overwrite="true">
<patternset>
<include name="**/native/**/*lwjgl*"/>
</patternset>
<globmapper from="lwjgl-${lwjgl.version}/native/*" to="*"/>
<globmapper from="lwjgl-${lwjgl.version}/native/*" to="*"/>
</unzip>
</target>
</target>
</project>

View file

@ -22,7 +22,4 @@ org.lwjgl.opengl.Window.undecorated
Whether to create an undecorated window (no title bar)
org.lwjgl.input.Mouse.allowNegativeMouseCoords
Usually mouse is clamped to 0,0 - setting this to true will cause you to get negative values if dragging outside and below or left of window
org.lwjgl.opengl.Display.enableHighDPI
Enable high DPI mode where available
Usually mouse is clamped to 0,0 - setting this to true will cause you to get negative values if dragging outside and below or left of window

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="anttasks"/>
</classpath>

View file

@ -9,6 +9,5 @@ Import-Package: org.apache.tools.ant,
org.apache.tools.ant.types,
org.apache.tools.ant.types.selectors,
org.apache.tools.ant.util,
org.junit;version="4"
org.junit;version="4.8.1"
Bundle-Vendor: Lightweight Java Game Library Project
Require-Bundle: org.junit;bundle-version="4.8.1"

View file

@ -1,34 +1,3 @@
How to build the Eclipse update site
------------------------------------
Author: Jens von Pilgrim <developer@jevopi.de>
Building the Eclipse update site is fully integrated into the main LWJGL build script.
Here is how to build the update site:
Run main lwjgl ant script (LWJGL/build.xml) with target "eclipse-updatesite"
You will find the updatesite in
LWJGL/eclipse-update/org.lwjgl.build/build/plugins/org.lwjgl.updatesite
Note that there are two targets: eclipse-updatesite and
eclipse-updatesite-simple. The first one depends from the target "release",
defined in the main build file. However, if you are sure the relase target has
been called before, you may want to only create the update site without
building the release target again. In that case, you can all
eclipse-update-simple.
The update site build requires some Java classes to be precompiled. These classes
can be found in some zip archives in folder plugin-classes and anttasks.jar.
Building these classes requires Eclipse dependencies (in case of the
plugin-classes) or they define anttasks required to be present when running ant.
In order to build these classes, open all projects found in subfolder
LWJGL/eclipse-update in Eclipse: this way, all Eclipse classes will get
automatically compiled. Then run the ant script buildEclipseClasses.xml from
within Eclipse. Actually, this is rarely necessary as the archives are all
committed to the LWJGL SVN and will be present if you check out everything. You
only need to run that build if the Eclise plugin classes (or the anttasks) were
changed.
The build plugin is part of the LWJGL Eclipse plugins. The following plugins are
required:
@ -77,11 +46,35 @@ org.lwjgl.build -- THIS Plugin
This is the build script project. Although it is an Eclipse project, you can
simply run the build script with ant from command line. See later on.
Everything is created in LWJGL/eclipse-update/org.lwjgl.build/build.
Everything is created in org.lwjgl.build/build.
Here is how to build the update site:
1) Create a new folder in org.lwjgl.build/lwjgl-archives , use the version
number as folder name. E.g., for version 2.6 create a folder "2.6",
for version 2.6.1 "2.6.1" and so on.
2) Copy the lwjgl, lwjgl-docs and lwjgl-source zips into that folder. E.g.,
for version 2.6, this folder must contain the following files:
org.lwjgl.build/lwjgl-archives
+ 2.6
- lwjgl-2.6.zip
- lwjgl-docs-2.6.zip
- lwjgl-source-2.6.zip
3) In order to run the build script, change to folder org.lwjgl.build and run
ant with a parameter indicating the appropriate LWJGL version, e.g.
ant -Dversion=2.6 dist
You will find the updatesite in
org.lwjgl.build/build/plugins/org.lwjgl.updatesite
You may note that the jars are all signed. I have added a temporary keystore
with a dummy alias. In order to use your key, simply edit the properties
(line 11-14) in the build script. If you do not want to store the password in
the build script, simply define it via "-Dstorepass=****" in the command line.
Some additional remarks:
- The version number is automatically "normalized" to Eclipse standards,
that is 2.6 will become 2.6.0 with the current date and time added.
that is 2.6 will become 2.6.0. You do not have to rename the initial archives,
you can use 2.6. Or 2.6.1 ;-)
- The lwjgl-debug.jar is not added to the org.lwjgl plugin, as I do not know
how to select one or the other. But I have not further investigated in
that direction.
@ -92,7 +85,4 @@ Some additional remarks:
to the Eclipse P2 system, which caches a lot of things. Simply uninstalling
a plugin does not remove the plugins from the Eclipse installation. When
the very same version is re-installed, instead of loading new files from the
update site these pre-installed versions are reused! Since the date and time
is added to the plugin version number, this should cause no problems.
- default values for keystore, alias and passphrase are the same as in
lwjgl-applet
update site these pre-installed versions are reused!

View file

@ -1,500 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Called from main build script.
Expects
lwjgl.version
to be set.
(C) 2011 LWJGL-Project
Author: Jens von Pilgrim, developer@jevopi.de
-->
<project default="eclipse-updatesite" basedir="." name="eclipse.antscript" xmlns:ant4eclipse="antlib:org.ant4eclipse" xmlns:antcontrib="antlib:net.sf.antcontrib">
<dirname property="eclipse.antscript.basedir" file="${ant.file.eclipse.antscript}" />
<property name="keystore" value="applet/lwjglkeystore" />
<property name="alias" value="lwjgl" />
<property name="password" value="123456" />
<property name="eclipse.updatesite" value="http://www.lwjgl.org/update/" />
<property name="eclipse.bundle.vendor" value="lwjgl.org" />
<taskdef name="packagelist" classname="org.lwjgl.ant.PackageList">
<classpath>
<pathelement location="${eclipse.antscript.basedir}/anttasks.jar" />
</classpath>
</taskdef>
<taskdef name="normalizeversion" classname="org.lwjgl.ant.NormalizeVersion">
<classpath>
<pathelement location="${eclipse.antscript.basedir}/anttasks.jar" />
</classpath>
</taskdef>
<taskdef name="publishBundlesAndFeatures" classname="org.lwjgl.ant.StandalonePublisher">
<classpath>
<pathelement location="${eclipse.antscript.basedir}/anttasks.jar" />
</classpath>
</taskdef>
<!-- properties imported from build-definitions.xml:
<property name="lwjgl.temp" location="temp" />
<property name="lwjgl.src" location="src" />
<property name="lwjgl.version" value="2.8.3" />
-->
<!-- where to build the update site and temporary build files -->
<property name="eclipse.build.path" value="${eclipse.antscript.basedir}/build" />
<property name="eclipse.build.temp" value="${eclipse.build.path}/temp" />
<property name="eclipse.build.plugins" value="${eclipse.build.path}/plugins" />
<property name="eclipse.prebuild-plugin-classes" value="${eclipse.antscript.basedir}/plugin-classes" />
<!-- from where to retrieve LWJGL files -->
<property name="eclipse.skeletons.dir" value="${eclipse.antscript.basedir}/.." />
<!-- base: ${lwjgl.temp} : <patternset refid="lwjgl_applet"/>
doc: basedir="${lwjgl.docs}" includes="javadoc/**"
source: refid="lwjgl.source.fileset"
-->
<property name="NL" value="&#10;" />
<target name="eclipse-updatesite">
<mkdir dir="${lwjgl.temp}"/>
<unzip dest="${lwjgl.temp}/eclipse" src="${lwjgl.dist}/lwjgl-${lwjgl.version}.zip" />
<antcall target="eclipse-updatesite-simple" />
</target>
<target name="eclipse-updatesite-simple">
<normalizeversion version="${lwjgl.version}" property="eclipse.normversion" addDateQualifier="yes" />
<echo>Building plugins for version ${lwjgl.version}, normalized version ${eclipse.normversion}</echo>
<mkdir dir="${eclipse.build.temp}" />
<!-- *******************************************************************
*
* Assemble plugins
*
******************************************************************** -->
<!-- Main plugin: lwjgl.org -->
<!-- Copy plugin skeletons -->
<mkdir dir="${eclipse.build.plugins}" />
<copy todir="${eclipse.build.plugins}/org.lwjgl">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl" casesensitive="yes">
<exclude name="**/src/**" />
<exclude name="**/*.jar" />
<!-- do not copy jars used for development -->
<exclude name="**/build/**" />
<exclude name="**/build.properties" />
<!-- do not copy development settings -->
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
<!-- do not copy native libraries -->
<exclude name="**/native/**" />
</fileset>
</copy>
<!-- Copy LWJGL native files and classes -->
<copy todir="${eclipse.build.plugins}/org.lwjgl">
<fileset dir="${lwjgl.temp}/eclipse/lwjgl-${lwjgl.version}/">
<patternset refid="lwjgl_base"/>
</fileset>
</copy>
<move todir="${eclipse.build.plugins}/org.lwjgl">
<fileset dir="${eclipse.build.plugins}/org.lwjgl/jar">
<include name="**" />
<exclude name="lwjgl-debug.jar" />
</fileset>
</move>
<delete dir="${eclipse.build.plugins}/org.lwjgl/jar" />
<!-- unzip Eclipse dependent classes,
have to be previously built by buildEclipseClasses.xml, but
are also contained in SVN
-->
<unzip dest="${eclipse.build.plugins}/org.lwjgl" src="${eclipse.prebuild-plugin-classes}/org.lwjgl.zip" />
<!-- Sources plugin: lwjgl.org.source -->
<!-- Copy plugin skeletons -->
<copy todir="${eclipse.build.plugins}/org.lwjgl.source">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.source" casesensitive="yes">
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<!-- Create zip files containing the source -->
<property name="eclipse.org.lwjgl.src.dir" value="${eclipse.build.plugins}/org.lwjgl.source/src/org.lwjgl_${eclipse.normversion}" />
<mkdir dir="${eclipse.org.lwjgl.src.dir}" />
<!-- Build src zips for plugin org.lwjgl -->
<!-- lwjgl sources (only Java sources) -->
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjglsrc.zip">
<fileset dir="${lwjgl.src}/generated" />
<fileset dir="${lwjgl.src}/java">
<exclude name="org/lwjgl/util/**" />
</fileset>
</zip>
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_utilsrc.zip">
<fileset dir="${lwjgl.src}/java">
<include name="org/lwjgl/util/**" />
<exclude name="org/lwjgl/util/applet/**" />
</fileset>
</zip>
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_util_applet.zip">
<fileset dir="${lwjgl.src}/java">
<include name="org/lwjgl/util/applet/**" />
</fileset>
</zip>
<!-- and the Eclipse related sources -->
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_eclipse.zip">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl/src/java" casesensitive="yes">
<include name="org/lwjgl/**" />
</fileset>
</zip>
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_tools.zip">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.tools/src/java" casesensitive="yes">
<include name="org/lwjgl/**" />
</fileset>
</zip>
<zip destfile="${eclipse.org.lwjgl.src.dir}/lwjgl_info.zip">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.info/src/java" casesensitive="yes">
<include name="org/lwjgl/**" />
</fileset>
</zip>
<!-- Documentation plugin: lwjgl.org.doc -->
<!-- Copy plugin skeletons including Eclipse documentation-->
<copy todir="${eclipse.build.plugins}/org.lwjgl.doc">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.doc" casesensitive="yes">
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<copy todir="${eclipse.build.plugins}/org.lwjgl.doc">
<fileset dir="${lwjgl.docs}">
<exclude name="javadoc/**" />
</fileset>
</copy>
<!-- create JavaDoc archive -->
<zip destfile="${eclipse.build.plugins}/org.lwjgl.doc/doc.zip" basedir="${lwjgl.docs}" includes="javadoc/**" />
<!-- Information view plugin: org.lwjgl.info -->
<copy todir="${eclipse.build.plugins}/org.lwjgl.info">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.info" casesensitive="yes">
<exclude name="**/src/**" />
<exclude name="**/build/**" />
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<!-- unzip Eclipse dependent classes,
have to be previously built by buildEclipseClasses.xml, but
are also contained in SVN
-->
<unzip dest="${eclipse.build.plugins}/org.lwjgl.info" src="${eclipse.prebuild-plugin-classes}/org.lwjgl.info.zip" />
<!-- Tools plugin: org.lwjgl.tools -->
<copy todir="${eclipse.build.plugins}/org.lwjgl.tools">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.tools" casesensitive="yes">
<exclude name="**/src/**" />
<exclude name="**/build/**" />
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<!-- unzip Eclipse dependent classes,
have to be previously built by buildEclipseClasses.xml, but
are also contained in SVN
-->
<unzip dest="${eclipse.build.plugins}/org.lwjgl.tools" src="${eclipse.prebuild-plugin-classes}/org.lwjgl.tools.zip" />
<!-- Feature -->
<copy todir="${eclipse.build.plugins}/org.lwjgl.feature">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.feature" casesensitive="yes">
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
<exclude name="**/*.template" />
</fileset>
</copy>
<!-- Update Site -->
<copy todir="${eclipse.build.plugins}/org.lwjgl.updatesite">
<fileset dir="${eclipse.skeletons.dir}/org.lwjgl.updatesite" casesensitive="yes">
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
<exclude name="**/*.template" />
</fileset>
</copy>
<!-- *******************************************************************
*
* Build manifest files
*
******************************************************************** -->
<!-- Calculate package export and bundle class paths -->
<packagelist property="eclipse.bundle.export-package" pathsep=",${NL} ">
<fileset dir="${lwjgl.temp}/eclipse/lwjgl-${lwjgl.version}/jar">
<exclude name="**/lwjgl-debug.jar" />
</fileset>
<patternset>
<exclude name="**/test/**" />
<exclude name="**/examples/**" />
</patternset>
</packagelist>
<pathconvert property="eclipse.bundle.classpath.jars" pathsep=",${NL} ">
<map from="${lwjgl.temp}/eclipse/lwjgl-${lwjgl.version}/jar/" to="" />
<fileset dir="${lwjgl.temp}/eclipse/lwjgl-${lwjgl.version}/jar">
<exclude name="**/lwjgl-debug.jar" />
<exclude name="**/lwjgl_test.jar" />
</fileset>
</pathconvert>
<!-- *******************************************************************
*
* org.lwjgl
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<echo file="${eclipse.build.plugins}/org.lwjgl/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LWJGL Lightweight Java Game Library
Bundle-SymbolicName: org.lwjgl
Bundle-Version: ${eclipse.normversion}
Bundle-Vendor: ${eclipse.bundle.vendor}
Bundle-Activator: org.lwjgl.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Export-Package: org.lwjgl.eclipse,${NL} ${eclipse.bundle.export-package}
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .,${NL} ${eclipse.bundle.classpath.jars}
</echo>
<!-- *******************************************************************
*
* org.lwjgl.doc
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<echo file="${eclipse.build.plugins}/org.lwjgl.doc/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-Vendor: ${eclipse.bundle.vendor}
Bundle-Version: ${eclipse.normversion}
Bundle-SymbolicName: org.lwjgl.doc;singleton:=true
Bundle-Localization: plugin
Require-Bundle: org.eclipse.help;bundle-version="3.2.0"
Eclipse-LazyStart: true
</echo>
<!-- *******************************************************************
*
* org.lwjgl.source
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<!-- Build manfest -->
<!-- not using manifest task, since manifest wraps at the wrong positions -->
<echo file="${eclipse.build.plugins}/org.lwjgl.source/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LWJGL Sources
Bundle-Vendor: ${eclipse.bundle.vendor}
Bundle-Version: ${eclipse.normversion}
Bundle-SymbolicName: org.lwjgl.source;singleton:=true
Bundle-Localization: plugin
</echo>
<!-- *******************************************************************
*
* org.lwjgl.info
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<echo file="${eclipse.build.plugins}/org.lwjgl.info/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LWJGL Test and Info View
Bundle-Vendor: ${eclipse.bundle.vendor}
Bundle-Version: ${eclipse.normversion}
Bundle-SymbolicName: org.lwjgl.info;singleton:=true
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.views,
org.eclipse.core.resources,
org.lwjgl
Bundle-RequiredExecutionEnvironment: J2SE-1.5
</echo>
<!-- Files are already in place -->
<!-- *******************************************************************
*
* org.lwjgl.tools
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<!-- Build plugin org.lwjgl.tools -->
<echo file="${eclipse.build.plugins}/org.lwjgl.tools/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LWJGL Tools Plug-in
Bundle-SymbolicName: org.lwjgl.tools;singleton:=true
Bundle-Version: ${eclipse.normversion}
Bundle-Vendor: ${eclipse.bundle.vendor}
Bundle-Activator: org.lwjgl.tools.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.4.0",
org.eclipse.jdt.core;bundle-version="3.4.0",
org.eclipse.jdt.ui;bundle-version="3.4.0",
org.lwjgl;bundle-version="${eclipse.normversion}",
org.eclipse.jdt.launching;bundle-version="3.4.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
</echo>
<!-- Files are already in place -->
<!-- Create features -->
<!-- *******************************************************************
*
* org.lwjgl.feature
*
******************************************************************** -->
<!-- Build org.lwjgl.feature -->
<copy file="${eclipse.skeletons.dir}/org.lwjgl.feature/feature.xml.template" tofile="${eclipse.build.plugins}/org.lwjgl.feature/feature.xml" encoding="UTF-8" overwrite="true">
<filterset>
<filter token="VERSION" value="${eclipse.normversion}" />
<filter token="PROVIDERNAME" value="${eclipse.bundle.vendor}" />
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
</filterset>
</copy>
<!-- *******************************************************************
*
* org.lwjgl.feature.sdk
*
******************************************************************** -->
<!-- Build org.lwjgl.feature -->
<copy file="${eclipse.skeletons.dir}/org.lwjgl.feature.sdk/feature.xml.template" tofile="${eclipse.build.plugins}/org.lwjgl.feature.sdk/feature.xml" encoding="UTF-8" overwrite="true">
<filterset>
<filter token="VERSION" value="${eclipse.normversion}" />
<filter token="PROVIDERNAME" value="${eclipse.bundle.vendor}" />
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
</filterset>
</copy>
<!-- *******************************************************************
*
* Build update site, i.e. zip all plugins and feature with version
* number to appropriate place
*
******************************************************************** -->
<!-- Build update site -->
<copy file="${eclipse.skeletons.dir}/org.lwjgl.updatesite/site.xml.template" tofile="${eclipse.build.plugins}/org.lwjgl.updatesite/site.xml" encoding="UTF-8" overwrite="true">
<filterset>
<filter token="VERSION" value="${eclipse.normversion}" />
<filter token="PROVIDERNAME" value="${eclipse.bundle.vendor}" />
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
</filterset>
</copy>
<mkdir dir="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins" />
<mkdir dir="${eclipse.build.plugins}/org.lwjgl.updatesite/features" />
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl/META-INF/MANIFEST.MF">
<fileset dir="${eclipse.build.plugins}/org.lwjgl" casesensitive="yes" />
</jar>
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.doc_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl.doc/META-INF/MANIFEST.MF">
<fileset dir="${eclipse.build.plugins}/org.lwjgl.doc" casesensitive="yes" />
</jar>
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.source_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl.source/META-INF/MANIFEST.MF">
<fileset dir="${eclipse.build.plugins}/org.lwjgl.source" casesensitive="yes" />
</jar>
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.info_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl.info/META-INF/MANIFEST.MF">
<fileset dir="${eclipse.build.plugins}/org.lwjgl.info" casesensitive="yes" />
</jar>
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.tools_${eclipse.normversion}.jar" manifest="${eclipse.build.plugins}/org.lwjgl.tools/META-INF/MANIFEST.MF">
<fileset dir="${eclipse.build.plugins}/org.lwjgl.tools" casesensitive="yes" />
</jar>
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/features/org.lwjgl_${eclipse.normversion}.jar">
<fileset dir="${eclipse.build.plugins}/org.lwjgl.feature" casesensitive="yes" />
</jar>
<jar destfile="${eclipse.build.plugins}/org.lwjgl.updatesite/features/org.lwjgl.sdk_${eclipse.normversion}.jar">
<fileset dir="${eclipse.build.plugins}/org.lwjgl.feature.sdk" casesensitive="yes" />
</jar>
<!-- *******************************************************************
*
* Sign plugins and feature
*
******************************************************************** -->
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/features/org.lwjgl_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/features/org.lwjgl.sdk_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.doc_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.source_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.info_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
<signjar jar="${eclipse.build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.tools_${eclipse.normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${password}" />
<!-- *******************************************************************
*
* Publish plugins and feature
* content.xml/jar and artifacts.xml/jar, required for some newer featues
* and tools such as Eclipse Tycho.
*
******************************************************************** -->
<publishBundlesAndFeatures compressed="true"
updatesitefolder="${eclipse.build.plugins}/org.lwjgl.updatesite"
repositoryname="lwjgl.org"
repositoryuri="${eclipse.updatesite}" />
<echo>Created Eclipse update site: ${eclipse.build.plugins}/org.lwjgl.updatesite</echo>
</target>
<target name="eclipse-clean">
<delete dir="${eclipse.build.path}" />
</target>
<target name="eclipse-help">
<echo>This plugin is to be called from main LWJGL build.xml file.</echo>
<echo>It creates the update site, the result will be found in</echo>
<echo>${eclipse.build.plugins}/org.lwjgl.updatesite</echo>
<echo>For more information, read READ.ME</echo>
</target>
</project>

View file

@ -0,0 +1,444 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Call with
ant -Dversion=1.9.1 dist
(C) 2011 LWJGL-Project
Author: Jens von Pilgrim, developer@jevopi.de
-->
<project default="help" basedir="." name="" xmlns:ant4eclipse="antlib:org.ant4eclipse" xmlns:antcontrib="antlib:net.sf.antcontrib">
<property name="keystore" value="teststore" />
<property name="alias" value="tester" />
<property name="storepass" value="tester" />
<property name="keypass" value="${storepass}" />
<property name="eclipse.updatesite" value="http://www.lwjgl.org/update/" />
<property name="bundle.vendor" value="lwjgl.org" />
<taskdef name="packagelist" classname="org.lwjgl.ant.PackageList">
<classpath>
<pathelement location="./anttasks" />
</classpath>
</taskdef>
<taskdef name="normalizeversion" classname="org.lwjgl.ant.NormalizeVersion">
<classpath>
<pathelement location="./anttasks" />
</classpath>
</taskdef>
<property name="version" value="unknown" />
<property name="archives.dir" value="lwjgl-archives/${version}" />
<property name="skeletons.dir" value=".." />
<property name="build.path" value="build" />
<property name="build.temp" value="${build.path}/temp" />
<property name="build.plugins" value="${build.path}/plugins" />
<property name="lwjgl.zip" value="lwjgl-${version}.zip" />
<property name="lwjgl_docs.zip" value="lwjgl-docs-${version}.zip" />
<property name="lwjgl_source.zip" value="lwjgl-source-${version}.zip" />
<property name="lwjgl.dir" value="${build.temp}/lwjgl-${version}" />
<property name="lwjgl_docs.dir" value="${build.temp}/javadoc" />
<property name="lwjgl_source.dir" value="${build.temp}/src" />
<property name="NL" value="&#10;" />
<!--
<property name="" value="" />
-->
<target name="init">
<normalizeversion version="${version}" property="normversion" />
<echo>Building plugins for version ${version}, normalized version ${normversion}</echo>
</target>
<target name="dist" depends="init">
<mkdir dir="${build.temp}" />
<!-- *******************************************************************
*
* Copy original plugins to build folder. Copy source to source plugin
* only, move classes into place.
*
******************************************************************** -->
<mkdir dir="${build.plugins}" />
<copy todir="${build.plugins}/org.lwjgl">
<fileset dir="${skeletons.dir}/org.lwjgl" casesensitive="yes">
<exclude name="**/src/**" />
<exclude name="**/*.jar" />
<!-- do not copy jars used for development -->
<exclude name="**/build/**" />
<exclude name="**/build.properties" />
<!-- do not copy development settings -->
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl">
<fileset dir="${skeletons.dir}/org.lwjgl/build/classes" casesensitive="yes">
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl.source">
<fileset dir="${skeletons.dir}/org.lwjgl.source" casesensitive="yes">
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl.doc">
<fileset dir="${skeletons.dir}/org.lwjgl.doc" casesensitive="yes">
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl.info">
<fileset dir="${skeletons.dir}/org.lwjgl.info" casesensitive="yes">
<exclude name="**/src/**" />
<exclude name="**/build/**" />
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl.info">
<fileset dir="${skeletons.dir}/org.lwjgl.info/build/classes" casesensitive="yes">
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl.tools">
<fileset dir="${skeletons.dir}/org.lwjgl.tools" casesensitive="yes">
<exclude name="**/src/**" />
<exclude name="**/build/**" />
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl.tools">
<fileset dir="${skeletons.dir}/org.lwjgl.tools/build/classes" casesensitive="yes">
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl.feature">
<fileset dir="${skeletons.dir}/org.lwjgl.feature" casesensitive="yes">
<exclude name="**/build.properties" />
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
<exclude name="**/*.template" />
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl.updatesite">
<fileset dir="${skeletons.dir}/org.lwjgl.updatesite" casesensitive="yes">
<exclude name="**/.settings/**" />
<exclude name="**/.classpath" />
<exclude name="**/.project" />
<exclude name="**/*.template" />
</fileset>
</copy>
<!-- *******************************************************************
*
* Unzip archives and move content into approriate plugins
*
******************************************************************** -->
<unzip src="${archives.dir}/${lwjgl.zip}" dest="${build.temp}" />
<copy todir="${build.plugins}/org.lwjgl/native">
<fileset dir="${lwjgl.dir}/native" />
</copy>
<copy todir="${build.plugins}/org.lwjgl/">
<fileset dir="${lwjgl.dir}/jar">
<exclude name="**/lwjgl-debug.jar" />
</fileset>
</copy>
<copy todir="${build.plugins}/org.lwjgl/doc">
<fileset dir="${lwjgl.dir}/doc" />
</copy>
<packagelist property="bundle.export-package" pathsep=",${NL} ">
<fileset dir="${lwjgl.dir}/jar">
<exclude name="**/lwjgl-debug.jar" />
</fileset>
<patternset>
<exclude name="**/test/**" />
<exclude name="**/examples/**" />
</patternset>
</packagelist>
<pathconvert property="bundle.classpath.jars" pathsep=",${NL} ">
<map from="${basedir}/${lwjgl.dir}/jar/" to="" />
<fileset dir="${lwjgl.dir}/jar">
<exclude name="**/lwjgl-debug.jar" />
<exclude name="**/lwjgl_test.jar" />
</fileset>
</pathconvert>
<!-- *******************************************************************
*
* Build plugins
*
******************************************************************** -->
<!-- *******************************************************************
*
* org.lwjgl
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<echo file="${build.plugins}/org.lwjgl/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LWJGL Lightweight Java Game Library
Bundle-SymbolicName: org.lwjgl
Bundle-Version: ${normversion}
Bundle-Vendor: ${bundle.vendor}
Bundle-Activator: org.lwjgl.eclipse.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Export-Package: org.lwjgl.eclipse,${NL} ${bundle.export-package}
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .,${NL} ${bundle.classpath.jars}
</echo>
<!-- *******************************************************************
*
* org.lwjgl.doc
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<copy file="${archives.dir}/${lwjgl_docs.zip}" tofile="${build.plugins}/org.lwjgl.doc/doc.zip" />
<echo file="${build.plugins}/org.lwjgl.doc/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-Vendor: ${bundle.vendor}
Bundle-Version: ${normversion}
Bundle-SymbolicName: org.lwjgl.doc;singleton:=true
Bundle-Localization: plugin
Require-Bundle: org.eclipse.help;bundle-version="3.2.0"
Eclipse-LazyStart: true
</echo>
<!-- *******************************************************************
*
* org.lwjgl.source
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<unzip src="${archives.dir}/${lwjgl_source.zip}" dest="${build.temp}" />
<!-- Build src zips for plugin org.lwjgl -->
<property name="org.lwjgl.src.dir" value="${build.plugins}/org.lwjgl.source/src/org.lwjgl_${normversion}" />
<mkdir dir="${org.lwjgl.src.dir}" />
<zip destfile="${org.lwjgl.src.dir}/lwjglsrc.zip">
<fileset dir="${lwjgl_source.dir}/generated" />
<fileset dir="${lwjgl_source.dir}/java">
<exclude name="org/lwjgl/util/**" />
</fileset>
</zip>
<zip destfile="${org.lwjgl.src.dir}/lwjgl_utilsrc.zip">
<fileset dir="${lwjgl_source.dir}/java">
<include name="org/lwjgl/util/**" />
<exclude name="org/lwjgl/util/applet/**" />
</fileset>
</zip>
<!--
<zip destfile="${org.lwjgl.src.dir}/lwjgl_util_applet.zip">
<fileset dir="${lwjgl_source.dir}/java">
<include name="org/lwjgl/util/applet/**" />
</fileset>
</zip>
-->
<zip destfile="${org.lwjgl.src.dir}/lwjgl_eclipse.zip">
<fileset dir="${skeletons.dir}/org.lwjgl/src/java" casesensitive="yes">
<include name="org/lwjgl/**" />
</fileset>
</zip>
<zip destfile="${org.lwjgl.src.dir}/lwjgl_tools.zip">
<fileset dir="${skeletons.dir}/org.lwjgl.tools/src/java" casesensitive="yes">
<include name="org/lwjgl/**" />
</fileset>
</zip>
<zip destfile="${org.lwjgl.src.dir}/lwjgl_info.zip">
<fileset dir="${skeletons.dir}/org.lwjgl.info/src/java" casesensitive="yes">
<include name="org/lwjgl/**" />
</fileset>
</zip>
<!-- Build manfest -->
<!-- not using manifest task, since manifest wraps at the wrong positions -->
<echo file="${build.plugins}/org.lwjgl.source/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LWJGL Sources
Bundle-Vendor: ${bundle.vendor}
Bundle-Version: ${normversion}
Bundle-SymbolicName: org.lwjgl.source;singleton:=true
Bundle-Localization: plugin
</echo>
<!-- *******************************************************************
*
* org.lwjgl.info
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<echo file="${build.plugins}/org.lwjgl.info/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LWJGL Test and Info View
Bundle-Vendor: ${bundle.vendor}
Bundle-Version: ${normversion}
Bundle-SymbolicName: org.lwjgl.info;singleton:=true
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.ui.views,
org.eclipse.core.resources,
org.lwjgl
Bundle-RequiredExecutionEnvironment: J2SE-1.5
</echo>
<!-- Files are already in place -->
<!-- *******************************************************************
*
* org.lwjgl.tools
*
* Build manifest files, not using manifest task, since manifest wraps
* at the wrong positions (at least ant 1.7)
*
******************************************************************** -->
<!-- Build plugin org.lwjgl.tools -->
<echo file="${build.plugins}/org.lwjgl.tools/META-INF/MANIFEST.MF" encoding="UTF-8">Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: LWJGL Tools Plug-in
Bundle-SymbolicName: org.lwjgl.tools;singleton:=true
Bundle-Version: ${normversion}
Bundle-Vendor: ${bundle.vendor}
Bundle-Activator: org.lwjgl.tools.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.4.0",
org.eclipse.jdt.core;bundle-version="3.4.0",
org.eclipse.jdt.ui;bundle-version="3.4.0",
org.lwjgl;bundle-version="${normversion}",
org.eclipse.jdt.launching;bundle-version="3.4.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
</echo>
<!-- Files are already in place -->
<!-- *******************************************************************
*
* org.lwjgl.feature
*
******************************************************************** -->
<!-- Build org.lwjgl.feature -->
<copy file="${skeletons.dir}/org.lwjgl.feature/feature.xml.template" tofile="${build.plugins}/org.lwjgl.feature/feature.xml" encoding="UTF-8" overwrite="true">
<filterset>
<filter token="VERSION" value="${normversion}" />
<filter token="PROVIDERNAME" value="${bundle.vendor}" />
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
</filterset>
</copy>
<!-- *******************************************************************
*
* org.lwjgl.feature.sdk
*
*
******************************************************************** -->
<!-- Build org.lwjgl.feature -->
<copy file="${skeletons.dir}/org.lwjgl.feature.sdk/feature.xml.template" tofile="${build.plugins}/org.lwjgl.feature.sdk/feature.xml" encoding="UTF-8" overwrite="true">
<filterset>
<filter token="VERSION" value="${normversion}" />
<filter token="PROVIDERNAME" value="${bundle.vendor}" />
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
</filterset>
</copy>
<!-- *******************************************************************
*
* Build update site, i.e. zip all plugins and feature with version
* number to appropriate place
*
******************************************************************** -->
<!-- Build update site -->
<copy file="${skeletons.dir}/org.lwjgl.updatesite/site.xml.template" tofile="${build.plugins}/org.lwjgl.updatesite/site.xml" encoding="UTF-8" overwrite="true">
<filterset>
<filter token="VERSION" value="${normversion}" />
<filter token="PROVIDERNAME" value="${bundle.vendor}" />
<filter token="UPDATEURL" value="${eclipse.updatesite}" />
</filterset>
</copy>
<mkdir dir="${build.plugins}/org.lwjgl.updatesite/plugins" />
<mkdir dir="${build.plugins}/org.lwjgl.updatesite/features" />
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl_${normversion}.jar" manifest="${build.plugins}/org.lwjgl/META-INF/MANIFEST.MF">
<fileset dir="${build.plugins}/org.lwjgl" casesensitive="yes" />
</jar>
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.doc_${normversion}.jar" manifest="${build.plugins}/org.lwjgl.doc/META-INF/MANIFEST.MF">
<fileset dir="${build.plugins}/org.lwjgl.doc" casesensitive="yes" />
</jar>
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.source_${normversion}.jar" manifest="${build.plugins}/org.lwjgl.source/META-INF/MANIFEST.MF">
<fileset dir="${build.plugins}/org.lwjgl.source" casesensitive="yes" />
</jar>
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.info_${normversion}.jar" manifest="${build.plugins}/org.lwjgl.info/META-INF/MANIFEST.MF">
<fileset dir="${build.plugins}/org.lwjgl.info" casesensitive="yes" />
</jar>
<jar destfile="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.tools_${normversion}.jar" manifest="${build.plugins}/org.lwjgl.tools/META-INF/MANIFEST.MF">
<fileset dir="${build.plugins}/org.lwjgl.tools" casesensitive="yes" />
</jar>
<jar destfile="${build.plugins}/org.lwjgl.updatesite/features/org.lwjgl_${normversion}.jar">
<fileset dir="${build.plugins}/org.lwjgl.feature" casesensitive="yes" />
</jar>
<jar destfile="${build.plugins}/org.lwjgl.updatesite/features/org.lwjgl.sdk_${normversion}.jar">
<fileset dir="${build.plugins}/org.lwjgl.feature.sdk" casesensitive="yes" />
</jar>
<!-- *******************************************************************
*
* Sign plugins and feature
*
******************************************************************** -->
<signjar jar="${build.plugins}/org.lwjgl.updatesite/features/org.lwjgl_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
<signjar jar="${build.plugins}/org.lwjgl.updatesite/features/org.lwjgl.sdk_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.doc_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.source_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.info_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
<signjar jar="${build.plugins}/org.lwjgl.updatesite/plugins/org.lwjgl.tools_${normversion}.jar" keystore="${keystore}" alias="${alias}" storepass="${storepass}" keypass="${keypass}" />
</target>
<target name="clean">
<delete dir="${build.path}" />
</target>
<target name="help">
<echo>Call this build with version number and target dist, e.g.</echo>
<echo> ant -Dversion=1.1.2 dist</echo>
</target>
</project>

View file

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
ant
(C) 2011 LWJGL-Project
Author: Jens von Pilgrim, developer@jevopi.de
-->
<project default="buildClasses" basedir="." name="Build Eclipse classes" xmlns:ant4eclipse="antlib:org.ant4eclipse" xmlns:antcontrib="antlib:net.sf.antcontrib">
<property name="plugin.lwjgl.org" value="org.lwjgl" />
<property name="plugin.lwjgl.org.info" value="org.lwjgl.info" />
<property name="plugin.lwjgl.org.tools" value="org.lwjgl.tools" />
<property name="classes.folder" value="build/classes" />
<property name="plugin.build.folder" value="plugin-classes" />
<!--
<property name="" value="" />
-->
<target name="init">
<echo></echo>
</target>
<target name="buildClasses" depends="init">
<mkdir dir="${plugin.build.folder}" />
<zip basedir="../${plugin.lwjgl.org}/${classes.folder}" destfile="${plugin.build.folder}/${plugin.lwjgl.org}.zip" />
<zip basedir="../${plugin.lwjgl.org.info}/${classes.folder}" destfile="${plugin.build.folder}/${plugin.lwjgl.org.info}.zip" />
<zip basedir="../${plugin.lwjgl.org.tools}/${classes.folder}" destfile="${plugin.build.folder}/${plugin.lwjgl.org.tools}.zip" />
<jar basedir="anttasks" destfile="anttasks.jar" />
</target>
<target name="clean">
<delete dir="${plugin.build.folder}" />
</target>
<target name="help">
<echo>Call this ant script in order to create archives containing the classes of all</echo>
<echo>Eclipes plugin related classes, such as Activors.</echo>
<echo>This build file removes the burden of building Eclipse dependent classes from</echo>
<echo>within the main build script</echo>
</target>
</project>

View file

@ -11,9 +11,6 @@
******************************************************************************/
package org.lwjgl.ant;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
@ -27,11 +24,7 @@ import org.apache.tools.ant.Task;
*/
public class NormalizeVersion extends Task {
public final static String SEGMENTS[] = { "major", "minor", "service",
"qualifier" };
public final static String VERSION_QUALIFIER_PATTERN = "yyyyMMdd-HHmm";
/**
* name of the property to set
*/
@ -39,22 +32,6 @@ public class NormalizeVersion extends Task {
protected String version;
protected boolean addDateQualifier = false;
/**
* @return the addQualifier
*/
public boolean isAddDateQualifier() {
return addDateQualifier;
}
/**
* @param i_addQualifier the addQualifier to set
*/
public void setAddDateQualifier(boolean i_addDateQualifier) {
addDateQualifier = i_addDateQualifier;
}
/**
* @return the property
*/
@ -80,7 +57,7 @@ public class NormalizeVersion extends Task {
* @param i_versionNumber the versionNumber to set
*/
public void setVersion(String version) {
this.version = version;
this.version =version;
}
/**
@ -95,30 +72,6 @@ public class NormalizeVersion extends Task {
if (version == null) {
throw new BuildException("attribute version missing");
}
String s = getVersion().trim();
int sn = 0;
boolean qualifier = false;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '.') {
sn++;
} else {
qualifier = !Character.isDigit(s.charAt(i));
if (sn < 1 && !Character.isDigit(s.charAt(i))) {
throw new BuildException(
"Wrong version format, must contain only digits in the "
+ SEGMENTS[sn] + " segment, was "
+ s.substring(0, i) + ">>" + s.charAt(i)
+ "<<" + s.substring(i + 1));
}
}
}
if ((sn > 2 || qualifier) && isAddDateQualifier()) {
throw new BuildException(
"Cannot add date qualifier, qualifier already specified");
}
}
/**
@ -194,11 +147,11 @@ public class NormalizeVersion extends Task {
}
n.append(c);
}
}
if (!qualifier) {
if (digits.length() > 0) {
if (digits.length()>0) {
if (snIndex > 0)
n.append('.');
n.append(digits);
@ -213,25 +166,8 @@ public class NormalizeVersion extends Task {
case 2: // e.g. "1.2.beta
n.append(".0");
}
if (isAddDateQualifier())
n.append(createDateQualifier());
} else {
if (isAddDateQualifier()) {
throw new BuildException(
"Cannot add date qualifier, qualifier already specified");
}
}
return n.toString();
}
/**
* @return
*/
private String createDateQualifier() {
return ".v"
+ new SimpleDateFormat(VERSION_QUALIFIER_PATTERN)
.format(new Date());
}
}

View file

@ -67,42 +67,5 @@ public class NormalizeVersionTest {
}
@Test
public void testQualifier() {
NormalizeVersion t = new NormalizeVersion();
t.setProperty("normalized");
t.setAddDateQualifier(true);
t.setVersion("1");
String s = t.doExecute();
Assert.assertEquals(20, s.length());
Assert.assertTrue(s.startsWith("1.0.0"));
t.setVersion("1.2");
s = t.doExecute();
Assert.assertEquals(20, s.length());
Assert.assertTrue(s.startsWith("1.2.0"));
t.setVersion("1.2.3");
s = t.doExecute();
Assert.assertEquals(20, s.length());
Assert.assertTrue(s.startsWith("1.2.3"));
t.setVersion("2.8.2");
s = t.doExecute();
Assert.assertEquals(20, s.length());
Assert.assertTrue(s.startsWith("2.8.2"));
}
@Test(expected= BuildException.class) public void dateQualifierWithQualifier() {
NormalizeVersion t = new NormalizeVersion();
t.setProperty("normalized");
t.setAddDateQualifier(true);
t.setVersion("1.2.beta");
t.doExecute();
}
}

View file

@ -3,7 +3,6 @@
<plugin>
<extension point="org.eclipse.ui.views" >
<view
category="org.eclipse.ui"
class="org.lwjgl.info.LWJGLTestView"
icon="icons/lwjgl_logo_16.gif"
id="org.lwjgl.info.LWJGLTestView"
@ -12,7 +11,6 @@
<extension point="org.eclipse.ui.views" >
<view
category="org.eclipse.ui"
class="org.lwjgl.info.LWJGLInfoView"
icon="icons/lwjgl_logo_16.gif"
id="org.lwjgl.info.LWJGLInfoView"

View file

@ -21,8 +21,6 @@ import org.eclipse.core.runtime.IBundleGroup;
import org.eclipse.core.runtime.IBundleGroupProvider;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.opengl.GLCanvas;
import org.eclipse.swt.opengl.GLData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
@ -56,23 +54,13 @@ public class LWJGLInfoView extends ViewPart {
*/
@Override
public void createPartControl(Composite i_parent) {
Text info = new Text(i_parent, SWT.READ_ONLY | SWT.LEFT | SWT.MULTI
| SWT.H_SCROLL | SWT.V_SCROLL);
GLCanvas canvas = new GLCanvas(i_parent, SWT.NONE, new GLData());
canvas.setCurrent();
try {
GLContext.useContext(canvas);
} catch (LWJGLException ex) {
// TODO Implement catch block for LWJGLException
ex.printStackTrace();
}
Text info = new Text(i_parent, SWT.READ_ONLY | SWT.LEFT | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );
String infoString = gatherInformation();
info.setText(infoString);
}
static String getFeatureVersion(String myFeatureId) {
IBundleGroupProvider[] providers = Platform.getBundleGroupProviders();
if (providers != null) {
@ -89,36 +77,41 @@ public class LWJGLInfoView extends ViewPart {
}
/**
* @param i_canvas
* @return
*/
private static String gatherInformation() {
public static String gatherInformation() {
StringBuffer strb = new StringBuffer();
try {
infoNL(strb, "LWJGL feature version",
getFeatureVersion("org.lwjgl"));
Display.setFullscreen(false);
Display.create();
} catch (LWJGLException ex) {
warnNL(strb, "Error initializing OpenGL display: " + ex.getMessage());
}
try {
infoNL(strb, "LWJGL feature version", getFeatureVersion("org.lwjgl"));
} catch (Exception ex) {
warnNL(strb, "Error retrieving feature version: " + ex.getMessage());
}
infoNL(strb, "LWJGL version", Sys.getVersion() + (Sys.is64Bit() ? " (64bit)" : ""));
infoNL(strb, "LWJGL version", Sys.getVersion()
+ (Sys.is64Bit() ? " (64bit)" : ""));
infoNL(strb, "Java", System.getProperty("java.version"),
System.getProperty("java.vendor"));
infoNL(strb, "Java", System.getProperty("java.version"), System
.getProperty("java.vendor"));
infoNL(strb, "Platform", LWJGLUtil.getPlatformName());
infoNL(strb, "Graphics card", Display.getAdapter());
infoNL(strb, "Driver version", Display.getVersion());
infoNL(strb, "OpenGL driver version", GL11.glGetString(GL11.GL_VERSION));
infoNL(strb, "GLU version", Registry.gluGetString(GLU.GLU_VERSION));
infoNL(strb, "GLU extensions",
Registry.gluGetString(GLU.GLU_EXTENSIONS));
infoNL(strb, "GLU extensions", Registry.gluGetString(GLU.GLU_EXTENSIONS));
ContextCapabilities caps = GLContext.getCapabilities();
openGLVersions(strb, caps);
strb.append(NL).append("Capabilities").append(NL);
TreeMap<String, Boolean> capInfos = new TreeMap<String, Boolean>();
gatherCapabilities(caps, capInfos);
@ -128,37 +121,23 @@ public class LWJGLInfoView extends ViewPart {
return strb.toString();
}
static void openGLVersions(StringBuffer strb, ContextCapabilities caps) {
StringBuffer versions = new StringBuffer();
if (caps.OpenGL11)
versions.append(", 1.1");
if (caps.OpenGL12)
versions.append(", 1.2");
if (caps.OpenGL13)
versions.append(", 1.3");
if (caps.OpenGL14)
versions.append(", 1.4");
if (caps.OpenGL15)
versions.append(", 1.5");
if (caps.OpenGL20)
versions.append(", 2.0");
if (caps.OpenGL21)
versions.append(", 2.1");
if (caps.OpenGL30)
versions.append(", 3.0");
if (caps.OpenGL31)
versions.append(", 3.1");
if (caps.OpenGL32)
versions.append(", 3.2");
if (caps.OpenGL33)
versions.append(", 3.3");
if (caps.OpenGL40)
versions.append(", 4.0");
if (caps.OpenGL41)
versions.append(", 4.1");
if (strb.length() > 2)
versions.delete(0, 2);
if (caps.OpenGL11) versions.append(", 1.1");
if (caps.OpenGL12) versions.append(", 1.2");
if (caps.OpenGL13) versions.append(", 1.3");
if (caps.OpenGL14) versions.append(", 1.4");
if (caps.OpenGL15) versions.append(", 1.5");
if (caps.OpenGL20) versions.append(", 2.0");
if (caps.OpenGL21) versions.append(", 2.1");
if (caps.OpenGL30) versions.append(", 3.0");
if (caps.OpenGL31) versions.append(", 3.1");
if (caps.OpenGL32) versions.append(", 3.2");
if (caps.OpenGL33) versions.append(", 3.3");
if (caps.OpenGL40) versions.append(", 4.0");
if (caps.OpenGL41) versions.append(", 4.1");
if (strb.length()>2) versions.delete(0, 2);
infoNL(strb, "Supported OpenGL versions", versions.toString());
}
@ -199,7 +178,7 @@ public class LWJGLInfoView extends ViewPart {
if (groupInfosSupported.isEmpty()) {
infoNL(strb, title, "n.a.");
} else {
strb.append(title).append(": ");
for (int i = 0; i < TAB - title.length(); i++) {
strb.append(' ');
@ -235,7 +214,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("AMD debug output", caps.GL_AMD_debug_output);
capInfos.put("AMD draw buffers blend", caps.GL_AMD_draw_buffers_blend);
capInfos.put("AMD name gen delete", caps.GL_AMD_name_gen_delete);
capInfos.put("AMD performance monitor", caps.GL_AMD_performance_monitor);
capInfos
.put("AMD performance monitor", caps.GL_AMD_performance_monitor);
capInfos.put("AMD seamless cubemap per texture",
caps.GL_AMD_seamless_cubemap_per_texture);
capInfos.put("AMD shader stencil export",
@ -245,7 +225,8 @@ public class LWJGLInfoView extends ViewPart {
caps.GL_AMD_transform_feedback3_lines_triangles);
capInfos.put("AMD vertex shader tessellator",
caps.GL_AMD_vertex_shader_tessellator);
capInfos.put("APPLE aux depth stencil", caps.GL_APPLE_aux_depth_stencil);
capInfos
.put("APPLE aux depth stencil", caps.GL_APPLE_aux_depth_stencil);
capInfos.put("APPLE client storage", caps.GL_APPLE_client_storage);
capInfos.put("APPLE element array", caps.GL_APPLE_element_array);
capInfos.put("APPLE fence", caps.GL_APPLE_fence);
@ -265,7 +246,8 @@ public class LWJGLInfoView extends ViewPart {
caps.GL_APPLE_vertex_program_evaluators);
capInfos.put("APPLE ycbcr 422", caps.GL_APPLE_ycbcr_422);
capInfos.put("ARB ES2 compatibility", caps.GL_ARB_ES2_compatibility);
capInfos.put("ARB blend func extended", caps.GL_ARB_blend_func_extended);
capInfos
.put("ARB blend func extended", caps.GL_ARB_blend_func_extended);
capInfos.put("ARB cl event", caps.GL_ARB_cl_event);
capInfos.put("ARB color buffer float", caps.GL_ARB_color_buffer_float);
capInfos.put("ARB compatibility", caps.GL_ARB_compatibility);
@ -304,7 +286,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("ARB multitexture", caps.GL_ARB_multitexture);
capInfos.put("ARB occlusion query", caps.GL_ARB_occlusion_query);
capInfos.put("ARB occlusion query2", caps.GL_ARB_occlusion_query2);
capInfos.put("ARB pixel buffer object", caps.GL_ARB_pixel_buffer_object);
capInfos
.put("ARB pixel buffer object", caps.GL_ARB_pixel_buffer_object);
capInfos.put("ARB point parameters", caps.GL_ARB_point_parameters);
capInfos.put("ARB point sprite", caps.GL_ARB_point_sprite);
capInfos.put("ARB provoking vertex", caps.GL_ARB_provoking_vertex);
@ -314,7 +297,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("ARB seamless cube map", caps.GL_ARB_seamless_cube_map);
capInfos.put("ARB separate shader objects",
caps.GL_ARB_separate_shader_objects);
capInfos.put("ARB shader bit encoding", caps.GL_ARB_shader_bit_encoding);
capInfos
.put("ARB shader bit encoding", caps.GL_ARB_shader_bit_encoding);
capInfos.put("ARB shader objects", caps.GL_ARB_shader_objects);
capInfos.put("ARB shader precision", caps.GL_ARB_shader_precision);
capInfos.put("ARB shader stencil export",
@ -328,14 +312,16 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("ARB shadow", caps.GL_ARB_shadow);
capInfos.put("ARB shadow ambient", caps.GL_ARB_shadow_ambient);
capInfos.put("ARB sync", caps.GL_ARB_sync);
capInfos.put("ARB tessellation shader", caps.GL_ARB_tessellation_shader);
capInfos
.put("ARB tessellation shader", caps.GL_ARB_tessellation_shader);
capInfos.put("ARB texture border clamp",
caps.GL_ARB_texture_border_clamp);
capInfos.put("ARB texture buffer object",
caps.GL_ARB_texture_buffer_object);
capInfos.put("ARB texture buffer object rgb32",
caps.GL_ARB_texture_buffer_object_rgb32);
capInfos.put("ARB texture compression", caps.GL_ARB_texture_compression);
capInfos
.put("ARB texture compression", caps.GL_ARB_texture_compression);
capInfos.put("ARB texture compression bptc",
caps.GL_ARB_texture_compression_bptc);
capInfos.put("ARB texture compression rgtc",
@ -344,7 +330,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("ARB texture cube map array",
caps.GL_ARB_texture_cube_map_array);
capInfos.put("ARB texture env add", caps.GL_ARB_texture_env_add);
capInfos.put("ARB texture env combine", caps.GL_ARB_texture_env_combine);
capInfos
.put("ARB texture env combine", caps.GL_ARB_texture_env_combine);
capInfos.put("ARB texture env crossbar",
caps.GL_ARB_texture_env_crossbar);
capInfos.put("ARB texture env dot3", caps.GL_ARB_texture_env_dot3);
@ -352,7 +339,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("ARB texture gather", caps.GL_ARB_texture_gather);
capInfos.put("ARB texture mirrored repeat",
caps.GL_ARB_texture_mirrored_repeat);
capInfos.put("ARB texture multisample", caps.GL_ARB_texture_multisample);
capInfos
.put("ARB texture multisample", caps.GL_ARB_texture_multisample);
capInfos.put("ARB texture non power of two",
caps.GL_ARB_texture_non_power_of_two);
capInfos.put("ARB texture query lod", caps.GL_ARB_texture_query_lod);
@ -361,14 +349,18 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("ARB texture rgb10 a2ui", caps.GL_ARB_texture_rgb10_a2ui);
capInfos.put("ARB texture swizzle", caps.GL_ARB_texture_swizzle);
capInfos.put("ARB timer query", caps.GL_ARB_timer_query);
capInfos.put("ARB transform feedback2", caps.GL_ARB_transform_feedback2);
capInfos.put("ARB transform feedback3", caps.GL_ARB_transform_feedback3);
capInfos
.put("ARB transform feedback2", caps.GL_ARB_transform_feedback2);
capInfos
.put("ARB transform feedback3", caps.GL_ARB_transform_feedback3);
capInfos.put("ARB transpose matrix", caps.GL_ARB_transpose_matrix);
capInfos.put("ARB uniform buffer object",
caps.GL_ARB_uniform_buffer_object);
capInfos.put("ARB vertex array bgra", caps.GL_ARB_vertex_array_bgra);
capInfos.put("ARB vertex array object", caps.GL_ARB_vertex_array_object);
capInfos.put("ARB vertex attrib 64bit", caps.GL_ARB_vertex_attrib_64bit);
capInfos
.put("ARB vertex array object", caps.GL_ARB_vertex_array_object);
capInfos
.put("ARB vertex attrib 64bit", caps.GL_ARB_vertex_attrib_64bit);
capInfos.put("ARB vertex blend", caps.GL_ARB_vertex_blend);
capInfos.put("ARB vertex buffer object",
caps.GL_ARB_vertex_buffer_object);
@ -394,8 +386,10 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("ATI texture env combine3",
caps.GL_ATI_texture_env_combine3);
capInfos.put("ATI texture float", caps.GL_ATI_texture_float);
capInfos.put("ATI texture mirror once", caps.GL_ATI_texture_mirror_once);
capInfos.put("ATI vertex array object", caps.GL_ATI_vertex_array_object);
capInfos
.put("ATI texture mirror once", caps.GL_ATI_texture_mirror_once);
capInfos
.put("ATI vertex array object", caps.GL_ATI_vertex_array_object);
capInfos.put("ATI vertex attrib array object",
caps.GL_ATI_vertex_attrib_array_object);
capInfos.put("ATI vertex streams", caps.GL_ATI_vertex_streams);
@ -405,17 +399,20 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("EXT blend color", caps.GL_EXT_blend_color);
capInfos.put("EXT blend equation separate",
caps.GL_EXT_blend_equation_separate);
capInfos.put("EXT blend func separate", caps.GL_EXT_blend_func_separate);
capInfos
.put("EXT blend func separate", caps.GL_EXT_blend_func_separate);
capInfos.put("EXT blend minmax", caps.GL_EXT_blend_minmax);
capInfos.put("EXT blend subtract", caps.GL_EXT_blend_subtract);
capInfos.put("EXT Cg shader", caps.GL_EXT_Cg_shader);
capInfos.put("EXT compiled vertex array",
caps.GL_EXT_compiled_vertex_array);
capInfos.put("EXT depth bounds test", caps.GL_EXT_depth_bounds_test);
capInfos.put("EXT direct state access", caps.GL_EXT_direct_state_access);
capInfos
.put("EXT direct state access", caps.GL_EXT_direct_state_access);
capInfos.put("EXT draw buffers2", caps.GL_EXT_draw_buffers2);
capInfos.put("EXT draw instanced", caps.GL_EXT_draw_instanced);
capInfos.put("EXT draw range elements", caps.GL_EXT_draw_range_elements);
capInfos
.put("EXT draw range elements", caps.GL_EXT_draw_range_elements);
capInfos.put("EXT fog coord", caps.GL_EXT_fog_coord);
capInfos.put("EXT framebuffer blit", caps.GL_EXT_framebuffer_blit);
capInfos.put("EXT framebuffer multisample",
@ -432,7 +429,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("EXT packed float", caps.GL_EXT_packed_float);
capInfos.put("EXT packed pixels", caps.GL_EXT_packed_pixels);
capInfos.put("EXT paletted texture", caps.GL_EXT_paletted_texture);
capInfos.put("EXT pixel buffer object", caps.GL_EXT_pixel_buffer_object);
capInfos
.put("EXT pixel buffer object", caps.GL_EXT_pixel_buffer_object);
capInfos.put("EXT point parameters", caps.GL_EXT_point_parameters);
capInfos.put("EXT provoking vertex", caps.GL_EXT_provoking_vertex);
capInfos.put("EXT rescale normal", caps.GL_EXT_rescale_normal);
@ -459,7 +457,8 @@ public class LWJGLInfoView extends ViewPart {
caps.GL_EXT_texture_compression_rgtc);
capInfos.put("EXT texture compression s3tc",
caps.GL_EXT_texture_compression_s3tc);
capInfos.put("EXT texture env combine", caps.GL_EXT_texture_env_combine);
capInfos
.put("EXT texture env combine", caps.GL_EXT_texture_env_combine);
capInfos.put("EXT texture env dot3", caps.GL_EXT_texture_env_dot3);
capInfos.put("EXT texture filter anisotropic",
caps.GL_EXT_texture_filter_anisotropic);
@ -476,7 +475,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("EXT timer query", caps.GL_EXT_timer_query);
capInfos.put("EXT transform feedback", caps.GL_EXT_transform_feedback);
capInfos.put("EXT vertex array bgra", caps.GL_EXT_vertex_array_bgra);
capInfos.put("EXT vertex attrib 64bit", caps.GL_EXT_vertex_attrib_64bit);
capInfos
.put("EXT vertex attrib 64bit", caps.GL_EXT_vertex_attrib_64bit);
capInfos.put("EXT vertex shader", caps.GL_EXT_vertex_shader);
capInfos.put("EXT vertex weighting", caps.GL_EXT_vertex_weighting);
@ -491,7 +491,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("NV depth buffer float", caps.GL_NV_depth_buffer_float);
capInfos.put("NV depth clamp", caps.GL_NV_depth_clamp);
capInfos.put("NV evaluators", caps.GL_NV_evaluators);
capInfos.put("NV explicit multisample", caps.GL_NV_explicit_multisample);
capInfos
.put("NV explicit multisample", caps.GL_NV_explicit_multisample);
capInfos.put("NV fence", caps.GL_NV_fence);
capInfos.put("NV float buffer", caps.GL_NV_float_buffer);
capInfos.put("NV fog distance", caps.GL_NV_fog_distance);
@ -509,11 +510,13 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("NV gpu shader5", caps.GL_NV_gpu_shader5);
capInfos.put("NV half float", caps.GL_NV_half_float);
capInfos.put("NV light max exponent", caps.GL_NV_light_max_exponent);
capInfos.put("NV multisample coverage", caps.GL_NV_multisample_coverage);
capInfos
.put("NV multisample coverage", caps.GL_NV_multisample_coverage);
capInfos.put("NV multisample filter hint",
caps.GL_NV_multisample_filter_hint);
capInfos.put("NV occlusion query", caps.GL_NV_occlusion_query);
capInfos.put("NV packed depth stencil", caps.GL_NV_packed_depth_stencil);
capInfos
.put("NV packed depth stencil", caps.GL_NV_packed_depth_stencil);
capInfos.put("NV parameter buffer object",
caps.GL_NV_parameter_buffer_object);
capInfos.put("NV parameter buffer object2",
@ -531,7 +534,8 @@ public class LWJGLInfoView extends ViewPart {
capInfos.put("NV texture barrier", caps.GL_NV_texture_barrier);
capInfos.put("NV texture compression vtc",
caps.GL_NV_texture_compression_vtc);
capInfos.put("NV texture env combine4", caps.GL_NV_texture_env_combine4);
capInfos
.put("NV texture env combine4", caps.GL_NV_texture_env_combine4);
capInfos.put("NV texture expand normal",
caps.GL_NV_texture_expand_normal);
capInfos.put("NV texture rectangle", caps.GL_NV_texture_rectangle);
@ -587,11 +591,7 @@ public class LWJGLInfoView extends ViewPart {
io_strb.append(NL);
}
public static void main(String[] args) throws Exception {
Display.setFullscreen(false);
Display.create();
public static void main(String[] args) {
String s = gatherInformation();
System.out.println(s);
}

Binary file not shown.

BIN
libs/linux/libopenal64.so Normal file → Executable file

Binary file not shown.

Binary file not shown.

BIN
libs/macosx/openal.dylib Executable file → Normal file

Binary file not shown.

BIN
libs/solaris/libopenal.so Normal file → Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,147 +0,0 @@
<?xml version="1.0"?>
<project name="lwjgl native code, bsd" basedir="../../bin/lwjgl" default="compile">
<property name="native" location="../../src/native"/>
<property name="libname32" value="liblwjgl.so"/>
<property name="libname64" value="liblwjgl64.so"/>
<property name="libs32" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -pthread -L${java.home}/lib/i386 -ljawt" />
<property name="libs64" value="-L/usr/X11R6/lib -L/usr/local/lib -lm -lX11 -lXext -lXcursor -lXrandr -lXxf86vm -pthread -L${java.home}/lib/amd64 -ljawt" />
<property name="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
<target name="clean">
<delete>
<fileset dir="x32"/>
<fileset dir="x64"/>
<fileset dir="." includes="*.o"/>
<fileset dir="." includes="*.so"/>
</delete>
</target>
<target name="compile">
<exec executable="uname" outputproperty="hwplatform">
<arg value="-m"/>
</exec>
<condition property="xf86vm_lib" value="-lXxf86vm" else="-Wl,-static,-lXxf86vm,-call_shared">
<os name="SunOS" />
</condition>
<condition property="cflags_pthread" value="-pthreads" else="-pthread">
<os name="SunOS" />
</condition>
<condition property="version_script_flags32" value="" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
<os name="SunOS" />
</condition>
<condition property="version_script_flags64" value="-m64" else="-Wl,--version-script='${native}/linux/lwjgl.map'">
<and>
<os name="SunOS" />
</and>
</condition>
<condition property="cflags64" value="-O2 -m64 -Wall -c -fPIC -std=c99 -Wunused" else="-O2 -Wall -c -fPIC -std=c99 -Wunused">
<os name="SunOS" />
</condition>
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32} ${xf86vm_lib}"/>
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64} ${xf86vm_lib}"/>
<condition property="build.32bit.only">
<and>
<os name="FreeBSD"/>
<equals arg1="${hwplatform}" arg2="i386"/>
</and>
</condition>
<condition property="build.32bit.only">
<and>
<os name="OpenBSD"/>
<equals arg1="${hwplatform}" arg2="i386"/>
</and>
</condition>
<!-- On freebsd, the 64 bit jre doesn't have the 32 bit libs -->
<condition property="build.64bit.only">
<and>
<os name="FreeBSD"/>
<equals arg1="${hwplatform}" arg2="amd64"/>
</and>
</condition>
<condition property="build.64bit.only">
<and>
<os name="OpenBSD"/>
<equals arg1="${hwplatform}" arg2="amd64"/>
</and>
</condition>
<antcall target="compile32"/>
<antcall target="compile64"/>
</target>
<target name="compile32" unless="build.64bit.only">
<mkdir dir="x32"/>
<apply dir="x32" executable="cc" skipemptyfilesets="true" failonerror="true">
<arg line="${cflags32} ${cflags_pthread}"/>
<arg value="-I${java.home}/include"/>
<arg value="-I${java.home}/include/freebsd"/>
<arg value="-I${java.home}/include/openbsd"/>
<arg value="-I${java.home}/../include"/>
<arg value="-I${java.home}/../include/freebsd"/>
<arg value="-I${java.home}/../include/openbsd"/>
<arg value="-I/usr/local/include"/>
<arg value="-I/usr/X11R6/include"/>
<arg value="-I${native}/common"/>
<arg value="-I${native}/common/opengl"/>
<arg value="-I${native}/linux"/>
<arg value="-I${native}/linux/opengl"/>
<mapper type="glob" from="*.c" to="*.o"/>
<fileset dir="${native}/common" includes="*.c"/>
<fileset dir="${native}/common/opengl" includes="*.c"/>
<fileset dir="${native}/generated/openal" includes="*.c"/>
<fileset dir="${native}/generated/opencl" includes="*.c"/>
<fileset dir="${native}/generated/opengl" includes="*.c"/>
<fileset dir="${native}/linux" includes="*.c"/>
<fileset dir="${native}/linux/opengl" includes="*.c"/>
</apply>
<apply dir="." parallel="true" executable="cc" failonerror="true">
<srcfile/>
<arg line="${linker_flags32}"/>
<fileset dir="x32" includes="*.o"/>
</apply>
<apply dir="." parallel="true" executable="strip" failonerror="true">
<fileset file="${libname32}"/>
</apply>
</target>
<target name="compile64" unless="build.32bit.only">
<mkdir dir="x64"/>
<apply dir="x64" executable="cc" skipemptyfilesets="true" failonerror="true">
<arg line="${cflags64} ${cflags_pthread}"/>
<arg value="-I${java.home}/include"/>
<arg value="-I${java.home}/include/freebsd"/>
<arg value="-I${java.home}/include/openbsd"/>
<arg value="-I${java.home}/../include"/>
<arg value="-I${java.home}/../include/freebsd"/>
<arg value="-I${java.home}/../include/openbsd"/>
<arg value="-I/usr/local/include"/>
<arg value="-I/usr/X11R6/include"/>
<arg value="-I${native}/common"/>
<arg value="-I${native}/common/opengl"/>
<arg value="-I${native}/linux"/>
<arg value="-I${native}/linux/opengl"/>
<mapper type="glob" from="*.c" to="*.o"/>
<fileset dir="${native}/common" includes="*.c"/>
<fileset dir="${native}/common/opengl" includes="*.c"/>
<fileset dir="${native}/generated/openal" includes="*.c"/>
<fileset dir="${native}/generated/opencl" includes="*.c"/>
<fileset dir="${native}/generated/opengl" includes="*.c"/>
<fileset dir="${native}/linux" includes="*.c"/>
<fileset dir="${native}/linux/opengl" includes="*.c"/>
</apply>
<apply dir="." parallel="true" executable="cc" failonerror="true">
<srcfile/>
<arg line="${linker_flags64}"/>
<fileset dir="x64" includes="*.o"/>
</apply>
<apply dir="." parallel="true" executable="strip" failonerror="true">
<fileset file="${libname64}"/>
</apply>
</target>
</project>

View file

@ -12,19 +12,13 @@
<property name="lwjgl.docs" location="doc" />
<property name="lwjgl.temp" location="temp" />
<property name="lwjgl.res" location="res" />
<property name="lwjgl.version" value="2.9.4" />
<property name="lwjgl.version" value="2.8.1" />
<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"/>
<property name="lwjgl.src.templates.gles" location="${lwjgl.src.templates}/org/lwjgl/opengles"/>
<property name="lwjgl.src.templates.cl" location="${lwjgl.src.templates}/org/lwjgl/opencl"/>
<property name="openal-template-pattern" value="AL*.java,EFX*.java"/>
<property name="opengl-template-pattern" value="GL*.java,ARB*.java,EXT*.java,KHR*.java,AMD*.java,APPLE*.java,ATI*.java,NV*.java,NVX*.java,HP*.java,IBM*.java,SUN*.java,SGIS*.java,GREMEDY*.java,INTEL*.java"/>
<property name="opengles-template-pattern" value="GLES*.java,ARB*.java,EXT*.java,KHR*.java,AMD*.java,ANGLE*.java,APPLE*.java,ARM*.java,DMP*.java,IMG*.java,NV*.java,OES*.java,QCOM*.java,VIV*.java"/>
<property name="opencl-template-pattern-extensions" value="KHR*.java,EXT*.java,APPLE*.java,AMD*.java,INTEL*.java,NV*.java"/>
<property name="opencl-template-pattern" value="CL*.java,${opencl-template-pattern-extensions}"/>
<property name="opengl-template-pattern" value="org/lwjgl/opengl/GL*.java,org/lwjgl/opengl/ARB*.java,org/lwjgl/opengl/AMD*.java,org/lwjgl/opengl/APPLE*.java,org/lwjgl/opengl/ATI*.java,org/lwjgl/opengl/EXT*.java,org/lwjgl/opengl/NV*.java,org/lwjgl/opengl/NVX*.java,org/lwjgl/opengl/HP*.java,org/lwjgl/opengl/IBM*.java,org/lwjgl/opengl/SUN*.java,org/lwjgl/opengl/SGIS*.java,org/lwjgl/opengl/GREMEDY*.java"/>
<property name="opengles-template-pattern" value="org/lwjgl/opengles/GLES*.java,org/lwjgl/opengles/ARB*.java,org/lwjgl/opengles/EXT*.java,org/lwjgl/opengles/AMD*.java,org/lwjgl/opengles/ANGLE*.java,org/lwjgl/opengles/APPLE*.java,org/lwjgl/opengles/ARM*.java,org/lwjgl/opengles/DMP*.java,org/lwjgl/opengles/IMG*.java,org/lwjgl/opengles/NV*.java,org/lwjgl/opengles/OES*.java,org/lwjgl/opengles/QCOM*.java,org/lwjgl/opengles/VIV*.java"/>
<property name="opencl-template-pattern-extensions" value="org/lwjgl/opencl/KHR*.java,org/lwjgl/opencl/EXT*.java,org/lwjgl/opencl/APPLE*.java,org/lwjgl/opencl/AMD*.java,org/lwjgl/opencl/INTEL*.java,org/lwjgl/opencl/NV*.java"/>
<property name="opencl-template-pattern" value="org/lwjgl/opencl/CL*.java,${opencl-template-pattern-extensions}"/>
<!-- ================================================================== -->
<!-- Filesets used for targets -->
@ -147,12 +141,12 @@
<!-- Files to include in mac os x package -->
<patternset id="lwjgl-macosx.fileset">
<patternset id="lwjgl-macosx-lwjgl.fileset">
<include name="liblwjgl.dylib" />
<include name="liblwjgl.jnilib" />
<include name="openal.dylib" />
</patternset>
<patternset id="lwjgl-macosx-jinput.fileset">
<include name="libjinput-osx.dylib" />
<include name="libjinput-osx-legacy.dylib" />
<include name="libjinput-osx.jnilib" />
<include name="libjinput-osx-legacy.jnilib" />
</patternset>
</patternset>

View file

@ -1,7 +1,5 @@
<project name="generator">
<import file="build-definitions.xml"/>
<!-- clean the generated files -->
<target name="clean-generated" description="Deletes the generated java source">
<delete quiet="true" failonerror="false">
@ -16,42 +14,35 @@
</target>
<!-- Compiles the Java generator source code -->
<target name="generators" description="Compiles the native method generators">
<mkdir dir="${lwjgl.src}/generated/"/>
<mkdir dir="${lwjgl.src.native}/generated/openal"/>
<mkdir dir="${lwjgl.src.native}/generated/opengl"/>
<mkdir dir="${lwjgl.src.native}/generated/opengles"/>
<mkdir dir="${lwjgl.src.native}/generated/opencl"/>
<mkdir dir="${lwjgl.bin}"/>
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.7" target="1.7" includes="org/lwjgl/util/generator/**.java" taskname="generator">
<target name="generators" description="Compiles the native method generators">
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" includes="org/lwjgl/util/generator/**.java" source="1.5" target="1.5" taskname="generator">
<include name="org/lwjgl/util/generator/openal/**.java"/>
<include name="org/lwjgl/util/generator/opengl/**.java"/>
<include name="org/lwjgl/util/generator/opengles/**.java"/>
<include name="org/lwjgl/util/generator/opencl/**.java"/>
<compilerarg value="-Xlint:none"/>
<compilerarg value="-Xlint:all"/>
</javac>
<!-- Compile helper classes used by the templates -->
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.7" target="1.7" taskname="generator">
<!-- Compile helper classes used by the templates -->
<javac debug="yes" srcdir="${lwjgl.src}/java/" destdir="${lwjgl.bin}" source="1.5" target="1.5" taskname="generator">
<include name="org/lwjgl/PointerWrapper.java"/>
<include name="org/lwjgl/PointerBuffer.java"/>
<!-- OpenGL -->
<include name="org/lwjgl/opengl/GLSync.java"/>
<include name="org/lwjgl/opengl/AMDDebugOutputCallback.java"/>
<include name="org/lwjgl/opengl/ARBDebugOutputCallback.java"/>
<include name="org/lwjgl/opengl/KHRDebugCallback.java"/>
<!-- OpenGL ES -->
<include name="org/lwjgl/opengles/EGLImageOES.java"/>
<include name="org/lwjgl/opengles/KHRDebugCallback.java"/>
<!-- OpenCL -->
<include name="org/lwjgl/opencl/CLPlatform.java"/>
<include name="org/lwjgl/opencl/CLDevice.java"/>
<include name="org/lwjgl/opencl/CLContext.java"/>
<include name="org/lwjgl/opencl/CLContextCallback.java"/>
<include name="org/lwjgl/opencl/CLCommandQueue.java"/>
<include name="org/lwjgl/opencl/CLMem.java"/>
<include name="org/lwjgl/opencl/CL*Callback.java"/>
<include name="org/lwjgl/opencl/CLMemObjectDestructorCallback.java"/>
<include name="org/lwjgl/opencl/CLBuildProgramCallback.java"/>
<include name="org/lwjgl/opencl/CLNativeKernel.java"/>
<include name="org/lwjgl/opencl/CLEventCallback.java"/>
<include name="org/lwjgl/opencl/CLFunctionAddress.java"/>
</javac>
</target>
@ -68,48 +59,38 @@
**************************************************************************** -->
<!-- Generate OpenAL -->
<target name="generate-openal" depends="generators" description="Generates java and native source for AL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" 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="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.src.native}/generated/openal"/>
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
<src>
<fileset dir="${lwjgl.src.templates.al}">
<include name="${openal-template-pattern}"/>
</fileset>
</src>
</javac>
<target name="generate-openal" depends="generators" description="Generates java and native source for AL">
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-d"/>
<arg path="${lwjgl.src.native}/generated/openal"/>
<arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
<fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
</apply>
</target>
<!-- Generate OpenAL [DEBUG] -->
<target name="generate-openal-debug" depends="generators" description="Generates java and native source for AL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" 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="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.src.native}/generated/openal"/>
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
<compilerarg value="-Ageneratechecks"/>
<src>
<fileset dir="${lwjgl.src.templates.al}">
<include name="${openal-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-d"/>
<arg path="${lwjgl.src.native}/generated/openal"/>
<arg value="-Atypemap=org.lwjgl.util.generator.openal.ALTypeMap"/>
<arg value="-Ageneratechecks"/>
<fileset dir="${lwjgl.src.templates}" includes="org/lwjgl/openal/AL10.java, org/lwjgl/openal/AL11.java, org/lwjgl/openal/EFX10.java"/>
</apply>
</target>
<!-- ********************************************************************************
@ -120,106 +101,84 @@
<!-- Generate OpenGL -->
<target name="generate-opengl" depends="generators" description="Generates java and native source for GL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processorGL">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.src.native}/generated/opengl"/>
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
<compilerarg value="-Acontextspecific"/>
<src>
<fileset dir="${lwjgl.src.templates.gl}">
<include name="${opengl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-d"/>
<arg path="${lwjgl.src.native}/generated/opengl"/>
<arg value="-Acontextspecific"/>
<arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenGL [DEBUG] -->
<target name="generate-opengl-debug" depends="generators" description="Generates debug java and native source for GL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.src.native}/generated/opengl"/>
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
<compilerarg value="-Ageneratechecks"/>
<compilerarg value="-Acontextspecific"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
<src>
<fileset dir="${lwjgl.src.templates.gl}">
<include name="${opengl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-d"/>
<arg path="${lwjgl.src.native}/generated/opengl"/>
<arg value="-Ageneratechecks"/>
<arg value="-Acontextspecific"/>
<arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLTypeMap"/>
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenGL references -->
<target name="generate-opengl-references" depends="generators" description="Generates java and native source for GL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<src>
<fileset dir="${lwjgl.src.templates.gl}">
<include name="${opengl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.opengl.GLReferencesGeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenGL context capabilities -->
<target name="generate-opengl-capabilities" depends="generators" description="Generates java and native source for GL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-Acontextspecific"/>
<src>
<fileset dir="${lwjgl.src.templates.gl}">
<include name="${opengl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-Acontextspecific"/>
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenGL context capabilities [DEBUG] -->
<target name="generate-opengl-capabilities-debug" depends="generators" description="Generates debug java and native source for GL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gl}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-Ageneratechecks"/>
<compilerarg value="-Acontextspecific"/>
<src>
<fileset dir="${lwjgl.src.templates.gl}">
<include name="${opengl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.opengl.GLGeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-Ageneratechecks"/>
<arg value="-Acontextspecific"/>
<fileset dir="${lwjgl.src.templates}" includes="${opengl-template-pattern}"/>
</apply>
</target>
<!-- ********************************************************************************
@ -230,88 +189,70 @@
<!-- Generate OpenGL ES -->
<target name="generate-opengles" depends="generators" description="Generates java and native source for GL ES">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.src.native}/generated/opengles"/>
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
<!--<compilerarg value="-Acontextspecific"/>-->
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
<src>
<fileset dir="${lwjgl.src.templates.gles}">
<include name="${opengles-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-d"/>
<arg path="${lwjgl.src.native}/generated/opengles"/>
<!--<arg value="-Acontextspecific"/>-->
<arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
<fileset dir="${lwjgl.src.templates}" includes="${opengles-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenGL ES [DEBUG] -->
<target name="generate-opengles-debug" depends="generators" description="Generates debug java and native source for GL ES">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.src.native}/generated/opengles"/>
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
<compilerarg value="-Ageneratechecks"/>
<!--<compilerarg value="-Acontextspecific"/>-->
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
<src>
<fileset dir="${lwjgl.src.templates.gles}">
<include name="${opengles-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-d"/>
<arg path="${lwjgl.src.native}/generated/opengles"/>
<arg value="-Ageneratechecks"/>
<!--<arg value="-Acontextspecific"/>-->
<arg value="-Atypemap=org.lwjgl.util.generator.opengl.GLESTypeMap"/>
<fileset dir="${lwjgl.src.templates}" includes="${opengles-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenGL ES context capabilities -->
<target name="generate-opengles-capabilities" depends="generators" description="Generates java and native source for GL ES">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<!--<compilerarg value="-Acontextspecific"/>-->
<src>
<fileset dir="${lwjgl.src.templates.gles}">
<include name="${opengles-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<!--<arg value="-Acontextspecific"/>-->
<fileset dir="${lwjgl.src.templates}" includes="${opengles-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenGL ES context capabilities [DEBUG] -->
<target name="generate-opengles-capabilities-debug" depends="generators" description="Generates debug java and native source for GL ES">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.gles}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-Ageneratechecks"/>
<!--<compilerarg value="-Acontextspecific"/>-->
<src>
<fileset dir="${lwjgl.src.templates.gles}">
<include name="${opengles-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.opengl.GLESGeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-Ageneratechecks"/>
<!--<arg value="-Acontextspecific"/>-->
<fileset dir="${lwjgl.src.templates}" includes="${opengles-template-pattern}"/>
</apply>
</target>
<!-- ********************************************************************************
@ -322,87 +263,69 @@
<!-- Generate OpenCL -->
<target name="generate-opencl" depends="generators" description="Generates java and native source for CL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.src.native}/generated/opencl"/>
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
<compilerarg value="-Acontextspecific"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
<src>
<fileset dir="${lwjgl.src.templates.cl}">
<include name="${opencl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-d"/>
<arg path="${lwjgl.src.native}/generated/opencl"/>
<arg value="-Acontextspecific"/>
<arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
<fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenCL [DEBUG] -->
<target name="generate-opencl-debug" depends="generators" description="Generates debug java and native source for CL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.GeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-d"/>
<compilerarg path="${lwjgl.src.native}/generated/opencl"/>
<compilerarg value="-Abinpath=${lwjgl.bin}"/>
<compilerarg value="-Ageneratechecks"/>
<compilerarg value="-Acontextspecific"/>
<compilerarg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
<src>
<fileset dir="${lwjgl.src.templates.cl}">
<include name="${opencl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.GeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-d"/>
<arg path="${lwjgl.src.native}/generated/opencl"/>
<arg value="-Ageneratechecks"/>
<arg value="-Acontextspecific"/>
<arg value="-Atypemap=org.lwjgl.util.generator.opencl.CLTypeMap"/>
<fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenCL capabilities -->
<target name="generate-opencl-capabilities" depends="generators" description="Generates capabilities for CL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-Acontextspecific"/>
<src>
<fileset dir="${lwjgl.src.templates.cl}">
<include name="${opencl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-Acontextspecific"/>
<fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
</apply>
</target>
<!-- Generate OpenCL capabilities [DEBUG] -->
<target name="generate-opencl-capabilities-debug" depends="generators" description="Generates debug capabilities for CL">
<javac destdir="${lwjgl.bin}" source="1.7" target="1.7" srcdir="${lwjgl.src.templates.cl}" fork="true" taskname="processor">
<compilerarg value="-proc:only"/>
<compilerarg value="-processor"/>
<compilerarg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessor"/>
<compilerarg value="-cp"/>
<compilerarg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<compilerarg value="-s"/>
<compilerarg path="${lwjgl.src}/generated"/>
<compilerarg value="-Ageneratechecks"/>
<compilerarg value="-Acontextspecific"/>
<src>
<fileset dir="${lwjgl.src.templates.cl}">
<include name="${opencl-template-pattern}"/>
</fileset>
</src>
</javac>
<apply executable="apt" parallel="true">
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="org.lwjgl.util.generator.opencl.CLGeneratorProcessorFactory"/>
<arg value="-cp"/>
<arg path="${lwjgl.src}/java:${lwjgl.src.templates}:${lwjgl.bin}:${java.class.path}"/>
<arg value="-s"/>
<arg path="${lwjgl.src}/generated"/>
<arg value="-Ageneratechecks"/>
<arg value="-Acontextspecific"/>
<fileset dir="${lwjgl.src.templates}" includes="${opencl-template-pattern}"/>
</apply>
</target>
</project>

View file

@ -4,7 +4,7 @@
<property name="native" location="../../src/native"/>
<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="libs32" value="-L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -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="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
@ -21,6 +21,9 @@
<exec executable="uname" outputproperty="hwplatform">
<arg value="-m"/>
</exec>
<condition property="xf86vm_lib" value="-lXxf86vm" else="-Wl,-static,-lXxf86vm,-call_shared">
<os name="SunOS" />
</condition>
<condition property="cflags_pthread" value="-pthreads" else="-pthread">
<os name="SunOS" />
</condition>
@ -36,8 +39,8 @@
<os name="SunOS" />
</condition>
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32}"/>
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64}"/>
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32} ${xf86vm_lib}"/>
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64} ${xf86vm_lib}"/>
<condition property="build.32bit.only">
<not>
@ -62,7 +65,7 @@
<target name="compile32" unless="build.64bit.only">
<mkdir dir="x32"/>
<apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true" parallel="true">
<apply dir="x32" executable="gcc" skipemptyfilesets="true" failonerror="true">
<arg line="${cflags32} ${cflags_pthread}"/>
<arg value="-I${java.home}/include"/>
<arg value="-I${java.home}/include/linux"/>
@ -94,7 +97,7 @@
<target name="compile64" unless="build.32bit.only">
<mkdir dir="x64"/>
<apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true" parallel="true">
<apply dir="x64" executable="gcc" skipemptyfilesets="true" failonerror="true">
<arg line="${cflags64} ${cflags_pthread}"/>
<arg value="-I${java.home}/include"/>
<arg value="-I${java.home}/include/linux"/>

View file

@ -4,8 +4,7 @@
<property name="native" location="../../src/native"/>
<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="libs32" value="-L/home/spasi/lwjgl/libs/linux -lEGL -L/usr/X11R6/lib -L/usr/X11/lib -lm -lX11 -lXext -lXcursor -lXrandr -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="cflags32" value="-O2 -Wall -c -fPIC -std=c99 -Wunused"/>
@ -22,6 +21,9 @@
<exec executable="uname" outputproperty="hwplatform">
<arg value="-m"/>
</exec>
<condition property="xf86vm_lib" value="-lXxf86vm" else="-Wl,-static,-lXxf86vm,-call_shared">
<os name="SunOS" />
</condition>
<condition property="cflags_pthread" value="-pthreads" else="-pthread">
<os name="SunOS" />
</condition>
@ -37,8 +39,8 @@
<os name="SunOS" />
</condition>
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32}"/>
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64}"/>
<property name="linker_flags32" value="${version_script_flags32} -shared -O2 -Wall -o ${libname32} ${libs32} ${xf86vm_lib}"/>
<property name="linker_flags64" value="${version_script_flags64} -shared -O2 -Wall -o ${libname64} ${libs64} ${xf86vm_lib}"/>
<condition property="build.32bit.only">
<not>
@ -124,4 +126,4 @@
<fileset file="${libname64}"/>
</apply>
</target>
</project>
</project>

View file

@ -1,3 +1,4 @@
#!/bin/sh
nm -j -g "$1"/*.o | grep -E "J(ava|NI)_[^.]*$"
nm -g "$1"/*.o | grep "Java_" | cut -d ' ' -f3 | cut -c 1-
nm -g "$1"/*.o | grep "JNI_" | cut -d ' ' -f3 | cut -c 1-

View file

@ -1,220 +1,103 @@
<project name="OS X Native code" basedir="../../bin/lwjgl" default="nativelibrary">
<property name="native" location="../../src/native"/>
<target name="init">
<mkdir dir="arm64"/>
<property environment="env" />
<!-- Ask Xcode for correct path to XCode tools -->
<!-- Will fail if XCode Command Line Tools are not installed on 10.7+ (Lion) -->
<exec executable="xcode-select" outputproperty="developer_path" errorproperty="xcode-select.error" failonerror="false" failifexecutionfails="false">
<arg value="-print-path" />
</exec>
<!-- Default to /Developer if xcode-select fails -->
<condition property="developer_path" value="/Developer">
<isset property="xcode-select.error" />
</condition>
<property name="sdk_path" value="Platforms/MacOSX.platform/Developer/SDKs"/>
<property name="jvm_headers_path" value="/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/include/"/>
<property name="sdkroot" value="${developer_path}/${sdk_path}/MacOSX.sdk"/>
<!-- Choose a JavaVM.framework -->
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
<and>
<not><isset property="javavmroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.9.sdk/${jvm_headers_path}" type="dir"/>
</and>
</condition>
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
<and>
<not><isset property="javavmroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk/${jvm_headers_path}" type="dir"/>
</and>
</condition>
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
<and>
<not><isset property="javavmroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk/${jvm_headers_path}" type="dir"/>
</and>
</condition>
<condition property="javavmroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
<and>
<not><isset property="javavmroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk/${jvm_headers_path}" type="dir"/>
</and>
</condition>
<condition property="javavmroot" value=""> <!-- Old location -->
<and>
<not><isset property="javavmroot"/></not>
<available file="/${jvm_headers_path}" type="dir"/>
</and>
</condition>
<!-- Choose a MacOSX SDK -->
<property name="compiler" value="clang"/> <!-- Default to clang for 10.8 and up -->
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.9.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.9.sdk" type="dir"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.8.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.8.sdk" type="dir"/>
</and>
</condition>
<!-- If we're on 10.7 or lower, use gcc instead of clang -->
<condition property="compiler" value="gcc-4.2">
<and>
<not><isset property="sdkroot"/></not>
<available file="gcc-4.2" filepath="${env.PATH}"/>
</and>
</condition>
<condition property="compiler" value="gcc">
<and>
<not><isset property="sdkroot"/></not>
<not><available file="gcc-4.2" filepath="${env.PATH}"/></not>
<available file="gcc" filepath="${env.PATH}"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.7.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.7.sdk" type="dir"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/${sdk_path}/MacOSX10.6.sdk">
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/${sdk_path}/MacOSX10.6.sdk" type="dir"/>
</and>
</condition>
<condition property="sdkroot" value="${developer_path}/SDKs/MacOSx10.6.sdk"> <!-- Old XCode location -->
<and>
<not><isset property="sdkroot"/></not>
<available file="${developer_path}/SDKs/MacOSx10.6.sdk" type="dir"/>
</and>
</condition>
</target>
<target name="clean">
<delete failonerror="false">
<fileset dir="arm64"/>
<fileset dir="." includes="liblwjgl.dylib"/>
<fileset dir="." includes="lwjgl.symbols"/>
</delete>
</target>
<target name="compile" depends="init">
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
<arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I${jvm_headers_path} -I${jvm_headers_path}/darwin -I${native}/common -I${native}/common/opengl -I${native}/macosx"/>
<!-- Map from *.m and *.c to .o -->
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
<fileset dir="${native}/macosx" includes="*.m"/>
<fileset dir="${native}/macosx" includes="*.c"/>
<fileset dir="${native}/common" includes="*.c"/>
<fileset dir="${native}/common/opengl" includes="*.c"/>
<fileset dir="${native}/generated/openal" includes="*.c"/>
<fileset dir="${native}/generated/opencl" includes="*.c"/>
<fileset dir="${native}/generated/opengl" includes="*.c"/>
</apply>
</target>
<target name="link" depends="init">
<condition property="jdk_lib" value="${java.home}/lib">
<available file="${java.home}/lib/libjawt.dylib" type="file"/>
</condition>
<condition property="jdk_lib" value="${java.home}/../Libraries">
<not><isset property="jdk_lib"/></not>
</condition>
<apply dir="${objdir}" parallel="true" executable="${compiler}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
<arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -weak_framework AppKit -framework Carbon -framework OpenGL -framework QuartzCore -L${jdk_lib} -ljawt"/>
<fileset dir="${objdir}" includes="*.o"/>
</apply>
<!-- <apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true"> -->
<!-- <arg line="-S -X"/> -->
<!-- <fileset file="${libname}"/> -->
<!-- </apply> -->
</target>
<target name="nativelibrary" depends="init">
<echo message=" Compiler: ${compiler}"/>
<echo message=" Mac OS SDK: ${sdkroot}"/>
<echo message="JavaVM.framework: ${javavmroot}"/>
<property name="build_arm64" value="1" />
<antcall target="-build"/>
</target>
<target name="-build" depends="-build_arm64"/>
<!-- <target name="-build_universal" unless="build_x86_64"> -->
<!-- <mkdir dir="i386"/> -->
<!-- <property name="universal_sdkroot" location="${sdkroot}"/> -->
<!-- <property name="x86_64_sdkroot" location="${sdkroot}"/> -->
<!-- <property name="universal_flags" value="-isysroot ${universal_sdkroot}"/> -->
<!-- <antcall target="compile"> -->
<!-- <param name="dstdir" location="i386"/> -->
<!-- <param name="sdkroot" location="${universal_sdkroot}"/> -->
<!-- <param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/> -->
<!-- </antcall> -->
<!-- <antcall target="compile"> -->
<!-- <param name="dstdir" location="x86_64"/> -->
<!-- <param name="sdkroot" location="${universal_sdkroot}"/> -->
<!-- <param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/> -->
<!-- </antcall> -->
<!-- <exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true"> -->
<!-- <arg path="../../platform_build/macosx_ant/build-symbol-list"/> -->
<!-- <arg path="i386"/> -->
<!-- </exec> -->
<!-- <antcall target="link"> -->
<!-- <param name="objdir" location="i386"/> -->
<!-- <param name="libname" value="liblwjgl-i386.dylib"/> -->
<!-- <param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.5"/> -->
<!-- </antcall> -->
<!-- <antcall target="link"> -->
<!-- <param name="objdir" location="x86_64"/> -->
<!-- <param name="libname" value="liblwjgl-i86_64.dylib"/> -->
<!-- <param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/> -->
<!-- </antcall> -->
<!-- <apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true"> -->
<!-- <arg value="-create"/> -->
<!-- <srcfile/> -->
<!-- <arg value="-output"/> -->
<!-- <arg path="liblwjgl.dylib"/> -->
<!-- <fileset file="i386/liblwjgl-i386.dylib"/> -->
<!-- <fileset file="x86_64/liblwjgl-i86_64.dylib"/> -->
<!-- </apply> -->
<!-- </target> -->
<target name="-build_arm64" if="build_arm64">
<antcall target="compile">
<param name="dstdir" location="arm64"/>
<param name="sdkroot" location="${sdkroot}"/>
<param name="cflags" value="-isysroot ${sdkroot} -arch arm64 -mmacosx-version-min=10.5"/>
</antcall>
<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
<arg path="arm64"/>
</exec>
<antcall target="link">
<param name="objdir" location="arm64"/>
<param name="libname" value="liblwjgl-arm64.dylib"/>
<param name="linkerflags" value="-isysroot ${sdkroot} -arch arm64 -mmacosx-version-min=10.5"/>
</antcall>
<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
<arg value="-create"/>
<srcfile/>
<arg value="-output"/>
<arg path="liblwjgl.dylib"/>
<fileset file="arm64/liblwjgl-arm64.dylib"/>
</apply>
</target>
</project>
<project name="OS X Native code" basedir="../../bin/lwjgl" default="nativelibrary">
<property name="native" location="../../src/native"/>
<target name="init">
<mkdir dir="ppc"/>
<mkdir dir="i386"/>
<mkdir dir="x86_64"/>
</target>
<target name="clean">
<delete failonerror="false">
<fileset dir="i386"/>
<fileset dir="x86_64"/>
<fileset dir="ppc"/>
<fileset dir="." includes="liblwjgl.jnilib"/>
<fileset dir="." includes="lwjgl.symbols"/>
</delete>
</target>
<target name="compile">
<apply dir="${dstdir}" executable="${compiler}" os="Mac OS X" skipemptyfilesets="true" failonerror="true" dest="${dstdir}">
<arg line="${cflags} -ObjC -O2 -Wall -Wunused -c -fPIC -I/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers -I${native}/common -I${native}/common/opengl -I${native}/macosx -I/System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/Headers"/>
<!-- Map from *.m and *.c to .o -->
<mapper type="regexp" from="^(.*)\.(c|m)" to="\1.o"/>
<fileset dir="${native}/macosx" includes="*.m"/>
<fileset dir="${native}/macosx" includes="*.c"/>
<fileset dir="${native}/common" includes="*.c"/>
<fileset dir="${native}/common/opengl" includes="*.c"/>
<fileset dir="${native}/generated/openal" includes="*.c"/>
<fileset dir="${native}/generated/opencl" includes="*.c"/>
<fileset dir="${native}/generated/opengl" includes="*.c"/>
</apply>
</target>
<target name="link">
<apply dir="${objdir}" parallel="true" executable="${linker}" os="Mac OS X" failonerror="true" skipemptyfilesets="true">
<arg line="${linkerflags} -exported_symbols_list ../lwjgl.symbols -dynamiclib -o ${libname} -framework Foundation -framework AppKit -framework JavaVM -framework Carbon -framework OpenGL -framework JavaNativeFoundation -F/System/Library/Frameworks/JavaVM.framework/Frameworks"/>
<fileset dir="${objdir}" includes="*.o"/>
</apply>
<apply dir="${objdir}" executable="strip" os="Mac OS X" failonerror="true">
<arg line="-S -X"/>
<fileset dir="." file="${libname}"/>
</apply>
</target>
<target name="nativelibrary" depends="init">
<property name="universal_sdkroot" location="/Developer/SDKs/MacOSX10.6.sdk"/>
<property name="ppc_sdkroot" location="/Developer/SDKs/MacOSX10.6.sdk"/>
<property name="x86_64_sdkroot" location="/Developer/SDKs/MacOSX10.6.sdk"/>
<property name="universal_flags" value="-isysroot ${universal_sdkroot}"/>
<property name="ppc_flags" value="-isysroot ${ppc_sdkroot}"/>
<antcall target="compile">
<param name="dstdir" location="ppc"/>
<param name="compiler" value="gcc-4.2"/>
<param name="sdkroot" location="${ppc_sdkroot}"/>
<param name="cflags" value="${universal_flags} -arch ppc -mmacosx-version-min=10.3"/>
</antcall>
<antcall target="compile">
<param name="dstdir" location="i386"/>
<param name="compiler" value="gcc-4.2"/>
<param name="sdkroot" location="${universal_sdkroot}"/>
<param name="cflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
</antcall>
<antcall target="compile">
<param name="dstdir" location="x86_64"/>
<param name="compiler" value="gcc-4.2"/>
<param name="sdkroot" location="${universal_sdkroot}"/>
<param name="cflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
</antcall>
<exec vmlauncher="true" executable="sh" output="lwjgl.symbols" failonerror="true">
<arg path="../../platform_build/macosx_ant/build-symbol-list"/>
<arg path="i386"/>
</exec>
<antcall target="link">
<param name="objdir" location="ppc"/>
<param name="libname" value="liblwjgl-ppc.jnilib"/>
<param name="linker" value="gcc-4.2"/>
<param name="linkerflags" value="${universal_flags} -arch ppc -mmacosx-version-min=10.3"/>
</antcall>
<antcall target="link">
<param name="objdir" location="i386"/>
<param name="libname" value="liblwjgl-i386.jnilib"/>
<param name="linker" value="gcc-4.2"/>
<param name="linkerflags" value="${universal_flags} -arch i386 -mmacosx-version-min=10.4"/>
</antcall>
<antcall target="link">
<param name="objdir" location="x86_64"/>
<param name="libname" value="liblwjgl-i86_64.jnilib"/>
<param name="linker" value="gcc-4.2"/>
<param name="linkerflags" value="-isysroot ${x86_64_sdkroot} -arch x86_64 -mmacosx-version-min=10.5"/>
</antcall>
<apply dir="." parallel="true" executable="lipo" os="Mac OS X" failonerror="true" skipemptyfilesets="true" >
<arg value="-create"/>
<srcfile/>
<arg value="-output"/>
<arg path="liblwjgl.jnilib"/>
<fileset file="ppc/liblwjgl-ppc.jnilib"/>
<fileset file="i386/liblwjgl-i386.jnilib"/>
<fileset file="x86_64/liblwjgl-i86_64.jnilib"/>
</apply>
</target>
</project>

View file

@ -6,8 +6,8 @@
<property name="sdkhome" location="${env.MSSDK}"/>
<target name="compile_dir">
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true" parallel="true">
<arg line="/c /W2 /EHsc /Ox /Gy /MT /MP /nologo"/>
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true">
<arg line="/Ox /W2 /nologo /Ox /Ob2 /Oi /Ot /Oy /FD /EHsc /MT /Gy /W2 /nologo /c"/>
<arg value="/I${sdkhome}\include"/>
<arg value="/I${java.home}\..\include"/>
<arg value="/I${java.home}\..\include\win32"/>

View file

@ -6,8 +6,8 @@
<property name="sdkhome" location="${env.MSSDK}"/>
<target name="compile_dir">
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true" parallel="true">
<arg line="/c /W2 /EHsc /Ox /Gy /MT /MP /nologo"/>
<apply dir="." failonerror="true" executable="cl" dest="." skipemptyfilesets="true">
<arg line="/Ox /W2 /nologo /Ox /Ob2 /Oi /Ot /Oy /FD /EHsc /MT /Gy /W2 /nologo /c"/>
<arg value="/I${sdkhome}\include"/>
<arg value="/I${java.home}\..\include"/>
<arg value="/I${java.home}\..\include\win32"/>

View file

@ -272,7 +272,7 @@ public class LWJGLUtil {
final String osName = getPrivilegedProperty("os.name");
if ( osName.startsWith("Windows") )
PLATFORM = PLATFORM_WINDOWS;
else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("OpenBSD") || osName.startsWith("SunOS") || osName.startsWith("Unix") )
else if ( osName.startsWith("Linux") || osName.startsWith("FreeBSD") || osName.startsWith("SunOS") || osName.startsWith("Unix") )
PLATFORM = PLATFORM_LINUX;
else if ( osName.startsWith("Mac OS X") || osName.startsWith("Darwin") )
PLATFORM = PLATFORM_MACOSX;
@ -319,21 +319,6 @@ public class LWJGLUtil {
}
}
/**
* Wraps {@link System#mapLibraryName}. On OS X with JDK 6, the .jnilib file
* extension will be replaced with .dylib.
*
* @param name the name of the library.
*
* @return a platform-dependent native library name.
*/
public static String mapLibraryName(String name) {
String libName = System.mapLibraryName(name);
return LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX && libName.endsWith(".jnilib")
? libName.substring(0, libName.length() - ".jnilib".length()) + ".dylib"
: libName;
}
/**
* Locates the paths required by a library.
*
@ -435,11 +420,9 @@ public class LWJGLUtil {
* @return Absolute path to library if found, otherwise null
*/
private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) {
Class<?> c = null;
try {
log("getPathFromClassLoader: searching for: " + libname);
c = classloader.getClass();
Class<?> c = classloader.getClass();
while (c != null) {
final Class<?> clazz = c;
try {
@ -457,7 +440,7 @@ public class LWJGLUtil {
}
}
} catch (Exception e) {
log("Failure locating " + e + " using classloader:" + c);
log("Failure locating " + e + " using classloader:" + e);
}
return null;
}
@ -620,10 +603,10 @@ public class LWJGLUtil {
* @param field the Field to test
* @param value the integer value of the field
*
* @return true if the Field is accepted
* @result true if the Field is accepted
*/
boolean accept(Field field, int value);
}
}
}

View file

@ -71,7 +71,7 @@ final class LinuxSysImplementation extends J2SESysImplementation {
// Linux may as well resort to pure Java hackery, as there's no Linux native way of doing it
// right anyway.
String[] browsers = {"sensible-browser", "xdg-open", "google-chrome", "chromium", "firefox", "iceweasel", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"};
for ( final String browser : browsers ) {
try {

View file

@ -31,10 +31,9 @@
*/
package org.lwjgl;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedExceptionAction;
import java.lang.UnsatisfiedLinkError;
import java.awt.Toolkit;
import com.apple.eio.FileManager;
/**
*
@ -43,16 +42,24 @@ import java.lang.UnsatisfiedLinkError;
* $Id$
*/
final class MacOSXSysImplementation extends J2SESysImplementation {
private static final int JNI_VERSION = 25;
private static final int JNI_VERSION = 21;
static {
// Manually start the AWT Application Loop
java.awt.Toolkit.getDefaultToolkit();
// Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3
Toolkit.getDefaultToolkit();
}
public int getRequiredJNIVersion() {
return JNI_VERSION;
}
public native boolean openURL(String url);
public boolean openURL(String url) {
try {
FileManager.openURL(url);
return true;
} catch (Exception e) {
LWJGLUtil.log("Exception occurred while trying to invoke browser: " + e);
return false;
}
}
}

View file

@ -33,7 +33,10 @@ package org.lwjgl;
import java.lang.reflect.Field;
import java.nio.*;
import java.nio.charset.*;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
/**
* [INTERNAL USE ONLY]
@ -62,10 +65,10 @@ public final class MemoryUtil {
// Depends on java.nio.Buffer#address and sun.misc.Unsafe
util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorUnsafe");
} catch (Exception e0) {
// try {
// // Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor
// util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorReflectFast");
// } catch (Exception e1) {
try {
// Depends on java.nio.Buffer#address and sun.reflect.FieldAccessor
util = loadAccessor("org.lwjgl.MemoryUtilSun$AccessorReflectFast");
} catch (Exception e1) {
try {
// Depends on java.nio.Buffer#address
util = new AccessorReflect();
@ -73,7 +76,7 @@ public final class MemoryUtil {
LWJGLUtil.log("Unsupported JVM detected, this will likely result in low performance. Please inform LWJGL developers.");
util = new AccessorJNI();
}
// }
}
}
LWJGLUtil.log("MemoryUtil Accessor: " + util.getClass().getSimpleName());
@ -282,63 +285,8 @@ public final class MemoryUtil {
throw new RuntimeException(e);
}
}
// cast to use Buffer's implementation of flip even when compiling against versions of java that have ByteBuffer::flip
((Buffer)out).flip();
return out;
}
public static String decodeASCII(final ByteBuffer buffer) {
return decode(buffer, ascii);
}
public static String decodeUTF8(final ByteBuffer buffer) {
return decode(buffer, utf8);
}
public static String decodeUTF16(final ByteBuffer buffer) {
return decode(buffer, utf16);
}
private static String decode(final ByteBuffer buffer, final Charset charset) {
if ( buffer == null )
return null;
return decodeImpl(buffer, charset);
}
private static String decodeImpl(final ByteBuffer in, final Charset charset) {
final CharsetDecoder decoder = charset.newDecoder(); // decoders are not thread-safe, create a new one on every call
int n = (int)(in.remaining() * decoder.averageCharsPerByte());
CharBuffer out = BufferUtils.createCharBuffer(n);
if ( (n == 0) && (in.remaining() == 0) )
return "";
decoder.reset();
for (; ; ) {
CoderResult cr = in.hasRemaining() ? decoder.decode(in, out, true) : CoderResult.UNDERFLOW;
if ( cr.isUnderflow() )
cr = decoder.flush(out);
if ( cr.isUnderflow() )
break;
if ( cr.isOverflow() ) {
n = 2 * n + 1; // Ensure progress; n might be 0!
CharBuffer o = BufferUtils.createCharBuffer(n);
out.flip();
o.put(out);
out = o;
continue;
}
try {
cr.throwException();
} catch (CharacterCodingException e) {
throw new RuntimeException(e);
}
}
out.flip();
return out.toString();
return out;
}
/** A null-terminated CharSequence. */
@ -414,18 +362,16 @@ public final class MemoryUtil {
return getDeclaredFieldRecursive(ByteBuffer.class, "address");
}
private static Field getDeclaredFieldRecursive(final Class<?> root, final String fieldName) throws NoSuchFieldException {
Class<?> type = root;
do {
private static Field getDeclaredFieldRecursive(Class<?> type, final String fieldName) throws NoSuchFieldException {
while ( type != null ) {
try {
return type.getDeclaredField(fieldName);
} catch (NoSuchFieldException e) {
type = type.getSuperclass();
}
} while ( type != null );
}
throw new NoSuchFieldException(fieldName + " does not exist in " + root.getSimpleName() + " or any of its superclasses.");
throw new NoSuchFieldException(fieldName + " does not exist in " + type.getSimpleName() + " or any of its superclasses.");
}
}

View file

@ -37,7 +37,7 @@ import java.lang.reflect.Modifier;
import java.nio.Buffer;
import sun.misc.Unsafe;
// import sun.reflect.FieldAccessor;
import sun.reflect.FieldAccessor;
/**
* MemoryUtil.Accessor implementations that depend on sun.misc.
@ -104,32 +104,32 @@ final class MemoryUtilSun {
}
/** Implementation using reflection on ByteBuffer, FieldAccessor is used directly. */
// private static class AccessorReflectFast implements MemoryUtil.Accessor {
private static class AccessorReflectFast implements MemoryUtil.Accessor {
// private final FieldAccessor addressAccessor;
private final FieldAccessor addressAccessor;
// AccessorReflectFast() {
// Field address;
// try {
// address = MemoryUtil.getAddressField();
// } catch (NoSuchFieldException e) {
// throw new UnsupportedOperationException(e);
// }
// address.setAccessible(true);
AccessorReflectFast() {
Field address;
try {
address = MemoryUtil.getAddressField();
} catch (NoSuchFieldException e) {
throw new UnsupportedOperationException(e);
}
address.setAccessible(true);
// try {
// Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class);
// m.setAccessible(true);
// addressAccessor = (FieldAccessor)m.invoke(address, true);
// } catch (Exception e) {
// throw new UnsupportedOperationException(e);
// }
// }
try {
Method m = Field.class.getDeclaredMethod("acquireFieldAccessor", boolean.class);
m.setAccessible(true);
addressAccessor = (FieldAccessor)m.invoke(address, true);
} catch (Exception e) {
throw new UnsupportedOperationException(e);
}
}
// public long getAddress(final Buffer buffer) {
// return addressAccessor.getLong(buffer);
// }
public long getAddress(final Buffer buffer) {
return addressAccessor.getLong(buffer);
}
// }
}
}
}

View file

@ -0,0 +1,409 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.IntBuffer;
import java.nio.FloatBuffer;
import java.nio.LongBuffer;
import java.nio.DoubleBuffer;
import java.nio.ByteOrder;
/**
* Utility class to cache thread local direct buffers so when we are passed a non-direct buffer,
* we can put its contents into a cached direct buffer and use that at the native side instead.
*
* Internal class, don't use.
* @author elias_naur <elias_naur@users.sourceforge.net>
* @version $Revision: 2762 $
* $Id: BufferChecks.java 2762 2007-04-11 16:13:05Z elias_naur $
*/
public final class NondirectBufferWrapper {
private static final int INITIAL_BUFFER_SIZE = 1;
private static final ThreadLocal<CachedBuffers> thread_buffer = new ThreadLocal<CachedBuffers>() {
protected CachedBuffers initialValue() {
return new CachedBuffers(INITIAL_BUFFER_SIZE);
}
};
private static CachedBuffers getCachedBuffers(int minimum_byte_size) {
CachedBuffers buffers = thread_buffer.get();
int current_byte_size = buffers.byte_buffer.capacity();
if (minimum_byte_size > current_byte_size) {
buffers = new CachedBuffers(minimum_byte_size);
thread_buffer.set(buffers);
}
return buffers;
}
public static ByteBuffer wrapNoCopyBuffer(ByteBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapNoCopyDirect(buf);
}
public static ShortBuffer wrapNoCopyBuffer(ShortBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapNoCopyDirect(buf);
}
public static IntBuffer wrapNoCopyBuffer(IntBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapNoCopyDirect(buf);
}
public static LongBuffer wrapNoCopyBuffer(LongBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapNoCopyDirect(buf);
}
public static FloatBuffer wrapNoCopyBuffer(FloatBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapNoCopyDirect(buf);
}
public static DoubleBuffer wrapNoCopyBuffer(DoubleBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapNoCopyDirect(buf);
}
public static ByteBuffer wrapBuffer(ByteBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapDirect(buf);
}
public static ShortBuffer wrapBuffer(ShortBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapDirect(buf);
}
public static IntBuffer wrapBuffer(IntBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapDirect(buf);
}
public static LongBuffer wrapBuffer(LongBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapDirect(buf);
}
public static FloatBuffer wrapBuffer(FloatBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapDirect(buf);
}
public static DoubleBuffer wrapBuffer(DoubleBuffer buf, int size) {
BufferChecks.checkBufferSize(buf, size);
return wrapDirect(buf);
}
public static ByteBuffer wrapDirect(ByteBuffer buffer) {
if (!buffer.isDirect())
return doWrap(buffer);
return buffer;
}
public static ShortBuffer wrapDirect(ShortBuffer buffer) {
if (!buffer.isDirect())
return doWrap(buffer);
return buffer;
}
public static FloatBuffer wrapDirect(FloatBuffer buffer) {
if (!buffer.isDirect())
return doWrap(buffer);
return buffer;
}
public static IntBuffer wrapDirect(IntBuffer buffer) {
if (!buffer.isDirect())
return doWrap(buffer);
return buffer;
}
public static LongBuffer wrapDirect(LongBuffer buffer) {
if (!buffer.isDirect())
return doWrap(buffer);
return buffer;
}
public static DoubleBuffer wrapDirect(DoubleBuffer buffer) {
if (!buffer.isDirect())
return doWrap(buffer);
return buffer;
}
public static ByteBuffer wrapNoCopyDirect(ByteBuffer buffer) {
if (!buffer.isDirect())
return doNoCopyWrap(buffer);
return buffer;
}
public static ShortBuffer wrapNoCopyDirect(ShortBuffer buffer) {
if (!buffer.isDirect())
return doNoCopyWrap(buffer);
return buffer;
}
public static FloatBuffer wrapNoCopyDirect(FloatBuffer buffer) {
if (!buffer.isDirect())
return doNoCopyWrap(buffer);
return buffer;
}
public static IntBuffer wrapNoCopyDirect(IntBuffer buffer) {
if (!buffer.isDirect())
return doNoCopyWrap(buffer);
return buffer;
}
public static LongBuffer wrapNoCopyDirect(LongBuffer buffer) {
if (!buffer.isDirect())
return doNoCopyWrap(buffer);
return buffer;
}
public static DoubleBuffer wrapNoCopyDirect(DoubleBuffer buffer) {
if (!buffer.isDirect())
return doNoCopyWrap(buffer);
return buffer;
}
public static void copy(ByteBuffer src, ByteBuffer dst) {
if (dst != null && !dst.isDirect()) {
int saved_position = dst.position();
dst.put(src);
dst.position(saved_position);
}
}
public static void copy(ShortBuffer src, ShortBuffer dst) {
if (dst != null && !dst.isDirect()) {
int saved_position = dst.position();
dst.put(src);
dst.position(saved_position);
}
}
public static void copy(IntBuffer src, IntBuffer dst) {
if (dst != null && !dst.isDirect()) {
int saved_position = dst.position();
dst.put(src);
dst.position(saved_position);
}
}
public static void copy(FloatBuffer src, FloatBuffer dst) {
if (dst != null && !dst.isDirect()) {
int saved_position = dst.position();
dst.put(src);
dst.position(saved_position);
}
}
public static void copy(LongBuffer src, LongBuffer dst) {
if (dst != null && !dst.isDirect()) {
int saved_position = dst.position();
dst.put(src);
dst.position(saved_position);
}
}
public static void copy(DoubleBuffer src, DoubleBuffer dst) {
if (dst != null && !dst.isDirect()) {
int saved_position = dst.position();
dst.put(src);
dst.position(saved_position);
}
}
private static ByteBuffer doNoCopyWrap(ByteBuffer buffer) {
ByteBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.limit(buffer.limit());
direct_buffer.position(buffer.position());
return direct_buffer;
}
private static ShortBuffer doNoCopyWrap(ShortBuffer buffer) {
ShortBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.limit(buffer.limit());
direct_buffer.position(buffer.position());
return direct_buffer;
}
private static IntBuffer doNoCopyWrap(IntBuffer buffer) {
IntBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.limit(buffer.limit());
direct_buffer.position(buffer.position());
return direct_buffer;
}
private static FloatBuffer doNoCopyWrap(FloatBuffer buffer) {
FloatBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.limit(buffer.limit());
direct_buffer.position(buffer.position());
return direct_buffer;
}
private static LongBuffer doNoCopyWrap(LongBuffer buffer) {
LongBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.limit(buffer.limit());
direct_buffer.position(buffer.position());
return direct_buffer;
}
private static DoubleBuffer doNoCopyWrap(DoubleBuffer buffer) {
DoubleBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.limit(buffer.limit());
direct_buffer.position(buffer.position());
return direct_buffer;
}
private static ByteBuffer lookupBuffer(ByteBuffer buffer) {
return getCachedBuffers(buffer.remaining()).byte_buffer;
}
private static ByteBuffer doWrap(ByteBuffer buffer) {
ByteBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.clear();
int saved_position = buffer.position();
direct_buffer.put(buffer);
buffer.position(saved_position);
direct_buffer.flip();
return direct_buffer;
}
private static ShortBuffer lookupBuffer(ShortBuffer buffer) {
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*2);
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.short_buffer_little : buffers.short_buffer_big;
}
private static ShortBuffer doWrap(ShortBuffer buffer) {
ShortBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.clear();
int saved_position = buffer.position();
direct_buffer.put(buffer);
buffer.position(saved_position);
direct_buffer.flip();
return direct_buffer;
}
private static FloatBuffer lookupBuffer(FloatBuffer buffer) {
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4);
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.float_buffer_little : buffers.float_buffer_big;
}
private static FloatBuffer doWrap(FloatBuffer buffer) {
FloatBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.clear();
int saved_position = buffer.position();
direct_buffer.put(buffer);
buffer.position(saved_position);
direct_buffer.flip();
return direct_buffer;
}
private static IntBuffer lookupBuffer(IntBuffer buffer) {
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*4);
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.int_buffer_little : buffers.int_buffer_big;
}
private static IntBuffer doWrap(IntBuffer buffer) {
IntBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.clear();
int saved_position = buffer.position();
direct_buffer.put(buffer);
buffer.position(saved_position);
direct_buffer.flip();
return direct_buffer;
}
private static LongBuffer lookupBuffer(LongBuffer buffer) {
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8);
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.long_buffer_little : buffers.long_buffer_big;
}
private static LongBuffer doWrap(LongBuffer buffer) {
LongBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.clear();
int saved_position = buffer.position();
direct_buffer.put(buffer);
buffer.position(saved_position);
direct_buffer.flip();
return direct_buffer;
}
private static DoubleBuffer lookupBuffer(DoubleBuffer buffer) {
CachedBuffers buffers = getCachedBuffers(buffer.remaining()*8);
return buffer.order() == ByteOrder.LITTLE_ENDIAN ? buffers.double_buffer_little : buffers.double_buffer_big;
}
private static DoubleBuffer doWrap(DoubleBuffer buffer) {
DoubleBuffer direct_buffer = lookupBuffer(buffer);
direct_buffer.clear();
int saved_position = buffer.position();
direct_buffer.put(buffer);
buffer.position(saved_position);
direct_buffer.flip();
return direct_buffer;
}
private static final class CachedBuffers {
private final ByteBuffer byte_buffer;
private final ShortBuffer short_buffer_big;
private final IntBuffer int_buffer_big;
private final FloatBuffer float_buffer_big;
private final LongBuffer long_buffer_big;
private final DoubleBuffer double_buffer_big;
private final ShortBuffer short_buffer_little;
private final IntBuffer int_buffer_little;
private final FloatBuffer float_buffer_little;
private final LongBuffer long_buffer_little;
private final DoubleBuffer double_buffer_little;
private CachedBuffers(int size) {
this.byte_buffer = ByteBuffer.allocateDirect(size);
this.short_buffer_big = byte_buffer.asShortBuffer();
this.int_buffer_big = byte_buffer.asIntBuffer();
this.float_buffer_big = byte_buffer.asFloatBuffer();
this.long_buffer_big = byte_buffer.asLongBuffer();
this.double_buffer_big = byte_buffer.asDoubleBuffer();
this.byte_buffer.order(ByteOrder.LITTLE_ENDIAN);
this.short_buffer_little = byte_buffer.asShortBuffer();
this.int_buffer_little = byte_buffer.asIntBuffer();
this.float_buffer_little = byte_buffer.asFloatBuffer();
this.long_buffer_little = byte_buffer.asLongBuffer();
this.double_buffer_little = byte_buffer.asDoubleBuffer();
}
}
}

View file

@ -550,9 +550,9 @@ public class PointerBuffer implements Comparable {
*/
public static void put(final ByteBuffer target, int index, long l) {
if ( is64Bit )
target.putLong(index, l);
target.putLong(index * 8, l);
else
target.putInt(index, (int)l);
target.putInt(index * 4, (int)l);
}
// -- Bulk get operations --

View file

@ -54,7 +54,7 @@ public final class Sys {
private static final String JNI_LIBRARY_NAME = "lwjgl";
/** Current version of library */
private static final String VERSION = "2.9.4";
private static final String VERSION = "2.8.1";
private static final String POSTFIX64BIT = "64";
@ -67,7 +67,8 @@ public final class Sys {
public Object run() {
String library_path = System.getProperty("org.lwjgl.librarypath");
if (library_path != null) {
System.load(library_path + File.separator + LWJGLUtil.mapLibraryName(lib_name));
System.load(library_path + File.separator +
System.mapLibraryName(lib_name));
} else {
System.loadLibrary(lib_name);
}
@ -79,15 +80,13 @@ public final class Sys {
private static void loadLibrary(final String lib_name) {
// actively try to load 64bit libs on 64bit architectures first
String osArch = System.getProperty("os.arch");
boolean try64First = LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_MACOSX && ("amd64".equals(osArch) || "x86_64".equals(osArch));
Error err = null;
if ( try64First ) {
boolean is64bit = "amd64".equals(osArch) || "x86_64".equals(osArch);
if(is64bit) {
try {
doLoadLibrary(lib_name + POSTFIX64BIT);
return;
} catch (UnsatisfiedLinkError e) {
err = e;
LWJGLUtil.log("Failed to load 64 bit library: " + e.getMessage());
}
}
@ -95,9 +94,6 @@ public final class Sys {
try {
doLoadLibrary(lib_name);
} catch (UnsatisfiedLinkError e) {
if ( try64First )
throw err;
if (implementation.has64Bit()) {
try {
doLoadLibrary(lib_name + POSTFIX64BIT);
@ -106,7 +102,6 @@ public final class Sys {
LWJGLUtil.log("Failed to load 64 bit library: " + e2.getMessage());
}
}
// Throw original error
throw e;
}

View file

@ -46,7 +46,7 @@ import org.lwjgl.opengl.Display;
* $Id$
*/
final class WindowsSysImplementation extends DefaultSysImplementation {
private static final int JNI_VERSION = 24;
private static final int JNI_VERSION = 23;
static {
Sys.initialize();

View file

@ -270,21 +270,4 @@ public interface Controller {
* @param zone The dead zone to use for the RZ axis
*/
void setRZAxisDeadZone(float zone);
/** Returns the number of rumblers this controller supports */
int getRumblerCount();
/** Returns the name of the specified rumbler
*
* @param index The rumbler index
*/
String getRumblerName(int index);
/** Sets the vibration strength of the specified rumbler
*
* @param index The index of the rumbler
* @param strength The strength to vibrate at
*/
void setRumblerStrength(int index, float strength);
}

View file

@ -52,18 +52,12 @@ class ControllerEvent {
private int index;
/** Type of control that generated the event */
private int type;
/** True when a button is pressed, if this event was caused by the button */
private boolean buttonState;
/** True if this event was caused by the x axis */
private boolean xaxis;
/** True if this event was caused by the y axis */
private boolean yaxis;
/** The time stamp of this event */
private long timeStamp;
/** The value on a specified axis, if this event was caused by the x-axis */
private float xaxisValue;
/** The value on a specified axis, if this event was caused by the y-axis */
private float yaxisValue;
/**
* Create a new event
@ -76,32 +70,12 @@ class ControllerEvent {
* @param yaxis True if this event was caused by the y-axis
*/
ControllerEvent(Controller source,long timeStamp, int type,int index,boolean xaxis,boolean yaxis) {
this(source, timeStamp, type, index, false, xaxis, yaxis, 0, 0);
}
/**
* Create a new event
*
* @param source The source of the event
* @param timeStamp The time stamp given for this event
* @param type The type of control generating this event
* @param index The index of the input that generated the event
* @param buttonState True when a button is pressed, if this event was caused by the button
* @param xaxis True if this event was caused by the x-axis
* @param yaxis True if this event was caused by the y-axis
* @param xaxisValue The value on a specified axis, if this event was caused by the x-axis
* @param yaxisValue The value on a specified axis, if this event was caused by the y-axis
*/
ControllerEvent(Controller source,long timeStamp, int type,int index,boolean buttonState,boolean xaxis,boolean yaxis,float xaxisValue,float yaxisValue) {
this.source = source;
this.timeStamp = timeStamp;
this.type = type;
this.index = index;
this.buttonState = buttonState;
this.xaxis = xaxis;
this.yaxis = yaxis;
this.xaxisValue = xaxisValue;
this.yaxisValue = yaxisValue;
}
/**
@ -141,15 +115,6 @@ class ControllerEvent {
return type == BUTTON;
}
/**
* Check the button is pressed or not, when this event was caused
*
* @return True when a button is pressed, if this event was caused by the button
*/
public boolean getButtonState() {
return buttonState;
}
/**
* Check if this event was generated by a axis
*
@ -194,24 +159,6 @@ class ControllerEvent {
public boolean isYAxis() {
return yaxis;
}
/**
* Get the value on an X axis when this event was caused
*
* @return The value on a specified axis, if this event was caused by the x-axis
*/
public float getXAxisValue() {
return xaxisValue;
}
/**
* Get the value on an Y axis when this event was caused
*
* @return The value on a specified axis, if this event was caused by the y-axis
*/
public float getYAxisValue() {
return yaxisValue;
}
/*
* @see java.lang.Object#toString()

View file

@ -262,39 +262,12 @@ public class Controllers {
/**
* Get the timestamp assigned to the current event
*
* @return The timestamp assigned to the current event
* @return The timestamp assigned ot the current event
*/
public static long getEventNanoseconds() {
return event.getTimeStamp();
}
/**
* Gets the state of the button that generated the current event
*
* @return True if button was down, or false if released
*/
public static boolean getEventButtonState() {
return event.getButtonState();
}
/**
* Get the value on an X axis of the current event
*
* @return The value on a x axis of the current event
*/
public static float getEventXAxisValue() {
return event.getXAxisValue();
}
/**
* Get the value on an Y axis of the current event
*
* @return The value on a y axis of the current event
*/
public static float getEventYAxisValue() {
return event.getYAxisValue();
}
/**
* Add an event to the stack of events that have been caused
*

View file

@ -33,10 +33,10 @@ package org.lwjgl.input;
import java.nio.IntBuffer;
import org.lwjgl.BufferChecks;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.NondirectBufferWrapper;
import org.lwjgl.Sys;
/**
@ -86,9 +86,9 @@ public class Cursor {
synchronized (OpenGLPackageAccess.global_lock) {
if ((getCapabilities() & CURSOR_ONE_BIT_TRANSPARENCY) == 0)
throw new LWJGLException("Native cursors not supported");
BufferChecks.checkBufferSize(images, width*height*numImages);
images = NondirectBufferWrapper.wrapBuffer(images, width*height*numImages);
if (delays != null)
BufferChecks.checkBufferSize(delays, numImages);
delays = NondirectBufferWrapper.wrapBuffer(delays, numImages);
if (!Mouse.isCreated())
throw new IllegalStateException("Mouse must be created before creating cursor objects");
if (width*height*numImages > images.remaining())
@ -163,32 +163,17 @@ public class Cursor {
IntBuffer images_copy = BufferUtils.createIntBuffer(images.remaining());
flipImages(width, height, numImages, images, images_copy);
// Mac and Windows doesn't (afaik) allow for animation based cursors, except in the .ani
// format on Windows, which we don't support.
// Win32 doesn't (afaik) allow for animation based cursors, except when they're
// in the .ani format, which we don't support.
// The cursor animation was therefor developed using java side time tracking.
// unfortunately X flickers when changing cursor. We therefore check for either
// Windows, Mac or X and do accordingly.
// we might want to split it into a X/Win/Mac cursor if it gets too cluttered
// Win32 or X and do accordingly. This hasn't been implemented on Mac, but we
// might want to split it into a X/Win/Mac cursor if it gets too cluttered
CursorElement[] cursors;
switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_MACOSX:
// OS X requires the image format to be in ABGR format
convertARGBtoABGR(images_copy);
// create our cursor elements
cursors = new CursorElement[numImages];
for(int i=0; i<numImages; i++) {
Object handle = Mouse.getImplementation().createCursor(width, height, xHotspot, yHotspot, 1, images_copy, null);
long delay = (delays != null) ? delays.get(i) : 0;
long timeout = System.currentTimeMillis();
cursors[i] = new CursorElement(handle, delay, timeout);
// offset to next image
images_copy.position(width*height*(i+1));
}
break;
/* Fall through */
case LWJGLUtil.PLATFORM_WINDOWS:
// create our cursor elements
cursors = new CursorElement[numImages];
@ -224,26 +209,6 @@ public class Cursor {
}
return cursors;
}
/**
* Convert an IntBuffer image of ARGB format into ABGR
*
* @param imageBuffer image to convert
*/
private static void convertARGBtoABGR(IntBuffer imageBuffer) {
for (int i = 0; i < imageBuffer.limit(); i++) {
int argbColor = imageBuffer.get(i);
byte alpha = (byte)(argbColor >>> 24);
byte blue = (byte)(argbColor >>> 16);
byte green = (byte)(argbColor >>> 8);
byte red = (byte)argbColor;
int abgrColor = ((alpha & 0xff) << 24 ) + ((red & 0xff) << 16 ) + ((green & 0xff) << 8 ) + ((blue & 0xff) );
imageBuffer.put(i, abgrColor);
}
}
/**
* Flips the images so they're oriented according to opengl

View file

@ -38,7 +38,6 @@ import net.java.games.input.Component.Identifier.Axis;
import net.java.games.input.Component.Identifier.Button;
import net.java.games.input.Event;
import net.java.games.input.EventQueue;
import net.java.games.input.Rumbler;
/**
* A wrapper round a JInput controller that attempts to make the interface
@ -57,8 +56,6 @@ class JInputController implements Controller {
private ArrayList<Component> axes = new ArrayList<Component>();
/** The POVs that have been detected on the JInput controller */
private ArrayList<Component> pov = new ArrayList<Component>();
/** The rumblers exposed by the controller */
private Rumbler[] rumblers;
/** The state of the buttons last check */
private boolean[] buttonState;
/** The values that were read from the pov last check */
@ -89,7 +86,7 @@ class JInputController implements Controller {
* @param index The index this controller has been assigned to
* @param target The target JInput controller this class is wrapping
*/
JInputController(int index, net.java.games.input.Controller target) {
JInputController(int index,net.java.games.input.Controller target) {
this.target = target;
this.index = index;
@ -151,8 +148,6 @@ class JInputController implements Controller {
axesMax[i] = 1.0f;
deadZones[i] = 0.05f;
}
rumblers = target.getRumblers();
}
/*
@ -208,8 +203,7 @@ class JInputController implements Controller {
buttonState[buttonIndex] = event.getValue() != 0;
// fire button pressed event
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,
buttonState[buttonIndex],false,false,0,0));
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.BUTTON,buttonIndex,false,false));
}
// handle pov events
@ -233,8 +227,6 @@ class JInputController implements Controller {
Component axis = event.getComponent();
int axisIndex = axes.indexOf(axis);
float value = axis.getPollData();
float xaxisValue = 0;
float yaxisValue = 0;
// fixed dead zone since most axis don't report it :(
if (Math.abs(value) < deadZones[axisIndex]) {
@ -249,17 +241,9 @@ class JInputController implements Controller {
// normalize the value based on maximum value read in the past
value /= axesMax[axisIndex];
if (axisIndex == xaxis) {
xaxisValue = value;
}
if (axisIndex == yaxis) {
yaxisValue = value;
}
// fire event
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,false,
axisIndex == xaxis,axisIndex == yaxis,xaxisValue,yaxisValue));
Controllers.addEvent(new ControllerEvent(this,event.getNanos(),ControllerEvent.AXIS,axisIndex,
axisIndex == xaxis,axisIndex == yaxis));
axesValue[axisIndex] = value;
}
}
@ -522,16 +506,5 @@ class JInputController implements Controller {
return 0;
}
public int getRumblerCount() {
return rumblers.length;
}
public String getRumblerName(int index) {
return rumblers[index].getAxisName();
}
public void setRumblerStrength(int index, float strength) {
rumblers[index].rumble(strength);
}
}

View file

@ -33,7 +33,6 @@ package org.lwjgl.input;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
@ -159,11 +158,7 @@ public class Keyboard {
public static final int KEY_F13 = 0x64; /* (NEC PC98) */
public static final int KEY_F14 = 0x65; /* (NEC PC98) */
public static final int KEY_F15 = 0x66; /* (NEC PC98) */
public static final int KEY_F16 = 0x67; /* Extended Function keys - (Mac) */
public static final int KEY_F17 = 0x68;
public static final int KEY_F18 = 0x69;
public static final int KEY_KANA = 0x70; /* (Japanese keyboard) */
public static final int KEY_F19 = 0x71; /* Extended Function keys - (Mac) */
public static final int KEY_CONVERT = 0x79; /* (Japanese keyboard) */
public static final int KEY_NOCONVERT = 0x7B; /* (Japanese keyboard) */
public static final int KEY_YEN = 0x7D; /* (Japanese keyboard) */
@ -178,12 +173,10 @@ public class Keyboard {
public static final int KEY_UNLABELED = 0x97; /* (J3100) */
public static final int KEY_NUMPADENTER = 0x9C; /* Enter on numeric keypad */
public static final int KEY_RCONTROL = 0x9D;
public static final int KEY_SECTION = 0xA7; /* Section symbol (Mac) */
public static final int KEY_NUMPADCOMMA = 0xB3; /* , on numeric keypad (NEC PC98) */
public static final int KEY_DIVIDE = 0xB5; /* / on numeric keypad */
public static final int KEY_SYSRQ = 0xB7;
public static final int KEY_RMENU = 0xB8; /* right Alt */
public static final int KEY_FUNCTION = 0xC4; /* Function (Mac) */
public static final int KEY_PAUSE = 0xC5; /* Pause */
public static final int KEY_HOME = 0xC7; /* Home on arrow keypad */
public static final int KEY_UP = 0xC8; /* UpArrow on arrow keypad */
@ -195,8 +188,7 @@ public class Keyboard {
public static final int KEY_NEXT = 0xD1; /* PgDn on arrow keypad */
public static final int KEY_INSERT = 0xD2; /* Insert on arrow keypad */
public static final int KEY_DELETE = 0xD3; /* Delete on arrow keypad */
public static final int KEY_CLEAR = 0xDA; /* Clear key (Mac) */
public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
public static final int KEY_LMETA = 0xDB; /* Left Windows/Option key */
/**
* The left windows key, mapped to KEY_LMETA
*
@ -224,7 +216,7 @@ public class Keyboard {
private static final int BUFFER_SIZE = 50;
/** Key names */
private static final String[] keyName = new String[KEYBOARD_SIZE];
private static final String[] keyName = new String[255];
private static final Map<String, Integer> keyMap = new HashMap<String, Integer>(253);
private static int counter;
@ -237,8 +229,7 @@ public class Keyboard {
&& Modifier.isPublic(field.getModifiers())
&& Modifier.isFinal(field.getModifiers())
&& field.getType().equals(int.class)
&& field.getName().startsWith("KEY_")
&& !field.getName().endsWith("WIN") ) { /* Don't use deprecated names */
&& field.getName().startsWith("KEY_") ) {
int key = field.getInt(null);
String name = field.getName().substring(4);
@ -332,7 +323,7 @@ public class Keyboard {
}
private static void reset() {
((Buffer)readBuffer).limit(0);
readBuffer.limit(0);
for (int i = 0; i < keyDownBuffer.remaining(); i++)
keyDownBuffer.put(i, (byte)0);
current_event.reset();
@ -393,7 +384,7 @@ public class Keyboard {
private static void read() {
readBuffer.compact();
implementation.readKeyboard(readBuffer);
((Buffer)readBuffer).flip();
readBuffer.flip();
}
/**
@ -454,7 +445,7 @@ public class Keyboard {
int num_events = 0;
while (readNext(tmp_event) && (!tmp_event.repeat || repeat_enabled))
num_events++;
((Buffer)readBuffer).position(old_position);
readBuffer.position(old_position);
return num_events;
}
}

View file

@ -31,7 +31,6 @@
*/
package org.lwjgl.input;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.security.AccessController;
@ -78,12 +77,6 @@ public class Mouse {
/** Mouse absolute Y position in pixels */
private static int y;
/** Mouse absolute X position in pixels without any clipping */
private static int absolute_x;
/** Mouse absolute Y position in pixels without any clipping */
private static int absolute_y;
/** Buffer to hold the deltas dx, dy and dwheel */
private static IntBuffer coord_buffer;
@ -250,7 +243,7 @@ public class Mouse {
private static void resetMouse() {
dx = dy = dwheel = 0;
((Buffer)readBuffer).position(readBuffer.limit());
readBuffer.position(readBuffer.limit());
}
static InputImplementation getImplementation() {
@ -280,7 +273,7 @@ public class Mouse {
if (currentCursor != null && implementation.getNativeCursorCapabilities() != 0)
setNativeCursor(currentCursor);
readBuffer = ByteBuffer.allocate(EVENT_SIZE * BUFFER_SIZE);
((Buffer)readBuffer).limit(0);
readBuffer.limit(0);
setGrabbed(isGrabbed);
}
@ -362,21 +355,17 @@ public class Mouse {
dy += poll_coord2;
x += poll_coord1;
y += poll_coord2;
absolute_x += poll_coord1;
absolute_y += poll_coord2;
} else {
dx = poll_coord1 - absolute_x;
dy = poll_coord2 - absolute_y;
absolute_x = x = poll_coord1;
absolute_y = y = poll_coord2;
dx = poll_coord1 - x;
dy = poll_coord2 - y;
x = poll_coord1;
y = poll_coord2;
}
if(clipMouseCoordinatesToWindow) {
x = Math.min(Display.getWidth() - 1, Math.max(0, x));
y = Math.min(Display.getHeight() - 1, Math.max(0, y));
}
dwheel += poll_dwheel;
if(clipMouseCoordinatesToWindow) {
x = Math.min(Display.getWidth() - 1, Math.max(0, x));
y = Math.min(Display.getHeight() - 1, Math.max(0, y));
}
dwheel += poll_dwheel;
read();
}
}
@ -384,7 +373,7 @@ public class Mouse {
private static void read() {
readBuffer.compact();
implementation.readMouse(readBuffer);
((Buffer)readBuffer).flip();
readBuffer.flip();
}
/**
@ -434,8 +423,8 @@ public class Mouse {
/**
* Gets the next mouse event. You can query which button caused the event by using
* <code>getEventButton()</code> (if any). To get the state of that key, for that event, use
* <code>getEventButtonState</code>. To get the current mouse delta values use <code>getEventDX()</code>
* and <code>getEventDY()</code>.
* <code>getEventButtonState</code>. To get the current mouse delta values use <code>getEventDX()</code>,
* <code>getEventDY()</code> and <code>getEventDZ()</code>.
* @see org.lwjgl.input.Mouse#getEventButton()
* @see org.lwjgl.input.Mouse#getEventButtonState()
* @return true if a mouse event was read, false otherwise

View file

@ -115,13 +115,8 @@ public final class AL {
String[] library_names;
switch (LWJGLUtil.getPlatform()) {
case LWJGLUtil.PLATFORM_WINDOWS:
if ( Sys.is64Bit() ) {
libname = "OpenAL64";
library_names = new String[]{"OpenAL64.dll"};
} else {
libname = "OpenAL32";
library_names = new String[]{"OpenAL32.dll"};
}
libname = "OpenAL32";
library_names = new String[]{"OpenAL64.dll", "OpenAL32.dll"};
break;
case LWJGLUtil.PLATFORM_LINUX:
libname = "openal";

View file

@ -152,11 +152,12 @@ public final class ALC10 {
* @return String property from device
*/
public static String alcGetString(ALCdevice device, int pname) {
ByteBuffer buffer = nalcGetString(getDevice(device), pname);
String result;
result = nalcGetString(getDevice(device), pname);
Util.checkALCError(device);
return MemoryUtil.decodeUTF8(buffer);
return result;
}
static native ByteBuffer nalcGetString(long device, int pname);
static native String nalcGetString(long device, int pname);
/**
* The application can query ALC for information using an integer query function.
@ -198,7 +199,7 @@ public final class ALC10 {
* @return opened device, or null
*/
public static ALCdevice alcOpenDevice(String devicename) {
ByteBuffer buffer = MemoryUtil.encodeUTF8(devicename);
ByteBuffer buffer = MemoryUtil.encodeASCII(devicename);
long device_address = nalcOpenDevice(MemoryUtil.getAddressSafe(buffer));
if(device_address != 0) {
ALCdevice device = new ALCdevice(device_address);

View file

@ -31,7 +31,6 @@
*/
package org.lwjgl.openal;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
@ -94,7 +93,7 @@ public final class ALC11 {
*/
public static ALCdevice alcCaptureOpenDevice(String devicename, int frequency, int format, int buffersize) {
ByteBuffer buffer = MemoryUtil.encodeASCII(devicename);
long device_address = nalcCaptureOpenDevice(MemoryUtil.getAddressSafe(buffer), frequency, format, buffersize);
long device_address = nalcCaptureOpenDevice(MemoryUtil.getAddress(buffer), frequency, format, buffersize);
if(device_address != 0) {
ALCdevice device = new ALCdevice(device_address);
synchronized (ALC10.devices) {
@ -178,7 +177,7 @@ public final class ALC11 {
try {
IntBuffer ib = BufferUtils.createIntBuffer(2);
ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MAJOR_VERSION, ib);
((Buffer)ib).position(1);
ib.position(1);
ALC10.alcGetInteger(AL.getDevice(), ALC10.ALC_MINOR_VERSION, ib);
int major = ib.get(0);

View file

@ -82,7 +82,7 @@ public final class ALCcontext {
* @param contextFrequency Frequency to add
* @param contextRefresh Refresh rate to add
* @param contextSynchronized Whether to synchronize the context
* @return attribute list
* @return
*/
static IntBuffer createAttributeList(int contextFrequency, int contextRefresh, int contextSynchronized) {
IntBuffer attribList = BufferUtils.createIntBuffer(7);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2011 LWJGL Project
* Copyright (c) 2002-2010 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -31,6 +31,8 @@
*/
package org.lwjgl.opencl;
import org.lwjgl.PointerWrapperAbstract;
/**
* Instances of this class can be used to receive OpenCL program build notifications.
* A single CLBuildProgramCallback instance should only be used with programs created
@ -38,6 +40,37 @@ package org.lwjgl.opencl;
*
* @author Spasi
*/
public abstract class CLBuildProgramCallback extends CLProgramCallback {
public abstract class CLBuildProgramCallback extends PointerWrapperAbstract {
private CLContext context;
protected CLBuildProgramCallback() {
super(CallbackUtil.getBuildProgramCallback());
}
/**
* Sets the context that contains the CLPrograms to which we're registered.
*
* @param context the CLContext object
*/
void setContext(final CLContext context) {
this.context = context;
}
/**
* Called from native code.
*
* @param program_address the CLProgram object pointer
*/
private void handleMessage(long program_address) {
handleMessage(context.getCLProgram(program_address));
}
/**
* The callback method.
*
* @param program the CLProgram object that was built
*/
protected abstract void handleMessage(CLProgram program);
}

View file

@ -31,11 +31,9 @@
*/
package org.lwjgl.opencl;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.PointerBuffer;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import static org.lwjgl.opencl.CL10.*;
@ -55,23 +53,23 @@ final class CLChecks {
/**
* Calculates the number of bytes in the specified cl_mem buffer rectangle region.
*
* @param offset the host offset
* @param origin the host origin
* @param region the rectangle region
* @param row_pitch the host row pitch
* @param slice_pitch the host slice pitch
*
* @return the region size in bytes
*/
static int calculateBufferRectSize(final PointerBuffer offset, final PointerBuffer region, long row_pitch, long slice_pitch) {
static int calculateBufferRectSize(final PointerBuffer origin, final PointerBuffer region, long row_pitch, long slice_pitch) {
if ( !LWJGLUtil.CHECKS )
return 0;
final long x = offset.get(0);
final long y = offset.get(1);
final long z = offset.get(2);
final long x = origin.get(0);
final long y = origin.get(1);
final long z = origin.get(2);
if ( LWJGLUtil.DEBUG && (x < 0 || y < 0 || z < 0) )
throw new IllegalArgumentException("Invalid cl_mem host offset: " + x + ", " + y + ", " + z);
throw new IllegalArgumentException("Invalid cl_mem host origin: " + x + ", " + y + ", " + z);
final long w = region.get(0);
final long h = region.get(1);
@ -139,7 +137,7 @@ final class CLChecks {
*
* @return the 2D image size in bytes
*/
static int calculateImage2DSize(final Buffer host_ptr, final ByteBuffer format, final long w, final long h, long row_pitch) {
static int calculateImage2DSize(final ByteBuffer format, final long w, final long h, long row_pitch) {
if ( !LWJGLUtil.CHECKS )
return 0;
@ -153,7 +151,7 @@ final class CLChecks {
else if ( LWJGLUtil.DEBUG && ((row_pitch < w * elementSize) || (row_pitch % elementSize != 0)) )
throw new IllegalArgumentException("Invalid image_row_pitch specified: " + row_pitch);
return (int)(row_pitch * h) >> BufferUtils.getElementSizeExponent(host_ptr);
return (int)(row_pitch * h);
}
/**
@ -168,7 +166,7 @@ final class CLChecks {
*
* @return the 3D image size in bytes
*/
static int calculateImage3DSize(final Buffer host_ptr, final ByteBuffer format, final long w, final long h, final long d, long row_pitch, long slice_pitch) {
static int calculateImage3DSize(final ByteBuffer format, final long w, final long h, final long d, long row_pitch, long slice_pitch) {
if ( !LWJGLUtil.CHECKS )
return 0;
@ -187,7 +185,7 @@ final class CLChecks {
else if ( LWJGLUtil.DEBUG && ((row_pitch < row_pitch * h) || (slice_pitch % row_pitch != 0)) )
throw new IllegalArgumentException("Invalid image_slice_pitch specified: " + row_pitch);
return (int)(slice_pitch * d) >> BufferUtils.getElementSizeExponent(host_ptr);
return (int)(slice_pitch * d);
}
/**

View file

@ -1,43 +0,0 @@
/*
* Copyright (c) 2002-2011 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opencl;
/**
* Instances of this class can be used to receive OpenCL program compilation notifications.
* A single CLCompileProgramCallback instance should only be used with programs created
* in the same CLContext.
*
* @author Spasi
*/
public abstract class CLCompileProgramCallback extends CLProgramCallback {
}

View file

@ -49,14 +49,10 @@ public final class CLContext extends CLObjectChild<CLPlatform> {
private static final CLContextUtil util = (CLContextUtil)CLPlatform.getInfoUtilInstance(CLContext.class, "CL_CONTEXT_UTIL");
private final CLObjectRegistry<CLCommandQueue> clCommandQueues;
private final CLObjectRegistry<CLMem> clMems;
private final CLObjectRegistry<CLSampler> clSamplers;
private final CLObjectRegistry<CLProgram> clPrograms;
private final CLObjectRegistry<CLEvent> clEvents;
private long
contextCallback,
printfCallback;
private final CLObjectRegistry<CLMem> clMems;
private final CLObjectRegistry<CLSampler> clSamplers;
private final CLObjectRegistry<CLProgram> clPrograms;
private final CLObjectRegistry<CLEvent> clEvents;
CLContext(final long pointer, final CLPlatform platform) {
super(pointer, platform);
@ -273,50 +269,4 @@ public final class CLContext extends CLObjectChild<CLPlatform> {
CLObjectRegistry<CLEvent> getCLEventRegistry() { return clEvents; }
private boolean checkCallback(final long callback, final int result) {
if ( result == 0 && (callback == 0 || isValid()) )
return true;
if ( callback != 0 )
CallbackUtil.deleteGlobalRef(callback);
return false;
}
/**
* Associates this context with the specified context callback reference. If the context
* is invalid, the callback reference is deleted. NO-OP if user_data is 0.
*
* @param callback the context callback pointer
*/
void setContextCallback(final long callback) {
if ( checkCallback(callback, 0) )
this.contextCallback = callback;
}
/**
* Associates this context with the specified printf callback reference. If the context
* is invalid, the callback reference is deleted. NO-OP if user_data is 0.
*
* @param callback the printf callback pointer
*/
void setPrintfCallback(final long callback, final int result) {
if ( checkCallback(callback, result) )
this.printfCallback = callback;
}
/**
* Decrements the context's reference count. If the reference
* count hits zero, it also deletes
* any callback objects associated with it.
*/
void releaseImpl() {
if ( release() > 0 )
return;
if ( contextCallback != 0 )
CallbackUtil.deleteGlobalRef(contextCallback);
if ( printfCallback != 0 )
CallbackUtil.deleteGlobalRef(printfCallback);
}
}

View file

@ -1,43 +0,0 @@
/*
* Copyright (c) 2002-2011 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opencl;
/**
* Instances of this class can be used to receive OpenCL program linkage notifications.
* A single CLLinkProgramCallback instance should only be used with programs created
* in the same CLContext.
*
* @author Spasi
*/
public abstract class CLLinkProgramCallback extends CLProgramCallback {
}

View file

@ -1,51 +0,0 @@
/*
* Copyright (c) 2002-2011 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opencl;
import org.lwjgl.PointerWrapperAbstract;
/**
* Instances of this class can be used to receive OpenCL printf messages.
* Different CLContexts should use different CLPrintfCallback instances.
*
* @author Spasi
*/
public abstract class CLPrintfCallback extends PointerWrapperAbstract {
protected CLPrintfCallback() {
super(CallbackUtil.getPrintfCallback());
}
/** The callback method. */
protected abstract void handleMessage(String data);
}

View file

@ -1,74 +0,0 @@
/*
* Copyright (c) 2002-2011 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opencl;
import org.lwjgl.PointerWrapperAbstract;
/**
* Base class for OpenCL program action notifications.
*
* @author Spasi
*/
abstract class CLProgramCallback extends PointerWrapperAbstract {
private CLContext context;
protected CLProgramCallback() {
super(CallbackUtil.getProgramCallback());
}
/**
* Sets the context that contains the CLPrograms to which we're registered.
*
* @param context the CLContext object
*/
final void setContext(final CLContext context) {
this.context = context;
}
/**
* Called from native code.
*
* @param program_address the CLProgram object pointer
*/
private void handleMessage(long program_address) {
handleMessage(context.getCLProgram(program_address));
}
/**
* The callback method.
*
* @param program the CLProgram object affected
*/
protected abstract void handleMessage(CLProgram program);
}

View file

@ -70,7 +70,7 @@ final class CallbackUtil {
*
* @param ref the GlobalRef memory address.
*/
static native void deleteGlobalRef(long ref);
private static native void deleteGlobalRef(long ref);
/**
* Deletes the global reference represented by user_data if an OpenCL error occured.
@ -99,6 +99,40 @@ final class CallbackUtil {
*/
static native long getContextCallback();
/**
* Associates the specified CLContext with the specified global reference. If the context
* is invalid, the global reference is deleted. NO-OP if user_data is 0.
*
* @param context the CLContext to register
* @param user_data the global reference pointer
*/
static void registerCallback(final CLContext context, final long user_data) {
if ( user_data == 0 )
return;
if ( context.isValid() )
contextUserData.put(context, user_data);
else
deleteGlobalRef(user_data);
}
/**
* Decrements the specified context's reference count, clears its association
* with a CLContextCallback object if it exists and deletes the corresponding
* global reference.
*
* @param context the CLContext to unregister
*/
static void unregisterCallback(final CLContext context) {
if ( context.release() > 0 )
return;
final Long user_data = contextUserData.remove(context);
if ( user_data != null )
deleteGlobalRef(user_data);
}
/* [ Other callback functionality ]
The other callbacks are simpler. We create the GlobalRef before passing the callback,
we delete it when we receive the callback call.
@ -116,7 +150,7 @@ final class CallbackUtil {
*
* @return the callback function address
*/
static native long getProgramCallback();
static native long getBuildProgramCallback();
/**
* Returns the memory address of the native function we pass to clEnqueueNativeKernel.
@ -132,13 +166,6 @@ final class CallbackUtil {
*/
static native long getEventCallback();
/**
* Returns the memory address of the native function we pass to clSetPrintfCallback.
*
* @return the callback function address
*/
static native long getPrintfCallback();
/**
* Returns the memory address of the native function we pass to clCreateContext(FromType),
* when <code>APPLEContextLoggingUtil.SYSTEM_LOG_CALLBACK</code> is used.

View file

@ -123,7 +123,7 @@ final class InfoUtilFactory {
Util.checkCLError(errcode_ret.get(0));
return __result;
} finally {
if ( __result != null ) __result.setContextCallback(user_data);
CallbackUtil.registerCallback(__result, user_data);
}
}
@ -305,7 +305,7 @@ final class InfoUtilFactory {
errcode_ret = APIUtil.getBufferInt();
CLMem __result = new CLMem(nclCreateImage2D(context.getPointer(), flags, MemoryUtil.getAddress(formatBuffer, 0), image_width, image_height, image_row_pitch, MemoryUtil.getAddress0Safe(host_ptr) +
(host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(host_ptr, formatBuffer, image_width, image_height, image_row_pitch)) : 0),
(host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage2DSize(formatBuffer, image_width, image_height, image_row_pitch)) : 0),
MemoryUtil.getAddressSafe(errcode_ret), function_pointer), context);
if ( LWJGLUtil.DEBUG )
Util.checkCLError(errcode_ret.get(0));
@ -325,7 +325,7 @@ final class InfoUtilFactory {
errcode_ret = APIUtil.getBufferInt();
CLMem __result = new CLMem(nclCreateImage3D(context.getPointer(), flags, MemoryUtil.getAddress(formatBuffer, 0), image_width, image_height, image_depth, image_row_pitch, image_slice_pitch, MemoryUtil.getAddress0Safe(host_ptr) +
(host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(host_ptr, formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0),
(host_ptr != null ? BufferChecks.checkBuffer(host_ptr, CLChecks.calculateImage3DSize(formatBuffer, image_width, image_height, image_depth, image_row_pitch, image_slice_pitch)) : 0),
MemoryUtil.getAddressSafe(errcode_ret), function_pointer), context);
if ( LWJGLUtil.DEBUG )
Util.checkCLError(errcode_ret.get(0));
@ -547,7 +547,7 @@ final class InfoUtilFactory {
target = new ByteBuffer[sizes.remaining()];
for ( int i = 0; i < sizes.remaining(); i++ )
target[i] = BufferUtils.createByteBuffer((int)sizes.get(i));
target[i] = BufferUtils.createByteBuffer((int)sizes.get(0));
} else if ( LWJGLUtil.DEBUG ) {
final PointerBuffer sizes = getSizesBuffer(program, CL_PROGRAM_BINARY_SIZES);
@ -603,4 +603,4 @@ final class InfoUtilFactory {
}
};
}
}

View file

@ -110,7 +110,7 @@ public final class AMDDebugOutputCallback extends PointerWrapperAbstract {
description = "OTHER";
break;
default:
description = printUnknownToken(category);
description = "Unknown (" + Integer.toHexString(category) + ")";
}
System.err.println("\tCategory: " + description);
@ -125,16 +125,12 @@ public final class AMDDebugOutputCallback extends PointerWrapperAbstract {
description = "LOW";
break;
default:
description = printUnknownToken(severity);
description = "Unknown (" + Integer.toHexString(category) + ")";
}
System.err.println("\tSeverity: " + description);
System.err.println("\tMessage: " + message);
}
private String printUnknownToken(final int token) {
return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
}
});
}

View file

@ -97,7 +97,7 @@ final class APIUtil {
buffer = BufferUtils.createByteBuffer(size);
caps.util.buffer = buffer;
} else
((Buffer)buffer).clear();
buffer.clear();
return buffer;
}
@ -114,8 +114,8 @@ final class APIUtil {
bufferNew.put(buffer);
caps.util.buffer = (buffer = bufferNew);
} else {
((Buffer)buffer).position(buffer.limit());
((Buffer)buffer).limit(buffer.capacity());
buffer.position(buffer.limit());
buffer.limit(buffer.capacity());
}
return buffer;
@ -193,7 +193,7 @@ final class APIUtil {
*/
static long getBuffer(final ContextCapabilities caps, final CharSequence string) {
final ByteBuffer buffer = encode(getBufferByte(caps, string.length()), string);
((Buffer)buffer).flip();
buffer.flip();
return MemoryUtil.getAddress0(buffer);
}
@ -206,7 +206,7 @@ final class APIUtil {
*/
static long getBuffer(final ContextCapabilities caps, final CharSequence string, final int offset) {
final ByteBuffer buffer = encode(getBufferByteOffset(caps, offset + string.length()), string);
((Buffer)buffer).flip();
buffer.flip();
return MemoryUtil.getAddress(buffer);
}
@ -220,7 +220,7 @@ final class APIUtil {
static long getBufferNT(final ContextCapabilities caps, final CharSequence string) {
final ByteBuffer buffer = encode(getBufferByte(caps, string.length() + 1), string);
buffer.put((byte)0);
((Buffer)buffer).flip();
buffer.flip();
return MemoryUtil.getAddress0(buffer);
}
@ -245,7 +245,7 @@ final class APIUtil {
for ( CharSequence string : strings )
encode(buffer, string);
((Buffer)buffer).flip();
buffer.flip();
return MemoryUtil.getAddress0(buffer);
}
@ -264,7 +264,7 @@ final class APIUtil {
buffer.put((byte)0);
}
((Buffer)buffer).flip();
buffer.flip();
return MemoryUtil.getAddress0(buffer);
}
@ -281,7 +281,7 @@ final class APIUtil {
for ( CharSequence string : strings )
buffer.put(string.length());
((Buffer)buffer).flip();
buffer.flip();
return MemoryUtil.getAddress0(buffer);
}
@ -293,4 +293,4 @@ final class APIUtil {
return MemoryUtil.getAddress0(getBufferByte(caps, 0));
}
}
}

View file

@ -113,7 +113,7 @@ public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
description = "OTHER";
break;
default:
description = printUnknownToken(source);
description = "Unknown (" + Integer.toHexString(source) + ")";
}
System.err.println("\tSource: " + description);
@ -137,7 +137,7 @@ public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
description = "OTHER";
break;
default:
description = printUnknownToken(type);
description = "Unknown (" + Integer.toHexString(source) + ")";
}
System.err.println("\tType: " + description);
@ -152,16 +152,12 @@ public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
description = "LOW";
break;
default:
description = printUnknownToken(severity);
description = "Unknown (" + Integer.toHexString(source) + ")";
}
System.err.println("\tSeverity: " + description);
System.err.println("\tMessage: " + message);
}
private String printUnknownToken(final int token) {
return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
}
});
}
@ -188,9 +184,9 @@ public final class ARBDebugOutputCallback extends PointerWrapperAbstract {
/**
* This method will be called when an ARB_debug_output message is generated.
*
* @param id the message ID
* @param source the message source
* @param type the message type
* @param id the message ID
* @param severity the message severity
* @param message the string representation of the message.
*/

View file

@ -32,8 +32,6 @@
package org.lwjgl.opengl;
import java.awt.Canvas;
import java.awt.Component;
import java.applet.Applet;
import java.nio.ByteBuffer;
import java.security.AccessController;
import java.security.PrivilegedActionException;
@ -82,13 +80,16 @@ final class AWTSurfaceLock {
// It is only needed on first call, so we avoid it on all subsequent calls
// due to performance..
// Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
if (firstLockSucceeded)
return lockAndInitHandle(lock_buffer, component);
return lockAndInitHandle(lock_buffer, component, allowCALayer);
else
try {
firstLockSucceeded = AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
public Boolean run() throws LWJGLException {
return lockAndInitHandle(lock_buffer, component);
return lockAndInitHandle(lock_buffer, component, allowCALayer);
}
});
return firstLockSucceeded;
@ -97,7 +98,7 @@ final class AWTSurfaceLock {
}
}
private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component) throws LWJGLException;
private static native boolean lockAndInitHandle(ByteBuffer lock_buffer, Canvas component, boolean allowCALayer) throws LWJGLException;
void unlock() throws LWJGLException {
nUnlock(lock_buffer);

View file

@ -42,11 +42,9 @@ import java.util.Map;
final class CallbackUtil {
/** Context -> Long */
private static final Map<ContextCapabilities, Long> contextUserParamsARB = new HashMap<ContextCapabilities, Long>();
private static final Map<ContextGL, Long> contextUserParamsARB = new HashMap<ContextGL, Long>();
/** Context -> Long */
private static final Map<ContextCapabilities, Long> contextUserParamsAMD = new HashMap<ContextCapabilities, Long>();
/** Context -> Long */
private static final Map<ContextCapabilities, Long> contextUserParamsKHR = new HashMap<ContextCapabilities, Long>();
private static final Map<ContextGL, Long> contextUserParamsAMD = new HashMap<ContextGL, Long>();
private CallbackUtil() {}
@ -86,19 +84,19 @@ final class CallbackUtil {
*
* @param userParam the global reference pointer
*/
private static void registerContextCallback(final long userParam, final Map<ContextCapabilities, Long> contextUserData) {
ContextCapabilities caps = GLContext.getCapabilities();
if ( caps == null ) {
private static void registerContextCallback(final long userParam, final Map<ContextGL, Long> contextUserData) {
ContextGL context = ContextGL.getCurrentContext();
if ( context == null ) {
deleteGlobalRef(userParam);
throw new IllegalStateException("No context is current.");
}
final Long userParam_old = contextUserData.remove(caps);
final Long userParam_old = contextUserData.remove(context);
if ( userParam_old != null )
deleteGlobalRef(userParam_old);
if ( userParam != 0 )
contextUserData.put(caps, userParam);
contextUserData.put(context, userParam);
}
/**
@ -106,19 +104,12 @@ final class CallbackUtil {
*
* @param context the Context to unregister
*/
static void unregisterCallbacks(final Object context) {
// TODO: This is never called for custom contexts. Need to fix for LWJGL 3.0
final ContextCapabilities caps = GLContext.getCapabilities(context);
Long userParam = contextUserParamsARB.remove(caps);
static void unregisterCallbacks(final ContextGL context) {
Long userParam = contextUserParamsARB.remove(context);
if ( userParam != null )
deleteGlobalRef(userParam);
userParam = contextUserParamsAMD.remove(caps);
if ( userParam != null )
deleteGlobalRef(userParam);
userParam = contextUserParamsKHR.remove(caps);
userParam = contextUserParamsAMD.remove(context);
if ( userParam != null )
deleteGlobalRef(userParam);
}
@ -163,24 +154,4 @@ final class CallbackUtil {
registerContextCallback(userParam, contextUserParamsAMD);
}
// --------- [ KHR_debug ] ---------
/**
* Returns the memory address of the native function we pass to glDebugMessageCallback.
*
* @return the callback function address
*/
static native long getDebugCallbackKHR();
/**
* Associates the current OpenGL context with the specified global reference. If there
* is no context current, the global reference is deleted and an exception is thrown.
* Any previous callback registrations will be cleared.
*
* @param userParam the global reference pointer
*/
static void registerContextCallbackKHR(final long userParam) {
registerContextCallback(userParam, contextUserParamsKHR);
}
}

View file

@ -32,6 +32,7 @@
package org.lwjgl.opengl;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengles.PowerManagementEventException;
/**
* @author Spasi

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2014 LWJGL Project
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -35,399 +35,274 @@ import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLUtil;
import java.nio.IntBuffer;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
/**
* This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context extension.
* <p/>
* The attributes supported are described in the following extensions:<br>
* <ul>
* <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context.txt">WGL_ARB_create_context(_profile)</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context.txt">GLX_ARB_create_context(_profile)</a></li>
* <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context_robustness.txt">WGL_ARB_create_context_robustness</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context_robustness.txt">GLX_ARB_create_context_robustness</a></li>
* <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_robustness_isolation.txt">WGL_ARB_robustness_isolation</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_robustness_isolation.txt">GLX_ARB_robustness_isolation</a></li>
* <li><a href="http://www.opengl.org/registry/specs/ARB/wgl_create_context_es2_profile.txt">WGL_EXT_create_context_es2_profile</a> and <a href="http://www.opengl.org/registry/specs/ARB/glx_create_context_es2_profile.txt">GLX_EXT_create_context_es2_profile</a></li>
* <li><a href="http://www.opengl.org/registry/specs/ARB/context_flush_control.txt">KHR_context_flush_control</a></li>
* </ul>
* This class represents the context attributes passed to CreateContextAttribs of the ARB_create_context and
* ARB_create_context_profile extensions.
* These attributes can be used to indicate at context creation which OpenGL interface will be used. This includes the
* OpenGL version, the layer plane on which rendering takes place and also optional debug and forward combatibility modes.
* (read the ARB_create_context spec for details)
* <p/>
* Use of this class is optional. If an OpenGL context is created without passing an instance of this class
* (or ARB_create_context is not supported), the old context creation code will be used. Support for debug and forward
* compatible mobes is not guaranteed by the OpenGL implementation. Developers may encounter debug contexts being the same
* as non-debug contexts or forward compatible contexts having support for deprecated functionality.
* <p/>
* If the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} flag is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0
* specification), even if the driver exposes the corresponding entry points.
* If the forwardCompatible
* attribute is used, LWJGL will not load the deprecated functionality (as defined in the OpenGL 3.0 specification). This
* means that developers can start working on cleaning up their applications without an OpenGL 3.0 complaint driver.
* <p/>
* This extension is not supported on MacOS X. However, in order to enable the GL 3.2 context on MacOS X 10.7 or newer, an instance of this class must be passed
* to LWJGL. The only valid configuration is <code>ContextAttribs(3, 2, CONTEXT_CORE_PROFILE_BIT_ARB)</code>, anything else will be ignored.
* This extension is not supported on MacOS X. However, in order to enable the GL 3.2 context on MacOS X 10.7 or newer, an
* instance of this class must be passed to LWJGL. The only valid configuration is <code>new ContextAttribs(3, 2).withProfileCore()</code>,
* anything else will be ignored.
*
* @author spasi <spasi@users.sourceforge.net>
*/
public final class ContextAttribs {
// ATTRIBUTES
// Same values for GLX & WGL
private static final int CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004;
public static final int CONTEXT_MAJOR_VERSION_ARB = 0x2091;
public static final int CONTEXT_MINOR_VERSION_ARB = 0x2092;
public static final int CONTEXT_PROFILE_MASK_ARB = 0x9126,
CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001,
CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002,
CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004;
public static final int CONTEXT_FLAGS_ARB = 0x2094,
CONTEXT_DEBUG_BIT_ARB = 0x0001,
CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002,
CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004,
CONTEXT_RESET_ISOLATION_BIT_ARB = 0x00000008;
public static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256,
NO_RESET_NOTIFICATION_ARB = 0x8261,
LOSE_CONTEXT_ON_RESET_ARB = 0x8252;
public static final int CONTEXT_RELEASE_BEHABIOR_ARB = 0x2097,
CONTEXT_RELEASE_BEHAVIOR_NONE_ARB = 0x0000,
CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB = 0x2098;
public static final int CONTEXT_LAYER_PLANE_ARB = 0x2093; // WGL-only
// STATE
private static final int CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004;
private static final int CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256;
private static final int
NO_RESET_NOTIFICATION_ARB = 0x8261,
LOSE_CONTEXT_ON_RESET_ARB = 0x8252;
private int majorVersion;
private int minorVersion;
private int profileMask;
private int contextFlags;
private int contextResetNotificationStrategy = NO_RESET_NOTIFICATION_ARB;
private int contextReleaseBehavior = CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB;
private int layerPlane;
// CONSTRUCTORS
private boolean debug;
private boolean forwardCompatible;
private boolean robustAccess;
private boolean profileCore;
private boolean profileCompatibility;
private boolean profileES;
private boolean loseContextOnReset;
/** Creates the default ContextAttribs instance. No special attributes will be used when creating the OpenGL context. */
public ContextAttribs() {
this(1, 0);
}
/** Creates a ContextAttribs instance for the given OpenGL version. */
public ContextAttribs(int majorVersion, int minorVersion) {
this(majorVersion, minorVersion, 0, 0);
}
/**
* Creates a new ContextAttribs instance with the given attributes.
*
* @param majorVersion the major OpenGL version
* @param minorVersion the minor OpenGL version
* @param profileMask the context profile mask. One of:<br>{@link #CONTEXT_CORE_PROFILE_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ES2_PROFILE_BIT_EXT}
*/
public ContextAttribs(int majorVersion, int minorVersion, int profileMask) {
this(majorVersion, minorVersion, 0, profileMask);
}
/**
* Creates a new ContextAttribs instance with the given attributes.
*
* @param majorVersion the major OpenGL version
* @param minorVersion the minor OpenGL version
* @param profileMask the context profile mask. One of:<br>{@link #CONTEXT_CORE_PROFILE_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ES2_PROFILE_BIT_EXT}
* @param contextFlags the context flags, a bitfield value. One or more of:<br>{@link #CONTEXT_DEBUG_BIT_ARB}, {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB}, {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB}, {@link #CONTEXT_RESET_ISOLATION_BIT_ARB}
*/
public ContextAttribs(int majorVersion, int minorVersion, int profileMask, int contextFlags) {
public ContextAttribs(final int majorVersion, final int minorVersion) {
if ( majorVersion < 0 || 4 < majorVersion ||
minorVersion < 0 ||
(majorVersion == 4 && 5 < minorVersion) ||
(majorVersion == 4 && 2 < minorVersion) ||
(majorVersion == 3 && 3 < minorVersion) ||
(majorVersion == 2 && 1 < minorVersion) ||
(majorVersion == 1 && 5 < minorVersion) )
throw new IllegalArgumentException("Invalid OpenGL version specified: " + majorVersion + '.' + minorVersion);
if ( LWJGLUtil.CHECKS ) {
if ( 1 < Integer.bitCount(profileMask) || CONTEXT_ES2_PROFILE_BIT_EXT < profileMask )
throw new IllegalArgumentException("Invalid profile mask specified: " + Integer.toBinaryString(profileMask));
if ( 0xF < contextFlags )
throw new IllegalArgumentException("Invalid context flags specified: " + Integer.toBinaryString(profileMask));
}
this.majorVersion = majorVersion;
this.minorVersion = minorVersion;
this.profileMask = profileMask;
this.contextFlags = contextFlags;
}
// Copy constructor
private ContextAttribs(ContextAttribs other) {
this.majorVersion = other.majorVersion;
this.minorVersion = other.minorVersion;
private ContextAttribs(final ContextAttribs attribs) {
this.majorVersion = attribs.majorVersion;
this.minorVersion = attribs.minorVersion;
this.profileMask = other.profileMask;
this.contextFlags = other.contextFlags;
this.layerPlane = attribs.layerPlane;
this.contextResetNotificationStrategy = other.contextResetNotificationStrategy;
this.contextReleaseBehavior = other.contextReleaseBehavior;
this.debug = attribs.debug;
this.forwardCompatible = attribs.forwardCompatible;
this.robustAccess = attribs.robustAccess;
this.layerPlane = other.layerPlane;
this.profileCore = attribs.profileCore;
this.profileCompatibility = attribs.profileCompatibility;
this.profileES = attribs.profileES;
this.loseContextOnReset = attribs.loseContextOnReset;
}
// GETTERS
/** Returns the {@link #CONTEXT_MAJOR_VERSION_ARB} value. */
public int getMajorVersion() {
return majorVersion;
}
/** Returns the {@link #CONTEXT_MINOR_VERSION_ARB} value. */
public int getMinorVersion() {
return minorVersion;
}
/** Returns the {@link #CONTEXT_PROFILE_MASK_ARB} value. */
public int getProfileMask() {
return profileMask;
}
private boolean hasMask(int mask) {
return profileMask == mask;
}
/** Returns true if the {@link #CONTEXT_CORE_PROFILE_BIT_ARB} has been set. */
public boolean isProfileCore() {
return hasMask(CONTEXT_CORE_PROFILE_BIT_ARB);
}
/** Returns true if the {@link #CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB} has been set. */
public boolean isProfileCompatibility() {
return hasMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB);
}
/** Returns true if the {@link #CONTEXT_ES2_PROFILE_BIT_EXT} has been set. */
public boolean isProfileES() {
return hasMask(CONTEXT_ES2_PROFILE_BIT_EXT);
}
/** Returns the {@link #CONTEXT_FLAGS_ARB} value. */
public int getContextFlags() {
return contextFlags;
}
private boolean hasFlag(int flag) {
return (contextFlags & flag) != 0;
}
/** Returns true if the {@link #CONTEXT_DEBUG_BIT_ARB} has been set. */
public boolean isDebug() {
return hasFlag(CONTEXT_DEBUG_BIT_ARB);
}
/** Returns true if the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} has been set. */
public boolean isForwardCompatible() {
return hasFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB);
}
/** Returns true if the {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB} has been set. */
public boolean isRobustAccess() { return hasFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB); }
/** Returns true if the {@link #CONTEXT_RESET_ISOLATION_BIT_ARB} has been set. */
public boolean isContextResetIsolation() {
return hasFlag(CONTEXT_RESET_ISOLATION_BIT_ARB);
}
/** Returns the {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} value. */
public int getContextResetNotificationStrategy() {
return contextResetNotificationStrategy;
}
/**
* Returns true if the {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} has been set to {@link #LOSE_CONTEXT_ON_RESET_ARB}.
*
* @deprecated use {@link #getContextResetNotificationStrategy} instead
*/
public boolean isLoseContextOnReset() { return contextResetNotificationStrategy == LOSE_CONTEXT_ON_RESET_ARB; }
/** Returns the {@link #CONTEXT_RELEASE_BEHABIOR_ARB} value. */
public int getContextReleaseBehavior() {
return contextReleaseBehavior;
}
/** Returns the {@link #CONTEXT_LAYER_PLANE_ARB} value. */
public int getLayerPlane() {
return layerPlane;
}
// CHAIN CONFIGURATION PATTERN
private ContextAttribs toggleMask(int mask, boolean value) {
if ( value == hasMask(mask) )
return this;
ContextAttribs attribs = new ContextAttribs(this);
attribs.profileMask = value ? mask : 0;
return attribs;
public boolean isDebug() {
return debug;
}
/**
* Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_CORE_PROFILE_BIT_ARB} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
* If {@code profileCore} is true, all other bits in the mask are cleared.
*/
public ContextAttribs withProfileCore(boolean profileCore) {
if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
return toggleMask(CONTEXT_CORE_PROFILE_BIT_ARB, profileCore);
public boolean isForwardCompatible() {
return forwardCompatible;
}
/**
* Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
* If {@code profileCompatibility} is true, all other bits in the mask are cleared.
*/
public ContextAttribs withProfileCompatibility(boolean profileCompatibility) {
if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
return toggleMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, profileCompatibility);
public boolean isProfileCore() {
return profileCore;
}
/**
* Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_ES2_PROFILE_BIT_EXT} bit in {@link #CONTEXT_PROFILE_MASK_ARB} set to the given value.
* If {@code profileES} is true, all other bits in the mask are cleared.
*/
public ContextAttribs withProfileES(boolean profileES) {
if ( !(majorVersion == 2 && minorVersion == 0) )
throw new IllegalArgumentException("The OpenGL ES profile is only supported on OpenGL version 2.0.");
return toggleMask(CONTEXT_ES2_PROFILE_BIT_EXT, profileES);
public boolean isProfileCompatibility() {
return profileCompatibility;
}
private ContextAttribs toggleFlag(int flag, boolean value) {
if ( value == hasFlag(flag) )
return this;
ContextAttribs attribs = new ContextAttribs(this);
attribs.contextFlags ^= flag; // toggle bit
return attribs;
public boolean isProfileES() {
return profileES;
}
/** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_DEBUG_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
public ContextAttribs withDebug(boolean debug) { return toggleFlag(CONTEXT_DEBUG_BIT_ARB, debug); }
/** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_FORWARD_COMPATIBLE_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
public ContextAttribs withForwardCompatible(boolean forwardCompatible) { return toggleFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB, forwardCompatible); }
/** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_ROBUST_ACCESS_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
public ContextAttribs withRobustAccess(boolean robustAccess) { return toggleFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB, robustAccess); }
/** Returns a new {@code ContextAttribs} instance with the {@link #CONTEXT_RESET_ISOLATION_BIT_ARB} bit in {@link #CONTEXT_FLAGS_ARB} set to the given value. */
public ContextAttribs withContextResetIsolation(boolean contextResetIsolation) { return toggleFlag(CONTEXT_RESET_ISOLATION_BIT_ARB, contextResetIsolation); }
/**
* Returns a ContextAttribs instance with {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} set to the given strategy. The default context reset notification
* strategy is {@link #NO_RESET_NOTIFICATION_ARB}.
*
* @param strategy the context reset notification strategy. One of:<br>{@link #NO_RESET_NOTIFICATION_ARB}, {@link #LOSE_CONTEXT_ON_RESET_ARB}
*
* @return the new ContextAttribs
*/
public ContextAttribs withResetNotificationStrategy(int strategy) {
if ( strategy == contextResetNotificationStrategy )
return this;
if ( LWJGLUtil.CHECKS && !(strategy == NO_RESET_NOTIFICATION_ARB || strategy == LOSE_CONTEXT_ON_RESET_ARB) )
throw new IllegalArgumentException("Invalid context reset notification strategy specified: 0x" + LWJGLUtil.toHexString(strategy));
ContextAttribs attribs = new ContextAttribs(this);
attribs.contextResetNotificationStrategy = strategy;
return attribs;
}
/**
* Returns a ContextAttribs instance with {@link #CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB} set to {@link #LOSE_CONTEXT_ON_RESET_ARB} if the parameter is
* true or to {@link #NO_RESET_NOTIFICATION_ARB} if the parameter is false.
*
* @param loseContextOnReset the context reset notification strategy
*
* @return the new ContextAttribs
*
* @deprecated use {@link #withResetNotificationStrategy} instead
*/
public ContextAttribs withLoseContextOnReset(boolean loseContextOnReset) {
return withResetNotificationStrategy(loseContextOnReset ? LOSE_CONTEXT_ON_RESET_ARB : NO_RESET_NOTIFICATION_ARB);
}
/**
* Returns a ContextAttribs instance with {@link #CONTEXT_RELEASE_BEHABIOR_ARB} set to the given behavior. The default context release behavior is
* {@link #CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB}.
*
* @param behavior the context release behavior. One of:<br>{@link #CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB}, {@link #CONTEXT_RELEASE_BEHAVIOR_NONE_ARB}
*
* @return the new ContextAttribs
*/
public ContextAttribs withContextReleaseBehavior(int behavior) {
if ( behavior == contextReleaseBehavior )
return this;
if ( LWJGLUtil.CHECKS && !(behavior == CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB || behavior == CONTEXT_RELEASE_BEHAVIOR_NONE_ARB) )
throw new IllegalArgumentException("Invalid context release behavior specified: 0x" + LWJGLUtil.toHexString(behavior));
ContextAttribs attribs = new ContextAttribs(this);
attribs.contextReleaseBehavior = behavior;
return attribs;
}
/** Returns a new {@code ContextAttribs} instance with {@link #CONTEXT_LAYER_PLANE_ARB} set to the given value. */
public ContextAttribs withLayer(int layerPlane) {
if ( LWJGLUtil.getPlatform() != LWJGLUtil.PLATFORM_WINDOWS )
throw new IllegalArgumentException("The CONTEXT_LAYER_PLANE_ARB attribute is supported only on the Windows platform.");
public ContextAttribs withLayer(final int layerPlane) {
if ( layerPlane < 0 )
throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane);
if ( layerPlane == this.layerPlane )
return this;
if ( layerPlane < 0 )
throw new IllegalArgumentException("Invalid layer plane specified: " + layerPlane);
ContextAttribs attribs = new ContextAttribs(this);
final ContextAttribs attribs = new ContextAttribs(this);
attribs.layerPlane = layerPlane;
return attribs;
}
public ContextAttribs withDebug(final boolean debug) {
if ( debug == this.debug )
return this;
final ContextAttribs attribs = new ContextAttribs(this);
attribs.debug = debug;
return attribs;
}
public ContextAttribs withForwardCompatible(final boolean forwardCompatible) {
if ( forwardCompatible == this.forwardCompatible )
return this;
final ContextAttribs attribs = new ContextAttribs(this);
attribs.forwardCompatible = forwardCompatible;
return attribs;
}
public ContextAttribs withProfileCore(final boolean profileCore) {
if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
if ( profileCore == this.profileCore )
return this;
final ContextAttribs attribs = new ContextAttribs(this);
attribs.profileCore = profileCore;
if ( profileCore )
attribs.profileCompatibility = false;
return attribs;
}
public ContextAttribs withProfileCompatibility(final boolean profileCompatibility) {
if ( majorVersion < 3 || (majorVersion == 3 && minorVersion < 2) )
throw new IllegalArgumentException("Profiles are only supported on OpenGL version 3.2 or higher.");
if ( profileCompatibility == this.profileCompatibility )
return this;
final ContextAttribs attribs = new ContextAttribs(this);
attribs.profileCompatibility = profileCompatibility;
if ( profileCompatibility )
attribs.profileCore = false;
return attribs;
}
public ContextAttribs withProfileES(final boolean profileES) {
if ( !(majorVersion == 2 && minorVersion == 0) )
throw new IllegalArgumentException("The OpenGL ES profiles is only supported for OpenGL version 2.0.");
if ( profileES == this.profileES )
return this;
final ContextAttribs attribs = new ContextAttribs(this);
attribs.profileES = profileES;
return attribs;
}
/**
* Returns a ContextAttribs instance with CONTEXT_RESET_NOTIFICATION_STRATEGY set
* to LOSE_CONTEXT_ON_RESET if the parameter is true or to NO_RESET_NOTIFICATION
* if the parameter is false.
*
* @param loseContextOnReset
*
* @return the new ContextAttribs
*/
public ContextAttribs withLoseContextOnReset(final boolean loseContextOnReset) {
if ( loseContextOnReset == this.loseContextOnReset )
return this;
final ContextAttribs attribs = new ContextAttribs(this);
attribs.loseContextOnReset = loseContextOnReset;
return attribs;
}
private static ContextAttribsImplementation getImplementation() {
switch ( LWJGLUtil.getPlatform() ) {
case LWJGLUtil.PLATFORM_LINUX:
return new LinuxContextAttribs();
case LWJGLUtil.PLATFORM_WINDOWS:
return new WindowsContextAttribs();
default:
throw new IllegalStateException("Unsupported platform");
}
}
IntBuffer getAttribList() {
if ( LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX )
return null;
LinkedHashMap<Integer, Integer> map = new LinkedHashMap<Integer, Integer>(8);
ContextAttribsImplementation implementation = getImplementation();
if ( !(majorVersion == 1 && minorVersion == 0) ) {
map.put(CONTEXT_MAJOR_VERSION_ARB, majorVersion);
map.put(CONTEXT_MINOR_VERSION_ARB, minorVersion);
}
int attribCount = 0;
if ( contextFlags != 0 )
map.put(CONTEXT_FLAGS_ARB, contextFlags);
if ( !(majorVersion == 1 && minorVersion == 0) )
attribCount += 2;
if ( 0 < layerPlane )
attribCount++;
if ( profileMask != 0 )
map.put(CONTEXT_PROFILE_MASK_ARB, profileMask);
int flags = 0;
if ( debug )
flags |= implementation.getDebugBit();
if ( forwardCompatible )
flags |= implementation.getForwardCompatibleBit();
if ( robustAccess )
flags |= CONTEXT_ROBUST_ACCESS_BIT_ARB;
if ( 0 < flags )
attribCount++;
if ( contextResetNotificationStrategy != NO_RESET_NOTIFICATION_ARB )
map.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, contextResetNotificationStrategy);
int profileMask = 0;
if ( profileCore )
profileMask |= implementation.getProfileCoreBit();
else if ( profileCompatibility )
profileMask |= implementation.getProfileCompatibilityBit();
else if ( profileES )
profileMask |= CONTEXT_ES2_PROFILE_BIT_EXT;
if ( 0 < profileMask )
attribCount++;
if ( contextReleaseBehavior != CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB )
map.put(CONTEXT_RELEASE_BEHABIOR_ARB, contextReleaseBehavior);
if ( layerPlane != 0 )
map.put(CONTEXT_LAYER_PLANE_ARB, layerPlane);
if ( map.isEmpty() )
if ( attribCount == 0 )
return null;
IntBuffer attribs = BufferUtils.createIntBuffer((map.size() * 2) + 1);
for ( Entry<Integer, Integer> attrib : map.entrySet() ) {
attribs
.put(attrib.getKey())
.put(attrib.getValue());
final IntBuffer attribs = BufferUtils.createIntBuffer((attribCount * 2) + 1);
if ( !(majorVersion == 1 && minorVersion == 0) ) {
attribs.put(implementation.getMajorVersionAttrib()).put(majorVersion);
attribs.put(implementation.getMinorVersionAttrib()).put(minorVersion);
}
if ( 0 < layerPlane )
attribs.put(implementation.getLayerPlaneAttrib()).put(layerPlane);
if ( 0 < flags )
attribs.put(implementation.getFlagsAttrib()).put(flags);
if ( 0 < profileMask )
attribs.put(implementation.getProfileMaskAttrib()).put(profileMask);
if ( loseContextOnReset )
attribs.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB).put(LOSE_CONTEXT_ON_RESET_ARB);
attribs.put(0);
attribs.rewind();
return attribs;
@ -438,37 +313,19 @@ public final class ContextAttribs {
sb.append("ContextAttribs:");
sb.append(" Version=").append(majorVersion).append('.').append(minorVersion);
if ( profileMask != 0 ) {
sb.append(", Profile=");
if ( hasMask(CONTEXT_CORE_PROFILE_BIT_ARB) )
sb.append("CORE");
else if ( hasMask(CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB) )
sb.append("COMPATIBLITY");
else if ( hasMask(CONTEXT_ES2_PROFILE_BIT_EXT) )
sb.append("ES2");
else
sb.append("*unknown*");
}
if ( contextFlags != 0 ) {
if ( hasFlag(CONTEXT_DEBUG_BIT_ARB) )
sb.append(", DEBUG");
if ( hasFlag(CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) )
sb.append(", FORWARD_COMPATIBLE");
if ( hasFlag(CONTEXT_ROBUST_ACCESS_BIT_ARB) )
sb.append(", ROBUST_ACCESS");
if ( hasFlag(CONTEXT_RESET_ISOLATION_BIT_ARB) )
sb.append(", RESET_ISOLATION");
}
if ( contextResetNotificationStrategy != NO_RESET_NOTIFICATION_ARB )
sb.append(", LOSE_CONTEXT_ON_RESET");
if ( contextReleaseBehavior != CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB )
sb.append(", RELEASE_BEHAVIOR_NONE");
if ( layerPlane != 0 )
sb.append(", Layer=").append(layerPlane);
sb.append(" - Layer=").append(layerPlane);
sb.append(" - Debug=").append(debug);
sb.append(" - ForwardCompatible=").append(forwardCompatible);
sb.append(" - RobustAccess=").append(robustAccess);
if ( robustAccess )
sb.append(" (").append(loseContextOnReset ? "LOSE_CONTEXT_ON_RESET" : "NO_RESET_NOTIFICATION");
sb.append(" - Profile=");
if ( profileCore )
sb.append("Core");
else if ( profileCompatibility )
sb.append("Compatibility");
else
sb.append("None");
return sb.toString();
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2014 LWJGL Project
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -29,14 +29,28 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
import org.lwjgl.util.generator.Reuse;
import org.lwjgl.util.generator.opengl.GLbitfield;
/** @author spasi <spasi@users.sourceforge.net> */
interface ContextAttribsImplementation {
public interface ARB_ES3_1_compatibility {
int getMajorVersionAttrib();
@Reuse("GL45")
void glMemoryBarrierByRegion(@GLbitfield int barriers);
int getMinorVersionAttrib();
int getLayerPlaneAttrib();
int getFlagsAttrib();
int getDebugBit();
int getForwardCompatibleBit();
int getProfileMaskAttrib();
int getProfileCoreBit();
int getProfileCompatibilityBit();
}

View file

@ -253,12 +253,8 @@ final class ContextGL implements Context {
boolean was_current = isCurrent();
int error = GL_NO_ERROR;
if ( was_current ) {
try {
// May fail on GLContext.getCapabilities()
if ( GLContext.getCapabilities() != null && GLContext.getCapabilities().OpenGL11 )
error = glGetError();
} catch (Exception e) {
// ignore
}
releaseCurrent();
}
checkDestroy();

View file

@ -43,10 +43,7 @@ package org.lwjgl.opengl;
* @author foo
*/
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import org.lwjgl.Sys;
import org.lwjgl.*;
import org.lwjgl.input.Controllers;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@ -55,7 +52,6 @@ import java.awt.*;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.security.AccessController;
@ -83,6 +79,9 @@ public final class Display {
/** The current display mode, if created */
private static DisplayMode current_mode;
/** Timer for sync() */
private static long timeThen;
/** X coordinate of the window */
private static int x = -1;
@ -240,21 +239,21 @@ public final class Display {
throw new NullPointerException("mode must be non-null");
boolean was_fullscreen = isFullscreen();
current_mode = mode;
if ( !isCreated() || parent != null )
return;
destroyWindow();
// If mode is not fullscreen capable, make sure we are in windowed mode
try {
if ( was_fullscreen && !isFullscreen() )
if ( isCreated() ) {
destroyWindow();
// If mode is not fullscreen capable, make sure we are in windowed mode
try {
if ( was_fullscreen && !isFullscreen() )
display_impl.resetDisplayMode();
else if ( isFullscreen() )
switchDisplayMode();
createWindow();
makeCurrentAndSetSwapInterval();
} catch (LWJGLException e) {
drawable.destroy();
display_impl.resetDisplayMode();
else if ( isFullscreen() )
switchDisplayMode();
createWindow();
makeCurrentAndSetSwapInterval();
} catch (LWJGLException e) {
drawable.destroy();
display_impl.resetDisplayMode();
throw e;
throw e;
}
}
}
}
@ -402,14 +401,40 @@ public final class Display {
}
}
private static long timeLate;
/**
* An accurate sync method that will attempt to run at a constant frame rate.
* It should be called once every frame.
* Best sync method that works reliably.
*
* @param fps - the desired frame rate, in frames per second
* @param fps The desired frame rate, in frames per second
*/
public static void sync(int fps) {
Sync.sync(fps);
long timeNow;
long gapTo;
long savedTimeLate;
synchronized ( GlobalLock.lock ) {
gapTo = Sys.getTimerResolution() / fps + timeThen;
timeNow = Sys.getTime();
savedTimeLate = timeLate;
}
try {
while ( gapTo > timeNow + savedTimeLate ) {
Thread.sleep(1);
timeNow = Sys.getTime();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
synchronized ( GlobalLock.lock ) {
if ( gapTo < timeNow )
timeLate = timeNow - gapTo;
else
timeLate = 0;
timeThen = timeNow;
}
}
/** @return the title of the window */
@ -660,7 +685,6 @@ public final class Display {
if ( parent_resized ) {
reshape();
parent_resized = false;
window_resized = true;
}
if ( processMessages )
@ -1049,15 +1073,6 @@ public final class Display {
}
});
}
/** 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);
}
});
}
private static void initControls() {
// Automatically create mouse, keyboard and controller
@ -1092,9 +1107,7 @@ public final class Display {
* regardless of whether the Display was the current rendering context.
*/
public static void destroy() {
if(isCreated()) {
drawable.destroy();
}
drawable.destroy();
}
/*
@ -1203,7 +1216,7 @@ public final class Display {
* <li>Linux (and similar platforms) expect one 32x32 icon.</li>
* <li>Mac OS X should be supplied one 128x128 icon</li>
* </ul>
* The implementation will use the supplied ByteBuffers with image data in RGBA (size must be a power of two) and perform any conversions nescesarry for the specific platform.
* The implementation will use the supplied ByteBuffers with image data in RGBA and perform any conversions nescesarry for the specific platform.
* <p/>
* <b>NOTE:</b> The display will make a deep copy of the supplied byte buffer array, for the purpose
* of recreating the icons when you go back and forth fullscreen mode. You therefore only need to
@ -1223,8 +1236,8 @@ public final class Display {
cached_icons[i] = BufferUtils.createByteBuffer(icons[i].capacity());
int old_position = icons[i].position();
cached_icons[i].put(icons[i]);
((Buffer)icons[i]).position(old_position);
((Buffer)cached_icons[i]).flip();
icons[i].position(old_position);
cached_icons[i].flip();
}
}
@ -1266,51 +1279,11 @@ public final class Display {
return window_resized;
}
/**
* @return this method will return the x position (top-left) of the Display window.
*
* If running in fullscreen mode it will return 0.
* If Display.setParent(Canvas parent) is being used, the x position of
* the parent will be returned.
*/
public static int getX() {
if (Display.isFullscreen()) {
return 0;
}
if (parent != null) {
return parent.getX();
}
return display_impl.getX();
}
/**
* @return this method will return the y position (top-left) of the Display window.
*
* If running in fullscreen mode it will return 0.
* If Display.setParent(Canvas parent) is being used, the y position of
* the parent will be returned.
*/
public static int getY() {
if (Display.isFullscreen()) {
return 0;
}
if (parent != null) {
return parent.getY();
}
return display_impl.getY();
}
/**
* @return this method will return the width of the Display window.
*
* If running in fullscreen mode it will return the width of the current set DisplayMode.
* If Display.setParent(Canvas parent) is being used, the width of the parent
* If running Display.setParent(Canvas parent) is being used, the width of the parent
* will be returned.
*
* This value will be updated after a call to Display.update().
@ -1332,7 +1305,7 @@ public final class Display {
* @return this method will return the height of the Display window.
*
* If running in fullscreen mode it will return the height of the current set DisplayMode.
* If Display.setParent(Canvas parent) is being used, the height of the parent
* If running Display.setParent(Canvas parent) is being used, the height of the parent
* will be returned.
*
* This value will be updated after a call to Display.update().
@ -1349,28 +1322,4 @@ public final class Display {
return height;
}
/**
* @return this method will return the pixel scale factor of the Display window.
*
* This method should be used when running in high DPI mode. In such modes Operating
* Systems will scale the Display window to avoid the window shrinking due to high
* resolutions. The OpenGL frame buffer will however use the higher resolution and
* not be scaled to match the Display window size.
*
* OpenGL methods that require pixel dependent values e.g. glViewport, glTexImage2D,
* glReadPixels, glScissor, glLineWidth, glRenderbufferStorage, etc can convert the
* scaled Display and Mouse coordinates to the correct high resolution value by
* multiplying them by the pixel scale factor.
*
* e.g. Display.getWidth() * Display.getPixelScaleFactor() will return the high DPI
* width of the OpenGL frame buffer. Whereas Display.getWidth() will be the same as
* the OpenGL frame buffer in non high DPI mode.
*
* Where high DPI mode is not available this method will just return 1.0f therefore
* not have any effect on values that are multiplied by it.
*/
public static float getPixelScaleFactor() {
return display_impl.getPixelScaleFactor();
}
}

View file

@ -174,27 +174,12 @@ interface DisplayImplementation extends InputImplementation {
boolean wasResized();
/**
* @return this method will return the width of the Display window.
* @return this method will return a the width of the Display window.
*/
int getWidth();
/**
* @return this method will return the height of the Display window.
* @return this method will return a the height of the Display window.
*/
int getHeight();
/**
* @return this method will return the top-left x position of the Display window.
*/
int getX();
/**
* @return this method will return the top-left y position of the Display window.
*/
int getY();
/**
* @return this method will return the pixel scale factor of the Display window useful for high resolution modes.
*/
float getPixelScaleFactor();
}

View file

@ -75,7 +75,7 @@ public final class DisplayMode {
this.fullscreen = fullscreen;
}
/** True if this instance can be used for fullscreen modes */
/** True iff this instance can be used for fullscreen modes */
public boolean isFullscreenCapable() {
return fullscreen;
}

View file

@ -36,7 +36,6 @@ package org.lwjgl.opengl;
* @author elias_naur
*/
import java.nio.Buffer;
import java.nio.ByteBuffer;
class EventQueue {
@ -59,12 +58,12 @@ class EventQueue {
* Copy available events into the specified buffer.
*/
public synchronized void copyEvents(ByteBuffer dest) {
((Buffer)queue).flip();
queue.flip();
int old_limit = queue.limit();
if (dest.remaining() < queue.remaining())
((Buffer)queue).limit(dest.remaining() + queue.position());
queue.limit(dest.remaining() + queue.position());
dest.put(queue);
((Buffer)queue).limit(old_limit);
queue.limit(old_limit);
queue.compact();
}

View file

@ -43,7 +43,6 @@ import static org.lwjgl.opengl.EXTAbgr.*;
import static org.lwjgl.opengl.EXTBgra.*;
import static org.lwjgl.opengl.EXTDirectStateAccess.*;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL13.*;
import static org.lwjgl.opengl.GL15.*;
import static org.lwjgl.opengl.NVPathRendering.*;
@ -66,6 +65,22 @@ class GLChecks {
private GLChecks() {
}
static int getBufferObjectSize(ContextCapabilities caps, int buffer_enum) {
return glGetBufferParameter(buffer_enum, GL_BUFFER_SIZE);
}
static int getBufferObjectSizeARB(ContextCapabilities caps, int buffer_enum) {
return glGetBufferParameterARB(buffer_enum, GL_BUFFER_SIZE_ARB);
}
static int getBufferObjectSizeATI(ContextCapabilities caps, int buffer) {
return glGetObjectBufferATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI);
}
static int getNamedBufferObjectSize(ContextCapabilities caps, int buffer) {
return glGetNamedBufferParameterEXT(buffer, GL_BUFFER_SIZE);
}
/** Helper method to ensure that array buffer objects are disabled. If they are enabled, we'll throw an OpenGLException */
static void ensureArrayVBOdisabled(ContextCapabilities caps) {
if ( LWJGLUtil.CHECKS && StateTracker.getReferences(caps).arrayBuffer != 0 )
@ -295,36 +310,37 @@ class GLChecks {
}
}
static int calculatePathColorGenModeElements(int genMode) {
static int calculatePathColorGenCoeffsCount(int genMode, int colorFormat) {
final int coeffsPerComponent = calculatePathGenCoeffsPerComponent(genMode);
switch ( colorFormat ) {
case GL_RGB:
return 3 * coeffsPerComponent;
case GL_RGBA:
return 4 * coeffsPerComponent;
default:
return coeffsPerComponent;
}
}
static int calculatePathTextGenCoeffsPerComponent(FloatBuffer coeffs, int genMode) {
if ( genMode == GL_NONE )
return 0;
return coeffs.remaining() / calculatePathGenCoeffsPerComponent(genMode);
}
private static int calculatePathGenCoeffsPerComponent(int genMode) {
switch ( genMode ) {
case GL_NONE:
return 0;
case GL_CONSTANT:
return 1;
case GL_OBJECT_LINEAR:
case GL_PATH_OBJECT_BOUNDING_BOX_NV:
return 3;
case GL_EYE_LINEAR:
return 4;
default:
throw new IllegalArgumentException(String.format("Unsupported genMode specified: 0x%X", genMode));
}
}
static int calculatePathColorGenFormatComponents(int colorFormat) {
switch ( colorFormat ) {
case GL_LUMINANCE:
case GL_INTENSITY:
case GL_ALPHA:
return 1;
case GL_LUMINANCE_ALPHA:
return 2;
case GL_RGB:
return 3;
case GL_RGBA:
return 4;
default:
throw new IllegalArgumentException(String.format("Unsupported colorFormat specified: 0x%X", colorFormat));
throw new IllegalArgumentException("Unsupported gen mode: " + genMode);
}
}

View file

@ -119,14 +119,6 @@ public final class GLContext {
* @return The current capabilities instance.
*/
public static ContextCapabilities getCapabilities() {
ContextCapabilities caps = getCapabilitiesImpl();
if ( caps == null )
throw new RuntimeException("No OpenGL context found in the current thread.");
return caps;
}
private static ContextCapabilities getCapabilitiesImpl() {
CapabilitiesCacheEntry recent_cache_entry = fast_path_cache;
// Check owner of cache entry
if ( recent_cache_entry.owner == Thread.currentThread() ) {
@ -138,17 +130,6 @@ public final class GLContext {
return getThreadLocalCapabilities();
}
/**
* Returns the capabilities instance associated with the specified context object.
*
* @param context the context object
*
* @return the capabilities instance
*/
static ContextCapabilities getCapabilities(Object context) {
return capability_cache.get(context);
}
private static ContextCapabilities getThreadLocalCapabilities() {
return current_capabilities.get();
}
@ -243,10 +224,10 @@ public final class GLContext {
}
final int[][] GL_VERSIONS = {
{ 1, 2, 3, 4, 5 }, // OpenGL 1
{ 0, 1 }, // OpenGL 2
{ 0, 1, 2, 3 }, // OpenGL 3
{ 0, 1, 2, 3, 4, 5 }, // OpenGL 4
{ 1, 2, 3, 4, 5 }, // OpenGL 1
{ 0, 1 }, // OpenGL 2
{ 0, 1, 2, 3 }, // OpenGL 3
{ 0, 1, 2 }, // OpenGL 4
};
for ( int major = 1; major <= GL_VERSIONS.length; major++ ) {

View file

@ -69,7 +69,7 @@ public interface InputImplementation {
void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons);
/**
* Method to read the mouse buffer
* Method to read the keyboard buffer
*/
void readMouse(ByteBuffer buffer);

View file

@ -1,209 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
import org.lwjgl.PointerWrapperAbstract;
/**
* Instances of this class are needed to use the callback functionality of the KHR_debug extension.
* Users of this class may provide implementations of the {@code Handler} interface to receive notifications.
* The same {@code Handler} instance may be used by different contexts but it is not recommended.
* Handler notifications are synchronized.
*
* @author Spasi
*/
public final class KHRDebugCallback extends PointerWrapperAbstract {
/** Severity levels. */
private static final int
GL_DEBUG_SEVERITY_HIGH = 0x9146,
GL_DEBUG_SEVERITY_MEDIUM = 0x9147,
GL_DEBUG_SEVERITY_LOW = 0x9148,
GL_DEBUG_SEVERITY_NOTIFICATION = 0x826B;
/** Sources. */
private static final int
GL_DEBUG_SOURCE_API = 0x8246,
GL_DEBUG_SOURCE_WINDOW_SYSTEM = 0x8247,
GL_DEBUG_SOURCE_SHADER_COMPILER = 0x8248,
GL_DEBUG_SOURCE_THIRD_PARTY = 0x8249,
GL_DEBUG_SOURCE_APPLICATION = 0x824A,
GL_DEBUG_SOURCE_OTHER = 0x824B;
/** Types. */
private static final int
GL_DEBUG_TYPE_ERROR = 0x824C,
GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR = 0x824D,
GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR = 0x824E,
GL_DEBUG_TYPE_PORTABILITY = 0x824F,
GL_DEBUG_TYPE_PERFORMANCE = 0x8250,
GL_DEBUG_TYPE_OTHER = 0x8251,
GL_DEBUG_TYPE_MARKER = 0x8268;
private static final long CALLBACK_POINTER;
static {
long pointer = 0;
try {
// Call reflectively so that we can compile this class for the Generator.
pointer = (Long)Class.forName("org.lwjgl.opengl.CallbackUtil").getDeclaredMethod("getDebugCallbackKHR").invoke(null);
} catch (Exception e) {
// ignore
}
CALLBACK_POINTER = pointer;
}
private final Handler handler;
/**
* Creates an KHRebugCallback with a default callback handler.
* The default handler will simply print the message on System.err.
*/
public KHRDebugCallback() {
this(new Handler() {
public void handleMessage(final int source, final int type, final int id, final int severity, final String message) {
System.err.println("[LWJGL] KHR_debug message");
System.err.println("\tID: " + id);
String description;
switch ( source ) {
case GL_DEBUG_SOURCE_API:
description = "API";
break;
case GL_DEBUG_SOURCE_WINDOW_SYSTEM:
description = "WINDOW SYSTEM";
break;
case GL_DEBUG_SOURCE_SHADER_COMPILER:
description = "SHADER COMPILER";
break;
case GL_DEBUG_SOURCE_THIRD_PARTY:
description = "THIRD PARTY";
break;
case GL_DEBUG_SOURCE_APPLICATION:
description = "APPLICATION";
break;
case GL_DEBUG_SOURCE_OTHER:
description = "OTHER";
break;
default:
description = printUnknownToken(source);
}
System.err.println("\tSource: " + description);
switch ( type ) {
case GL_DEBUG_TYPE_ERROR:
description = "ERROR";
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR:
description = "DEPRECATED BEHAVIOR";
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR:
description = "UNDEFINED BEHAVIOR";
break;
case GL_DEBUG_TYPE_PORTABILITY:
description = "PORTABILITY";
break;
case GL_DEBUG_TYPE_PERFORMANCE:
description = "PERFORMANCE";
break;
case GL_DEBUG_TYPE_OTHER:
description = "OTHER";
break;
case GL_DEBUG_TYPE_MARKER:
description = "MARKER";
break;
default:
description = printUnknownToken(type);
}
System.err.println("\tType: " + description);
switch ( severity ) {
case GL_DEBUG_SEVERITY_HIGH:
description = "HIGH";
break;
case GL_DEBUG_SEVERITY_MEDIUM:
description = "MEDIUM";
break;
case GL_DEBUG_SEVERITY_LOW:
description = "LOW";
break;
case GL_DEBUG_SEVERITY_NOTIFICATION:
description = "NOTIFICATION";
break;
default:
description = printUnknownToken(severity);
}
System.err.println("\tSeverity: " + description);
System.err.println("\tMessage: " + message);
}
private String printUnknownToken(final int token) {
return "Unknown (0x" + Integer.toHexString(token).toUpperCase() + ")";
}
});
}
/**
* Creates an ARBDebugOutputCallback with the specified callback handler.
* The handler's {@code handleMessage} method will be called whenever
* debug output is generated by the GL.
*
* @param handler the callback handler
*/
public KHRDebugCallback(final Handler handler) {
super(CALLBACK_POINTER);
this.handler = handler;
}
Handler getHandler() {
return handler;
}
/** Implementations of this interface can be used to receive ARB_debug_output notifications. */
public interface Handler {
/**
* This method will be called when an ARB_debug_output message is generated.
*
* @param source the message source
* @param type the message type
* @param id the message ID
* @param severity the message severity
* @param message the string representation of the message.
*/
void handleMessage(int source, int type, int id, int severity, String message);
}
}

View file

@ -1,46 +1,91 @@
/*
* Copyright (c) 2002-2012 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
import org.lwjgl.util.generator.opengl.GLfloat;
import org.lwjgl.util.generator.opengl.GLuint;
public interface NV_draw_texture {
void glDrawTextureNV(@GLuint int texture, @GLuint int sampler,
@GLfloat float x0, @GLfloat float y0,
@GLfloat float x1, @GLfloat float y1,
@GLfloat float z,
@GLfloat float s0, @GLfloat float t0,
@GLfloat float s1, @GLfloat float t1);
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
/**
* An implementation of ContextAttribs using GLX_create_context.
*
* @author spasi <spasi@users.sourceforge.net>
*/
final class LinuxContextAttribs implements ContextAttribsImplementation {
private static final int GLX_CONTEXT_MAJOR_VERSION_ARB = 0x2091;
private static final int GLX_CONTEXT_MINOR_VERSION_ARB = 0x2092;
private static final int GLX_CONTEXT_FLAGS_ARB = 0x2094;
private static final int GLX_CONTEXT_PROFILE_MASK_ARB = 0x9126;
private static final int GLX_CONTEXT_DEBUG_BIT_ARB = 0x0001;
private static final int GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002;
private static final int GLX_CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001;
private static final int GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002;
LinuxContextAttribs() {
}
public int getMajorVersionAttrib() {
return GLX_CONTEXT_MAJOR_VERSION_ARB;
}
public int getMinorVersionAttrib() {
return GLX_CONTEXT_MINOR_VERSION_ARB;
}
public int getLayerPlaneAttrib() {
throw new UnsupportedOperationException();
}
public int getFlagsAttrib() {
return GLX_CONTEXT_FLAGS_ARB;
}
public int getDebugBit() {
return GLX_CONTEXT_DEBUG_BIT_ARB;
}
public int getForwardCompatibleBit() {
return GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
}
public int getProfileMaskAttrib() {
return GLX_CONTEXT_PROFILE_MASK_ARB;
}
public int getProfileCoreBit() {
return GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
}
public int getProfileCompatibilityBit() {
return GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
}
}

View file

@ -143,31 +143,16 @@ final class LinuxContextImplementation implements ContextImplementation {
public void setSwapInterval(int value) {
ContextGL current_context = ContextGL.getCurrentContext();
if ( current_context == null )
throw new IllegalStateException("No context is current");
PeerInfo peer_info = current_context.getPeerInfo();
synchronized ( current_context ) {
LinuxDisplay.lockAWT();
try {
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();
}
nSetSwapInterval(current_context.getHandle(), value);
LinuxDisplay.unlockAWT();
}
}
private static native void nSetSwapInterval(ByteBuffer peer_handle, ByteBuffer context_handle, int value);
private static native void nSetSwapInterval(ByteBuffer context_handle, int value);
public void destroy(PeerInfo peer_info, ByteBuffer handle) throws LWJGLException {
LinuxDisplay.lockAWT();

View file

@ -45,7 +45,6 @@ import java.awt.event.FocusEvent;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteOrder;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
@ -129,6 +128,7 @@ final class LinuxDisplay implements DisplayImplementation {
private DisplayMode saved_mode;
private DisplayMode current_mode;
private Screen[] savedXrandrConfig;
private boolean keyboard_grabbed;
private boolean pointer_grabbed;
@ -144,8 +144,6 @@ final class LinuxDisplay implements DisplayImplementation {
private boolean resizable;
private boolean resized;
private int window_x;
private int window_y;
private int window_width;
private int window_height;
@ -154,25 +152,20 @@ final class LinuxDisplay implements DisplayImplementation {
private static boolean xembedded;
private long parent_proxy_focus_window;
private boolean parent_focused;
private boolean parent_focus_changed;
private long last_window_focus = 0;
private LinuxKeyboard keyboard;
private LinuxMouse mouse;
private String wm_class;
private final FocusListener focus_listener = new FocusListener() {
public void focusGained(FocusEvent e) {
synchronized (GlobalLock.lock) {
parent_focused = true;
parent_focus_changed = true;
}
}
public void focusLost(FocusEvent e) {
synchronized (GlobalLock.lock) {
parent_focused = false;
parent_focus_changed = true;
}
}
};
@ -462,43 +455,22 @@ final class LinuxDisplay implements DisplayImplementation {
ByteBuffer handle = peer_info.lockAndGetHandle();
try {
current_window_mode = getWindowMode(Display.isFullscreen());
// Try to enable Lecagy FullScreen Support in Compiz, else
// we may have trouble with stuff overlapping our fullscreen window.
if ( current_window_mode != WINDOWED )
Compiz.setLegacyFullscreenSupport(true);
// Setting _MOTIF_WM_HINTS in fullscreen mode is problematic for certain window
// managers. We do not set MWM_HINTS_DECORATIONS in fullscreen mode anymore,
// unless org.lwjgl.opengl.Window.undecorated_fs has been specified.
// See native/linux/org_lwjgl_opengl_Display.c, createWindow function.
boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated") || (current_window_mode != WINDOWED && Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated_fs"));
this.parent = parent;
parent_window = parent != null ? getHandle(parent) : getRootWindow(getDisplay(), getDefaultScreen());
resizable = Display.isResizable();
resized = false;
window_x = x;
window_y = y;
window_width = mode.getWidth();
window_height = mode.getHeight();
// overwrite arguments x and y - superclass always uses 0,0 for fullscreen windows
// use the coordinates of XRandRs primary screen instead
// this is required to let the fullscreen window appear on the primary screen
if (mode.isFullscreenCapable() && current_displaymode_extension == XRANDR) {
Screen primaryScreen = XRandR.DisplayModetoScreen(Display.getDisplayMode());
x = primaryScreen.xPos;
y = primaryScreen.yPos;
}
current_window = nCreateWindow(getDisplay(), getDefaultScreen(), handle, mode, current_window_mode, x, y, undecorated, parent_window, resizable);
// Set the WM_CLASS hint which is needed by some WM's e.g. Gnome Shell
wm_class = Display.getPrivilegedString("LWJGL_WM_CLASS");
if (wm_class == null) wm_class = Display.getTitle();
setClassHint(Display.getTitle(), wm_class);
mapRaised(getDisplay(), current_window);
xembedded = parent != null && isAncestorXEmbedded(parent_window);
blank_cursor = createBlankCursor();
@ -517,8 +489,9 @@ final class LinuxDisplay implements DisplayImplementation {
if (parent != null) {
parent.addFocusListener(focus_listener);
parent_focused = parent.isFocusOwner();
parent_focus_changed = true;
if (parent.isFocusOwner()) {
parent_focused = true;
}
}
} finally {
peer_info.unlock();
@ -541,8 +514,6 @@ final class LinuxDisplay implements DisplayImplementation {
private static native long nGetInputFocus(long display) throws LWJGLException;
private static native void nSetInputFocus(long display, long window, long time);
private static native void nSetWindowSize(long display, long window, int width, int height, boolean resizable);
private static native int nGetX(long display, long window);
private static native int nGetY(long display, long window);
private static native int nGetWidth(long display, long window);
private static native int nGetHeight(long display, long window);
@ -578,9 +549,6 @@ final class LinuxDisplay implements DisplayImplementation {
public void destroyWindow() {
lockAWT();
try {
if (parent != null) {
parent.removeFocusListener(focus_listener);
}
try {
setNativeCursor(null);
} catch (LWJGLException e) {
@ -611,17 +579,12 @@ final class LinuxDisplay implements DisplayImplementation {
}
private void switchDisplayModeOnTmpDisplay(DisplayMode mode) throws LWJGLException {
if (current_displaymode_extension == XRANDR) {
// let Xrandr set the display mode
XRandR.setConfiguration(false, XRandR.DisplayModetoScreen(mode));
} else {
incDisplay();
try {
nSwitchDisplayMode(getDisplay(), getDefaultScreen(), current_displaymode_extension, mode);
} finally {
decDisplay();
}
}
incDisplay();
try {
nSwitchDisplayMode(getDisplay(), getDefaultScreen(), current_displaymode_extension, mode);
} finally {
decDisplay();
}
}
private static native void nSwitchDisplayMode(long display, int screen, int extension, DisplayMode mode) throws LWJGLException;
@ -638,11 +601,11 @@ final class LinuxDisplay implements DisplayImplementation {
public void resetDisplayMode() {
lockAWT();
try {
if( current_displaymode_extension == XRANDR )
if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
{
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
XRandR.restoreConfiguration();
XRandR.setConfiguration( savedXrandrConfig );
return null;
}
});
@ -740,11 +703,12 @@ final class LinuxDisplay implements DisplayImplementation {
throw new LWJGLException("No modes available");
switch (current_displaymode_extension) {
case XRANDR:
saved_mode = AccessController.doPrivileged(new PrivilegedAction<DisplayMode>() {
public DisplayMode run() {
return XRandR.ScreentoDisplayMode(XRandR.getConfiguration());
savedXrandrConfig = AccessController.doPrivileged(new PrivilegedAction<Screen[]>() {
public Screen[] run() {
return XRandR.getConfiguration();
}
});
saved_mode = getCurrentXRandrMode();
break;
case XF86VIDMODE:
saved_mode = modes[0];
@ -788,20 +752,6 @@ final class LinuxDisplay implements DisplayImplementation {
}
}
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 {
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);
public boolean isCloseRequested() {
boolean result = close_requested;
@ -845,10 +795,10 @@ final class LinuxDisplay implements DisplayImplementation {
relayEventToParent(event_buffer, KeyPressMask);
break;
case LinuxEvent.ButtonPress:
if (xembedded || !focused) relayEventToParent(event_buffer, KeyPressMask);
relayEventToParent(event_buffer, KeyPressMask);
break;
case LinuxEvent.ButtonRelease:
if (xembedded || !focused) relayEventToParent(event_buffer, KeyPressMask);
relayEventToParent(event_buffer, KeyPressMask);
break;
default:
break;
@ -885,17 +835,10 @@ final class LinuxDisplay implements DisplayImplementation {
break;
case LinuxEvent.Expose:
dirty = true;
break;
case LinuxEvent.ConfigureNotify:
int x = nGetX(getDisplay(), getWindow());
int y = nGetY(getDisplay(), getWindow());
int width = nGetWidth(getDisplay(), getWindow());
int height = nGetHeight(getDisplay(), getWindow());
window_x = x;
window_y = y;
if (window_width != width || window_height != height) {
resized = true;
window_width = width;
@ -938,29 +881,13 @@ final class LinuxDisplay implements DisplayImplementation {
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
lockAWT();
try {
incDisplay();
if (current_displaymode_extension == XRANDR) {
// nGetAvailableDisplayModes cannot be trusted. Use it only for bitsPerPixel
DisplayMode[] nDisplayModes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
int bpp = 24;
if (nDisplayModes.length > 0) {
bpp = nDisplayModes[0].getBitsPerPixel();
}
// get the resolutions and frequencys from XRandR
Screen[] resolutions = XRandR.getResolutions(XRandR.getScreenNames()[0]);
DisplayMode[] modes = new DisplayMode[resolutions.length];
for (int i = 0; i < modes.length; i++) {
modes[i] = new DisplayMode(resolutions[i].width, resolutions[i].height, bpp, resolutions[i].freq);
}
return modes;
} else {
try {
DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
return modes;
} finally {
decDisplay();
}
}
incDisplay();
try {
DisplayMode[] modes = nGetAvailableDisplayModes(getDisplay(), getDefaultScreen(), current_displaymode_extension);
return modes;
} finally {
decDisplay();
}
} finally {
unlockAWT();
}
@ -1044,24 +971,20 @@ final class LinuxDisplay implements DisplayImplementation {
}
}
else {
if (parent_focus_changed && parent_focused) {
setInputFocusUnsafe(getWindow());
parent_focus_changed = false;
if (parent_focused != keyboard_grabbed) {
if (parent_focused) {
grabKeyboard();
input_released = false;
focused = true;
}
else {
ungrabKeyboard();
input_released = true;
focused = false;
}
}
}
}
private void setInputFocusUnsafe(long window) {
try {
nSetInputFocus(getDisplay(), window, CurrentTime);
nSync(getDisplay(), false);
} catch (LWJGLException e) {
// Since we don't have any event timings for XSetInputFocus, a race condition might give a BadMatch, which we'll catch and ignore
LWJGLUtil.log("Got exception while trying to focus: " + e);
}
}
private static native void nSync(long display, boolean throw_away_events) throws LWJGLException;
/**
* This method will check if the parent window is active when running
@ -1106,7 +1029,7 @@ final class LinuxDisplay implements DisplayImplementation {
}
private void setFocused(boolean got_focus, int focus_detail) {
if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || xembedded)
if (focused == got_focus || focus_detail == NotifyDetailNone || focus_detail == NotifyPointer || focus_detail == NotifyPointerRoot || parent != null)
return;
focused = got_focus;
@ -1121,18 +1044,16 @@ final class LinuxDisplay implements DisplayImplementation {
private void releaseInput() {
if (isLegacyFullscreen() || input_released)
return;
if ( keyboard != null )
keyboard.releaseAll();
input_released = true;
updateInputGrab();
if (current_window_mode == FULLSCREEN_NETWM) {
nIconifyWindow(getDisplay(), getWindow(), getDefaultScreen());
try {
if( current_displaymode_extension == XRANDR )
if( current_displaymode_extension == XRANDR && savedXrandrConfig.length > 0 )
{
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
XRandR.restoreConfiguration();
XRandR.setConfiguration( savedXrandrConfig );
return null;
}
});
@ -1359,58 +1280,50 @@ final class LinuxDisplay implements DisplayImplementation {
public void releaseTexImageFromPbuffer(PeerInfo handle, int buffer) {
throw new UnsupportedOperationException();
}
/**
* This method will convert icon bytebuffers into a single bytebuffer
* as the icon format required by _NET_WM_ICON should be in a cardinal
* 32 bit ARGB format i.e. all icons in a single buffer the data starting
* with 32 bit width & height followed by the color data as 32bit ARGB.
*
* @param icons Array of icons in RGBA format
*/
private static ByteBuffer convertIcons(ByteBuffer[] icons) {
int bufferSize = 0;
// calculate size of bytebuffer
for ( ByteBuffer icon : icons ) {
int size = icon.limit() / 4;
int dimension = (int)Math.sqrt(size);
if ( dimension > 0 ) {
bufferSize += 2 * 4; // add 32 bit width & height, 4 bytes each
bufferSize += dimension * dimension * 4;
private static ByteBuffer convertIcon(ByteBuffer icon, int width, int height) {
ByteBuffer icon_rgb = BufferUtils.createByteBuffer(icon.capacity());
int x;
int y;
byte r,g,b;
int depth = 4;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
r = icon.get((x*4)+(y*width*4));
g = icon.get((x*4)+(y*width*4)+1);
b = icon.get((x*4)+(y*width*4)+2);
icon_rgb.put((x*depth)+(y*width*depth), b); // blue
icon_rgb.put((x*depth)+(y*width*depth)+1, g); // green
icon_rgb.put((x*depth)+(y*width*depth)+2, r);
}
}
if (bufferSize == 0) return null;
ByteBuffer icon_argb = BufferUtils.createByteBuffer(bufferSize);//icon.capacity()+(2*4));
icon_argb.order(ByteOrder.BIG_ENDIAN);
for ( ByteBuffer icon : icons ) {
int size = icon.limit() / 4;
int dimension = (int)Math.sqrt(size);
icon_argb.putInt(dimension); // width
icon_argb.putInt(dimension); // height
for (int y = 0; y < dimension; y++) {
for (int x = 0; x < dimension; x++) {
byte r = icon.get((x*4)+(y*dimension*4));
byte g = icon.get((x*4)+(y*dimension*4)+1);
byte b = icon.get((x*4)+(y*dimension*4)+2);
byte a = icon.get((x*4)+(y*dimension*4)+3);
icon_argb.put(a);
icon_argb.put(r);
icon_argb.put(g);
icon_argb.put(b);
}
return icon_rgb;
}
private static ByteBuffer convertIconMask(ByteBuffer icon, int width, int height) {
ByteBuffer icon_mask = BufferUtils.createByteBuffer((icon.capacity()/4)/8);
int x;
int y;
byte a;
int depth = 4;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
a = icon.get((x*4)+(y*width*4)+3);
int mask_index = x + y*width;
int mask_byte_index = mask_index/8;
int mask_bit_index = mask_index%8;
byte bit = (((int)a) & 0xff) >= 127 ? (byte)1 : (byte)0;
byte new_byte = (byte)((icon_mask.get(mask_byte_index) | (bit<<mask_bit_index)) & 0xff);
icon_mask.put(mask_byte_index, new_byte);
}
}
return icon_argb;
return icon_mask;
}
/**
@ -1430,11 +1343,17 @@ final class LinuxDisplay implements DisplayImplementation {
try {
incDisplay();
try {
// get icons as cardinal ARGB format
ByteBuffer icons_data = convertIcons(icons);
if (icons_data == null) return 0;
nSetWindowIcon(getDisplay(), getWindow(), icons_data, icons_data.capacity());//, icon_mask, icon_mask.capacity(), dimension, dimension);
return icons.length;
for ( ByteBuffer icon : icons ) {
int size = icon.limit() / 4;
int dimension = (int)Math.sqrt(size);
if ( dimension > 0 ) {
ByteBuffer icon_rgb = convertIcon(icon, dimension, dimension);
ByteBuffer icon_mask = convertIconMask(icon, dimension, dimension);
nSetWindowIcon(getDisplay(), getWindow(), icon_rgb, icon_rgb.capacity(), icon_mask, icon_mask.capacity(), dimension, dimension);
return 1;
}
}
return 0;
} finally {
decDisplay();
}
@ -1446,16 +1365,8 @@ final class LinuxDisplay implements DisplayImplementation {
}
}
private static native void nSetWindowIcon(long display, long window, ByteBuffer icons_data, int icons_size);
private static native void nSetWindowIcon(long display, long window, ByteBuffer icon_rgb, int icon_rgb_size, ByteBuffer icon_mask, int icon_mask_size, int width, int height);
public int getX() {
return window_x;
}
public int getY() {
return window_y;
}
public int getWidth() {
return window_width;
}
@ -1486,10 +1397,6 @@ final class LinuxDisplay implements DisplayImplementation {
return false;
}
public float getPixelScaleFactor() {
return 1f;
}
/**
* Helper class for managing Compiz's workarounds. We need this to enable Legacy
* Fullscreen Support in Compiz, else we'll have trouble with fullscreen windows

View file

@ -53,7 +53,6 @@ final class LinuxEvent {
public static final int UnmapNotify = 18;
public static final int MapNotify = 19;
public static final int Expose = 12;
public static final int ConfigureNotify = 22;
public static final int ClientMessage = 33;
private final ByteBuffer event_buffer;

View file

@ -257,22 +257,46 @@ final class LinuxKeyboard {
private static native long lookupKeysym(long event_ptr, int index);
private static native long toUpper(long keysym);
private int getKeycode(long event_ptr, int event_state) {
boolean shift = (event_state & (ShiftMask | shift_lock_mask)) != 0;
int group = (event_state & modeswitch_mask) != 0 ? 1 : 0;
private long mapEventToKeySym(long event_ptr, int event_state) {
int group;
long keysym;
if ((event_state & modeswitch_mask) != 0)
group = 1;
else
group = 0;
if ((event_state & numlock_mask) != 0 && isKeypadKeysym(keysym = getKeySym(event_ptr, group, 1))) {
if ( shift )
keysym = getKeySym(event_ptr, group, 0);
} else {
if ((event_state & (ShiftMask | shift_lock_mask)) != 0) {
return getKeySym(event_ptr, group, 0);
} else {
return keysym;
}
} else if ((event_state & (ShiftMask | LockMask)) == 0) {
return getKeySym(event_ptr, group, 0);
} else if ((event_state & ShiftMask) == 0) {
keysym = getKeySym(event_ptr, group, 0);
if ( shift ^ ((event_state & caps_lock_mask) != 0) )
if ((event_state & caps_lock_mask) != 0)
keysym = toUpper(keysym);
return keysym;
} else {
keysym = getKeySym(event_ptr, group, 1);
if ((event_state & caps_lock_mask) != 0)
keysym = toUpper(keysym);
return keysym;
}
return LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym);
}
private static byte getKeyState(int event_type) {
private int getKeycode(long event_ptr, int event_state) {
long keysym = mapEventToKeySym(event_ptr, event_state);
int keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym);
if (keycode == Keyboard.KEY_NONE) {
// Try unshifted keysym mapping
keysym = lookupKeysym(event_ptr, 0);
keycode = LinuxKeycodes.mapKeySymToLWJGLKeyCode(keysym);
}
return keycode;
}
private byte getKeyState(int event_type) {
switch (event_type) {
case LinuxEvent.KeyPress:
return 1;
@ -283,22 +307,10 @@ final class LinuxKeyboard {
}
}
/** This is called when the window loses focus: we release all currently pressed keys. */
void releaseAll() {
for ( int i = 0; i < key_down_buffer.length; i++ ) {
if ( key_down_buffer[i] != 0 ) {
key_down_buffer[i] = 0;
putKeyboardEvent(i, (byte)0, 0, 0L, false);
}
}
}
private void handleKeyEvent(long event_ptr, long millis, int event_type, int event_keycode, int event_state) {
int keycode = getKeycode(event_ptr, event_state);
byte key_state = getKeyState(event_type);
boolean repeat = key_state == key_down_buffer[keycode];
if ( repeat && event_type == LinuxEvent.KeyRelease ) // This can happen for modifier keys after losing and regaining focus.
return;
key_down_buffer[keycode] = key_state;
long nanos = millis*1000000;
if (event_type == LinuxEvent.KeyPress) {

View file

@ -43,23 +43,17 @@ import org.lwjgl.LWJGLException;
import org.lwjgl.input.Mouse;
final class LinuxMouse {
private static final int NUM_BUTTONS = 3;
private static final int POINTER_WARP_BORDER = 10;
// scale the mouse wheel according to DirectInput
private static final int WHEEL_SCALE = 120;
private int button_count;
/* X11 constants */
private static final int Button1 = 1;
private static final int Button2 = 2;
private static final int Button3 = 3;
private static final int Button4 = 4;
private static final int Button5 = 5;
private static final int Button6 = 6; // wheel tilt left *rare*
private static final int Button7 = 7; // wheel tilt right *rare*
private static final int Button8 = 8; // back button
private static final int Button9 = 9; // forward button
private static final int ButtonPress = 4;
private static final int ButtonRelease = 5;
@ -76,7 +70,7 @@ final class LinuxMouse {
private int accum_dx;
private int accum_dy;
private int accum_dz;
private byte[] buttons;
private byte[] buttons = new byte[NUM_BUTTONS];
private EventQueue event_queue;
private long last_event_nanos;
@ -85,8 +79,6 @@ final class LinuxMouse {
this.window = window;
this.input_window = input_window;
this.warp_atom = LinuxDisplay.nInternAtom(display, "_LWJGL", false);
button_count = nGetButtonCount(display);
buttons = new byte[button_count];
reset(false, false);
}
@ -197,8 +189,6 @@ final class LinuxMouse {
}
private static native int nGetWindowHeight(long display, long window);
private static native int nGetWindowWidth(long display, long window);
private static native int nGetButtonCount(long display);
private static native long nQueryPointer(long display, long window, IntBuffer result);
@ -223,23 +213,7 @@ final class LinuxMouse {
case Button3:
button_num = (byte)1;
break;
case Button6:
button_num = (byte)5;
break;
case Button7:
button_num = (byte)6;
break;
case Button8:
button_num = (byte)3; // back button
break;
case Button9:
button_num = (byte)4; // forward button
break;
default:
if (button > Button9 && button <= button_count) {
button_num = (byte)(button-1);
break;
}
return;
}
buttons[button_num] = state;

View file

@ -32,151 +32,32 @@
package org.lwjgl.opengl;
import java.awt.Canvas;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.Insets;
import java.awt.Container;
import java.awt.Component;
import java.awt.Point;
import java.awt.Window;
import java.nio.ByteBuffer;
import javax.swing.SwingUtilities;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
/**
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @author kappaOne <one.kappa@gmail.com>
* @version $Revision$
* $Id$
*/
abstract class MacOSXCanvasPeerInfo extends MacOSXPeerInfo {
private final AWTSurfaceLock awt_surface = new AWTSurfaceLock();
public ByteBuffer window_handle;
protected MacOSXCanvasPeerInfo(PixelFormat pixel_format, ContextAttribs attribs, boolean support_pbuffer) throws LWJGLException {
super(pixel_format, attribs, true, true, support_pbuffer, true);
}
protected void initHandle(Canvas component) throws LWJGLException {
boolean forceCALayer = true;
boolean autoResizable = true; // set the CALayer to autoResize
// Allow the use of a Core Animation Layer only when using non fullscreen Display.setParent() or AWTGLCanvas
final boolean allowCALayer = (Display.getParent() != null && !Display.isFullscreen()) || component instanceof AWTGLCanvas;
String javaVersion = System.getProperty("java.version");
if (javaVersion.startsWith("1.5") || javaVersion.startsWith("1.6")) {
// On Java 7 and newer CALayer mode is the only way to use OpenGL with AWT
// therefore force it on all JVM's except for the older Java 5 and Java 6
// where the older cocoaViewRef NSView method maybe be available.
forceCALayer = false;
}
else if (javaVersion.startsWith("1.7")) {
autoResizable = false;
}
Insets insets = getInsets(component);
int top = insets != null ? insets.top : 0;
int left = insets != null ? insets.left : 0;
window_handle = nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), window_handle, forceCALayer, autoResizable, component.getX()-left, component.getY()-top);
if (javaVersion.startsWith("1.7")) {
// fix for CALayer position not covering Canvas due to a Java 7 bug
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172187
addComponentListener(component);
reSetLayerBounds(component, getHandle());
}
nInitHandle(awt_surface.lockAndGetHandle(component), getHandle(), allowCALayer);
}
private void addComponentListener(final Canvas component) {
ComponentListener[] components = component.getComponentListeners();
// avoid adding duplicate listners by checking if one has already been added
for (int i = 0; i < components.length; i++) {
ComponentListener c = components[i];
if (c.toString() == "CanvasPeerInfoListener") {
return; // already contains the listner below return without adding
}
}
ComponentListener comp = new ComponentListener() {
public void componentHidden(ComponentEvent e) {
}
private static native void nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle, boolean allowCALayer) throws LWJGLException;
public void componentMoved(ComponentEvent e) {
//nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
reSetLayerBounds(component, getHandle());
}
public void componentResized(ComponentEvent e) {
//nSetLayerPosition(getHandle(), component.getX() - left, component.getY() - top);
reSetLayerBounds(component, getHandle());
}
public void componentShown(ComponentEvent e) {
}
public String toString() {
return "CanvasPeerInfoListener";
}
};
component.addComponentListener(comp);
}
private static native ByteBuffer nInitHandle(ByteBuffer surface_buffer, ByteBuffer peer_info_handle, ByteBuffer window_handle, boolean forceCALayer, boolean autoResizable, int x, int y) throws LWJGLException;
private static native void nSetLayerPosition(ByteBuffer peer_info_handle, int x, int y);
private static native void nSetLayerBounds(ByteBuffer peer_info_handle, int x, int y, int width, int height);
/**
* fix for CALayer position not covering Canvas due to a Java 7 bug
* {@link http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172187}
* @param component
* @param peer_info_handle
*/
private static void reSetLayerBounds(Canvas component, ByteBuffer peer_info_handle) {
// report the root parent (peer).
Component peer = SwingUtilities.getRoot(component);
Point rtLoc = SwingUtilities.convertPoint(component.getParent(), component.getLocation(), peer);
int x = (int) rtLoc.getX(), y = (int) rtLoc.getY();
Insets insets = getInsets(component);
x -= insets != null ? insets.left : 0;
y -= insets != null ? insets.top : 0;
// http://hg.openjdk.java.net/jdk8/awt/jdk/rev/65d874d16d59
y = (int) peer.getHeight() - y - (int) component.getHeight();
nSetLayerBounds(peer_info_handle, x, y, component.getWidth(), component.getHeight());
}
protected void doUnlock() throws LWJGLException {
awt_surface.unlock();
}
/**
* @return rootpane insets (peer insets) values.
*/
private static Insets getInsets(Canvas component) {
Container c = SwingUtilities.getRootPane(component);
if(c != null) {
return c.getInsets();
} else {
return new Insets(0, 0, 0, 0);
}
}
}

View file

@ -35,13 +35,11 @@ package org.lwjgl.opengl;
* This is the Display implementation interface. Display delegates
* to implementors of this interface. There is one DisplayImplementation
* for each supported platform.
*
* @author elias_naur <elias_naur@users.sourceforge.net>
* @author mojang
* @author kappaOne <one.kappa@gmail.com>
* @author elias_naur
*/
import java.awt.Canvas;
import java.awt.Cursor;
import java.awt.Robot;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
@ -52,171 +50,96 @@ import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Cursor;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.BufferUtils;
import org.lwjgl.MemoryUtil;
import org.lwjgl.LWJGLException;
import org.lwjgl.LWJGLUtil;
import com.apple.eawt.Application;
import com.apple.eawt.ApplicationAdapter;
import com.apple.eawt.ApplicationEvent;
import static org.lwjgl.opengl.GL11.*;
final class MacOSXDisplay implements DisplayImplementation {
private static final int PBUFFER_HANDLE_SIZE = 24;
private static final int GAMMA_LENGTH = 256;
//private MacOSXCanvasListener canvas_listener;
private MacOSXCanvasListener canvas_listener;
private MacOSXFrame frame;
private Canvas canvas;
private Robot robot;
private MacOSXMouseEventQueue mouse_queue;
private KeyboardEventQueue keyboard_queue;
private DisplayMode requested_mode;
/* Members for native window use */
private MacOSXNativeMouse mouse;
private MacOSXNativeKeyboard keyboard;
private ByteBuffer window;
private ByteBuffer context;
private boolean skipViewportValue = false;
private static final IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
private boolean mouseInsideWindow;
private java.awt.DisplayMode requested_mode;
/* States */
private boolean close_requested;
private boolean native_mode = true;
private boolean updateNativeCursor = false;
private long currentNativeCursor = 0;
private boolean enableHighDPI = false;
private float scaleFactor = 1.0f;
MacOSXDisplay() {
}
private native ByteBuffer nCreateWindow(int x, int y, int width, int height, boolean fullscreen, boolean undecorated, boolean resizable, boolean parented, boolean enableFullscreenModeAPI, boolean enableHighDPI, ByteBuffer peer_info_handle, ByteBuffer window_handle) throws LWJGLException;
private native Object nGetCurrentDisplayMode();
private native void nGetDisplayModes(Object modesList);
private native boolean nIsMiniaturized(ByteBuffer window_handle);
private native boolean nIsFocused(ByteBuffer window_handle);
private native void nSetResizable(ByteBuffer window_handle, boolean resizable);
private native void nResizeWindow(ByteBuffer window_handle, int x, int y, int width, int height);
private native boolean nWasResized(ByteBuffer window_handle);
private native int nGetX(ByteBuffer window_handle);
private native int nGetY(ByteBuffer window_handle);
private native int nGetWidth(ByteBuffer window_handle);
private native int nGetHeight(ByteBuffer window_handle);
private native boolean nIsNativeMode(ByteBuffer peer_info_handle);
private static boolean isUndecorated() {
return Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
}
public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
boolean fullscreen = Display.isFullscreen();
boolean resizable = Display.isResizable();
boolean parented = (parent != null) && !fullscreen;
// OS X fullscreen mode API is only available on OS X 10.7+
boolean enableFullscreenModeAPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
!Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.disableOSXFullscreenModeAPI");
// OS X high DPI mode is only available on OS X 10.7+
enableHighDPI = LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) && parent == null &&
(Display.getPrivilegedBoolean("org.lwjgl.opengl.Display.enableHighDPI") || fullscreen);
if (parented) this.canvas = parent;
else this.canvas = null;
close_requested = false;
DrawableGL gl_drawable = (DrawableGL)Display.getDrawable();
PeerInfo peer_info = gl_drawable.peer_info;
ByteBuffer peer_handle = peer_info.lockAndGetHandle();
ByteBuffer window_handle = parented ? ((MacOSXCanvasPeerInfo)peer_info).window_handle : window;
try {
window = nCreateWindow(x, y, mode.getWidth(), mode.getHeight(),
fullscreen, isUndecorated(), resizable,
parented, enableFullscreenModeAPI, enableHighDPI, peer_handle, window_handle);
if (fullscreen) {
// when going to fullscreen viewport is set to screen size by Cocoa, ignore this value
skipViewportValue = true;
// if starting in fullscreen then set initial viewport to displaymode size
current_viewport.put(2, mode.getWidth());
current_viewport.put(3, mode.getHeight());
}
native_mode = nIsNativeMode(peer_handle);
if (!native_mode) {
robot = AWTUtil.createRobot(canvas);
}
} catch (LWJGLException e) {
destroyWindow();
throw e;
} finally {
peer_info.unlock();
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
Application.getApplication().addApplicationListener(new ApplicationAdapter() {
public void handleQuit(ApplicationEvent event) {
doHandleQuit();
}
});
return null;
}
});
} catch (Throwable e) {
/**
* In an applet environment, referencing com.apple.eawt.Application can fail with
* a native exception. So log any exceptions instead of re-throwing.
*/
LWJGLUtil.log("Failed to register quit handler: " + e.getMessage());
}
}
public void doHandleQuit() {
public void createWindow(final DrawableLWJGL drawable, DisplayMode mode, Canvas parent, int x, int y) throws LWJGLException {
boolean fullscreen = Display.isFullscreen();
hideUI(fullscreen);
close_requested = false;
try {
if (parent == null) {
frame = new MacOSXFrame(mode, requested_mode, fullscreen, x, y);
canvas = frame.getCanvas();
} else {
frame = null;
canvas = parent;
}
canvas_listener = new MacOSXCanvasListener(canvas);
robot = AWTUtil.createRobot(canvas);
} catch (LWJGLException e) {
destroyWindow();
throw e;
}
}
private void doHandleQuit() {
synchronized (this) {
close_requested = true;
}
}
public void mouseInsideWindow(boolean inside) {
synchronized (this) {
mouseInsideWindow = inside;
}
updateNativeCursor = true;
}
public void setScaleFactor(float scale) {
synchronized (this) {
scaleFactor = scale;
}
}
public native void nDestroyCALayer(ByteBuffer peer_info_handle);
public native void nDestroyWindow(ByteBuffer window_handle);
public void destroyWindow() {
if (!native_mode) {
DrawableGL gl_drawable = (DrawableGL)Display.getDrawable();
PeerInfo peer_info = gl_drawable.peer_info;
if (peer_info != null) {
ByteBuffer peer_handle = peer_info.getHandle();
nDestroyCALayer(peer_handle);
}
robot = null;
if (canvas_listener != null) {
canvas_listener.disableListeners();
canvas_listener = null;
}
nDestroyWindow(window);
if (frame != null) {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
if (MacOSXFrame.getDevice().getFullScreenWindow() == frame)
MacOSXFrame.getDevice().setFullScreenWindow(null);
return null;
}
});
if (frame.isDisplayable())
frame.dispose();
frame = null;
}
hideUI(false);
}
public int getGammaRampLength() {
@ -232,80 +155,81 @@ final class MacOSXDisplay implements DisplayImplementation {
public String getVersion() {
return null;
}
private static boolean equals(DisplayMode mode1, DisplayMode mode2) {
return mode1.getWidth() == mode2.getWidth() && mode1.getHeight() == mode2.getHeight()
&& mode1.getBitsPerPixel() == mode2.getBitsPerPixel() && mode1.getFrequency() == mode2.getFrequency();
private static boolean equals(java.awt.DisplayMode awt_mode, DisplayMode mode) {
return awt_mode.getWidth() == mode.getWidth() && awt_mode.getHeight() == mode.getHeight()
&& awt_mode.getBitDepth() == mode.getBitsPerPixel() && awt_mode.getRefreshRate() == mode.getFrequency();
}
public void switchDisplayMode(DisplayMode mode) throws LWJGLException {
DisplayMode[] modes = getAvailableDisplayModes();
for (DisplayMode available_mode : modes) {
if (equals(available_mode, mode)) {
requested_mode = available_mode;
java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
for ( java.awt.DisplayMode awt_mode : awt_modes ) {
if (equals(awt_mode, mode)) {
requested_mode = awt_mode;
return;
}
}
throw new LWJGLException(mode + " is not supported");
}
public void resetDisplayMode() {
requested_mode = null;
if (MacOSXFrame.getDevice().getFullScreenWindow() != null)
MacOSXFrame.getDevice().setFullScreenWindow(null);
requested_mode = null;
restoreGamma();
}
private native void restoreGamma();
public Object createDisplayMode(int width, int height, int bitsPerPixel, int refreshRate) {
return new DisplayMode(width, height, bitsPerPixel, refreshRate);
private static DisplayMode createLWJGLDisplayMode(java.awt.DisplayMode awt_mode) {
int bit_depth;
int refresh_rate;
int awt_bit_depth = awt_mode.getBitDepth();
int awt_refresh_rate = awt_mode.getRefreshRate();
if (awt_bit_depth != java.awt.DisplayMode.BIT_DEPTH_MULTI)
bit_depth = awt_bit_depth;
else
bit_depth = 32; // Assume the best bit depth
if (awt_refresh_rate != java.awt.DisplayMode.REFRESH_RATE_UNKNOWN)
refresh_rate = awt_refresh_rate;
else
refresh_rate = 0;
return new DisplayMode(awt_mode.getWidth(), awt_mode.getHeight(), bit_depth, refresh_rate);
}
public DisplayMode init() throws LWJGLException {
return (DisplayMode) nGetCurrentDisplayMode();
}
public void addDisplayMode(Object modesList, int width, int height, int bitsPerPixel, int refreshRate) {
List<DisplayMode> modes = (List<DisplayMode>) modesList;
DisplayMode displayMode = new DisplayMode(width, height, bitsPerPixel, refreshRate);
modes.add(displayMode);
return createLWJGLDisplayMode(MacOSXFrame.getDevice().getDisplayMode());
}
public DisplayMode[] getAvailableDisplayModes() throws LWJGLException {
java.awt.DisplayMode[] awt_modes = MacOSXFrame.getDevice().getDisplayModes();
List<DisplayMode> modes = new ArrayList<DisplayMode>();
nGetDisplayModes(modes); // will populate the above list
modes.add(Display.getDesktopDisplayMode()); // add desktop resolution as scaled resolutions do not appear
for ( java.awt.DisplayMode awt_mode : awt_modes )
if ( awt_mode.getBitDepth() >= 16 )
modes.add(createLWJGLDisplayMode(awt_mode));
return modes.toArray(new DisplayMode[modes.size()]);
}
private native void nSetTitle(ByteBuffer window_handle, ByteBuffer title_buffer);
public void setTitle(String title) {
ByteBuffer buffer = MemoryUtil.encodeUTF8(title);
nSetTitle(window, buffer);
if (frame != null)
frame.setTitle(title);
}
public boolean isCloseRequested() {
boolean result;
synchronized (this) {
result = close_requested;
result = close_requested || (frame != null && frame.syncIsCloseRequested());
close_requested = false;
}
return result;
}
public boolean isVisible() {
return true;
return frame == null || frame.syncIsVisible();
}
public boolean isActive() {
if (native_mode) {
return nIsFocused(window);
}
else {
return Display.getParent().hasFocus();
}
return canvas.isFocusOwner();
}
public Canvas getCanvas() {
@ -313,7 +237,7 @@ final class MacOSXDisplay implements DisplayImplementation {
}
public boolean isDirty() {
return false;
return frame != null && frame.getCanvas().syncIsDirty();
}
public PeerInfo createPeerInfo(PixelFormat pixel_format, ContextAttribs attribs) throws LWJGLException {
@ -324,37 +248,71 @@ final class MacOSXDisplay implements DisplayImplementation {
}
}
private static final IntBuffer current_viewport = BufferUtils.createIntBuffer(16);
public void update() {
boolean should_update = true;
boolean should_update = canvas_listener.syncShouldUpdateContext();
/*
* Workaround for the "white screen in fullscreen mode" problem
*
* Sometimes, switching from windowed mode to fullscreen or simply creating the Display
* in fullscreen mode will result in the context not being bound to the window correctly.
* The program runs fine, but the canvas background (white) is shown instead of the context
* front buffer.
*
* I've discovered that re-binding the context with another setView() won't fix the problem, while a
* clearDrawable() followed by a setView() does work. A straightforward workaround would be
* to simply run the combination at every update(). This is not sufficient, since the clearDrawable()
* call makes the the background appear shortly, causing visual artifacts.
* What we really need is a way to detect that a setView() failed, and then do the magic combo. I've not
* been able to find such a detection so alternatively I'm triggering the combo if the display is fullscreen
* (I've not seen the white screen problem in windowed mode) and if the canvas has gotten a paint message or
* if its update flag was set.
*
* My testing seems to indicate that the workaround works, since I've not seen the problem after the fix.
*
* - elias
*/
DrawableGL drawable = (DrawableGL)Display.getDrawable();
if (Display.isFullscreen() && (frame != null && frame.getCanvas().syncCanvasPainted() || should_update)) {
try {
MacOSXContextImplementation.resetView(drawable.peer_info, drawable.context);
} catch (LWJGLException e) {
LWJGLUtil.log("Failed to reset context: " + e);
}
}
if (should_update) {
// Save the current viewport size as cocoa will automatically
// set the viewport size to the window size on context update
if (skipViewportValue) skipViewportValue = false;
else glGetInteger(GL_VIEWPORT, current_viewport);
drawable.context.update();
// restore the original viewport size that was set before the update
/* This is necessary to make sure the context won't "forget" about the view size */
glGetInteger(GL_VIEWPORT, current_viewport);
glViewport(current_viewport.get(0), current_viewport.get(1), current_viewport.get(2), current_viewport.get(3));
}
if (native_mode && updateNativeCursor) {
updateNativeCursor = false;
try {
setNativeCursor(currentNativeCursor);
} catch (LWJGLException e) {
e.printStackTrace();
}
if (frame != null && mouse_queue != null) {
if (frame.syncShouldReleaseCursor())
MacOSXMouseEventQueue.nGrabMouse(false);
if (frame.syncShouldWarpCursor())
mouse_queue.warpCursor();
}
}
/**
* This is an interface to the native Carbon call
* SetSystemUIMode. It is used to hide the dock in a way
* that will prevent AWT from shifting the fullscreen window
*
* The workaround is not necessary on 10.4, and since 10.4 shows
* instability problems calling SetSystemUIMode, we'll only call it
* when the OS version is 10.3 or lower.
*/
private void hideUI(boolean hide) {
if (!LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4))
nHideUI(hide);
}
private native void nHideUI(boolean hide);
public void reshape(int x, int y, int width, int height) {
//if (native_mode) {
// nResizeWindow(window, x, y, width, height);
//}
if (frame != null)
frame.resize(x, y, width, height);
}
/* Mouse */
@ -367,180 +325,109 @@ final class MacOSXDisplay implements DisplayImplementation {
}
public void createMouse() throws LWJGLException {
if (native_mode) {
mouse = new MacOSXNativeMouse(this, window);
mouse.register();
}
else {
this.mouse_queue = new MacOSXMouseEventQueue(canvas);
mouse_queue.register();
}
this.mouse_queue = new MacOSXMouseEventQueue(canvas);
mouse_queue.register();
}
public void destroyMouse() {
if (native_mode) {
// restore default native cursor
try {
MacOSXNativeMouse.setCursor(0);
} catch (LWJGLException e) {};
// release any mouse grab
grabMouse(false);
if (mouse != null) {
mouse.unregister();
}
mouse = null;
}
else {
if (mouse_queue != null) {
MacOSXMouseEventQueue.nGrabMouse(false);
mouse_queue.unregister();
}
this.mouse_queue = null;
if (mouse_queue != null) {
MacOSXMouseEventQueue.nGrabMouse(false);
mouse_queue.unregister();
}
this.mouse_queue = null;
}
public void pollMouse(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
if (native_mode) {
mouse.poll(coord_buffer, buttons_buffer);
}
else {
mouse_queue.poll(coord_buffer, buttons_buffer);
}
mouse_queue.poll(coord_buffer, buttons_buffer);
}
public void readMouse(ByteBuffer buffer) {
if (native_mode) {
mouse.copyEvents(buffer);
}
else {
mouse_queue.copyEvents(buffer);
}
mouse_queue.copyEvents(buffer);
}
public void grabMouse(boolean grab) {
if (native_mode) {
mouse.setGrabbed(grab);
}
else {
mouse_queue.setGrabbed(grab);
}
mouse_queue.setGrabbed(grab);
}
public int getNativeCursorCapabilities() {
if (native_mode) {
return Cursor.CURSOR_ONE_BIT_TRANSPARENCY | Cursor.CURSOR_8_BIT_ALPHA | Cursor.CURSOR_ANIMATION;
}
return AWTUtil.getNativeCursorCapabilities();
}
public void setCursorPosition(int x, int y) {
if (native_mode) {
if (mouse != null) {
mouse.setCursorPosition(x, y);
}
}
//else {
//MacOSXMouseEventQueue.nWarpCursor(x, y);
//}
AWTUtil.setCursorPosition(canvas, robot, x, y);
}
public void setNativeCursor(Object handle) throws LWJGLException {
if (native_mode) {
currentNativeCursor = getCursorHandle(handle);
if (Display.isCreated()) {
if (mouseInsideWindow) MacOSXNativeMouse.setCursor(currentNativeCursor);
else MacOSXNativeMouse.setCursor(0); // restore default cursor if outside Display
}
}
Cursor awt_cursor = (Cursor)handle;
if (frame != null)
frame.setCursor(awt_cursor);
}
public int getMinCursorSize() {
return 1;
return AWTUtil.getMinCursorSize();
}
public int getMaxCursorSize() {
// as there is no max cursor size limit on OS X
// return the max cursor size as half the screen resolution
DisplayMode dm = Display.getDesktopDisplayMode();
return Math.min(dm.getWidth(), dm.getHeight()) / 2;
return AWTUtil.getMaxCursorSize();
}
/* Keyboard */
public void createKeyboard() throws LWJGLException {
if (native_mode) {
this.keyboard = new MacOSXNativeKeyboard(window);
keyboard.register();
}
else {
this.keyboard_queue = new KeyboardEventQueue(canvas);
keyboard_queue.register();
}
this.keyboard_queue = new KeyboardEventQueue(canvas);
keyboard_queue.register();
}
public void destroyKeyboard() {
if (native_mode) {
if (keyboard != null) {
keyboard.unregister();
}
keyboard = null;
}
else {
if (keyboard_queue != null) {
keyboard_queue.unregister();
}
this.keyboard_queue = null;
}
if (keyboard_queue != null)
keyboard_queue.unregister();
this.keyboard_queue = null;
}
public void pollKeyboard(ByteBuffer keyDownBuffer) {
if (native_mode) {
keyboard.poll(keyDownBuffer);
}
else {
keyboard_queue.poll(keyDownBuffer);
}
keyboard_queue.poll(keyDownBuffer);
}
public void readKeyboard(ByteBuffer buffer) {
if (native_mode) {
keyboard.copyEvents(buffer);
keyboard_queue.copyEvents(buffer);
}
/* public int isStateKeySet(int key) {
int awt_key;
switch (key) {
case Keyboard.KEY_CAPITAL:
awt_key = KeyEvent.VK_CAPS_LOCK;
break;
case Keyboard.KEY_NUMLOCK:
awt_key = KeyEvent.VK_NUM_LOCK;
break;
case Keyboard.KEY_SYSRQ:
awt_key = KeyEvent.VK_SCROLL_LOCK;
break;
default:
return Keyboard.STATE_UNKNOWN;
}
else {
keyboard_queue.copyEvents(buffer);
try {
boolean state = Toolkit.getDefaultToolkit().getLockingKeyState(awt_key);
return state ? Keyboard.STATE_ON : Keyboard.STATE_OFF;
} catch (Exception e) {
LWJGLUtil.log("Failed to query key state: " + e);
return Keyboard.STATE_UNKNOWN;
}
}
*/
/** Native cursor handles */
public Object createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
if (native_mode) {
long cursor = MacOSXNativeMouse.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
return cursor;
}
else {
return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
}
return AWTUtil.createCursor(width, height, xHotspot, yHotspot, numImages, images, delays);
}
public void destroyCursor(Object cursor_handle) {
long handle = getCursorHandle(cursor_handle);
// reset current cursor if same
if (currentNativeCursor == handle) {
currentNativeCursor = 0;
}
MacOSXNativeMouse.destroyCursor(handle);
}
private static long getCursorHandle(Object cursor_handle) {
return cursor_handle != null ? (Long)cursor_handle : 0;
}
public int getPbufferCapabilities() {
return Pbuffer.PBUFFER_SUPPORTED;
if (LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 3))
return Pbuffer.PBUFFER_SUPPORTED;
else
return 0;
}
public boolean isBufferLost(PeerInfo handle) {
@ -578,7 +465,7 @@ final class MacOSXDisplay implements DisplayImplementation {
* @return number of icons used.
*/
public int setIcon(ByteBuffer[] icons) {
/*int size = 0;
/* int size = 0;
int biggest = -1;
for (int i=0;i<icons.length;i++) {
@ -608,37 +495,25 @@ final class MacOSXDisplay implements DisplayImplementation {
// Don't use any icon, since Mac OS X windows don't have window icons
return 0;
}
public int getX() {
return nGetX(window);
}
public int getY() {
return nGetY(window);
}
public int getWidth() {
return nGetWidth(window);
return frame.getWidth();
}
public int getHeight() {
return nGetHeight(window);
return frame.getHeight();
}
public boolean isInsideWindow() {
return mouseInsideWindow;
}
public boolean isInsideWindow() {
return true;
}
public void setResizable(boolean resizable) {
nSetResizable(window, resizable);
public void setResizable(boolean resizable) {
frame.setResizable(resizable);
}
public boolean wasResized() {
return nWasResized(window);
}
public float getPixelScaleFactor() {
return (enableHighDPI && !Display.isFullscreen()) ? scaleFactor : 1f;
return canvas_listener.wasResized();
}
}

View file

@ -0,0 +1,228 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
/**
* This is the Mac OS X AWT Frame. It contains thread safe
* methods to manipulateit from non-AWT threads
* @author elias_naur
*/
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import org.lwjgl.LWJGLException;
final class MacOSXFrame extends Frame implements WindowListener, ComponentListener {
private static final long serialVersionUID = -5823294716668988777L;
private final MacOSXGLCanvas canvas;
private boolean close_requested;
/* States */
private Rectangle bounds;
private boolean active;
private boolean minimized;
private boolean should_warp_cursor;
private boolean should_release_cursor;
MacOSXFrame(DisplayMode mode, final java.awt.DisplayMode requested_mode, boolean fullscreen, int x, int y) throws LWJGLException {
setResizable(Display.isResizable());
addWindowListener(this);
addComponentListener(this);
canvas = new MacOSXGLCanvas();
canvas.setFocusTraversalKeysEnabled(false);
add(canvas, BorderLayout.CENTER);
boolean undecorated = Display.getPrivilegedBoolean("org.lwjgl.opengl.Window.undecorated");
setUndecorated(fullscreen || undecorated);
if ( fullscreen ) {
try {
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
public Object run() throws Exception {
getDevice().setFullScreenWindow(MacOSXFrame.this);
getDevice().setDisplayMode(requested_mode);
java.awt.DisplayMode real_mode = getDevice().getDisplayMode();
/** For some strange reason, the display mode is sometimes silently capped even though the mode is reported as supported */
if ( requested_mode.getWidth() != real_mode.getWidth() || requested_mode.getHeight() != real_mode.getHeight() ) {
getDevice().setFullScreenWindow(null);
if (isDisplayable())
dispose();
throw new LWJGLException("AWT capped mode: requested mode = " + requested_mode.getWidth() + "x" + requested_mode.getHeight() +
" but got " + real_mode.getWidth() + " " + real_mode.getHeight());
}
return null;
}
});
} catch (PrivilegedActionException e) {
throw new LWJGLException(e);
}
}
pack();
resize(x, y, mode.getWidth(), mode.getHeight());
setVisible(true);
requestFocus();
canvas.requestFocus();
updateBounds();
}
public void resize(int x, int y, int width, int height) {
Insets insets = getInsets();
setBounds(x, y, width + insets.left + insets.right, height + insets.top + insets.bottom);
}
public Rectangle syncGetBounds() {
synchronized ( this ) {
return bounds;
}
}
public void componentShown(ComponentEvent e) {
}
public void componentHidden(ComponentEvent e) {
}
private void updateBounds() {
synchronized ( this ) {
bounds = getBounds();
}
}
public void componentResized(ComponentEvent e) {
updateBounds();
}
public void componentMoved(ComponentEvent e) {
updateBounds();
}
public static GraphicsDevice getDevice() {
GraphicsEnvironment g_env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = g_env.getDefaultScreenDevice();
return device;
}
public void windowIconified(WindowEvent e) {
synchronized ( this ) {
minimized = true;
}
}
public void windowDeiconified(WindowEvent e) {
synchronized ( this ) {
minimized = false;
}
}
public void windowOpened(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
synchronized ( this ) {
close_requested = true;
}
}
public void windowDeactivated(WindowEvent e) {
synchronized ( this ) {
active = false;
should_release_cursor = true;
should_warp_cursor = false;
}
}
public void windowActivated(WindowEvent e) {
synchronized ( this ) {
active = true;
should_warp_cursor = true;
should_release_cursor = false;
}
}
public boolean syncIsCloseRequested() {
boolean result;
synchronized ( this ) {
result = close_requested;
close_requested = false;
}
return result;
}
public boolean syncIsVisible() {
synchronized ( this ) {
return !minimized;
}
}
public boolean syncIsActive() {
synchronized ( this ) {
return active;
}
}
public MacOSXGLCanvas getCanvas() {
return canvas;
}
public boolean syncShouldReleaseCursor() {
boolean result;
synchronized ( this ) {
result = should_release_cursor;
should_release_cursor = false;
}
return result;
}
public boolean syncShouldWarpCursor() {
boolean result;
synchronized ( this ) {
result = should_warp_cursor;
should_warp_cursor = false;
}
return result;
}
}

View file

@ -96,13 +96,13 @@ final class MacOSXMouseEventQueue extends MouseEventQueue {
// If we're going to warp the cursor position, we'll skip the next event to avoid bogus delta values
skip_event = isGrabbed();
}
if (isGrabbed()) {
/* if (isGrabbed()) {
Rectangle bounds = getComponent().getBounds();
Point location_on_screen = getComponent().getLocationOnScreen();
int x = location_on_screen.x + bounds.width/2;
int y = location_on_screen.y + bounds.height/2;
nWarpCursor(x, y);
}
}*/
}
private static native void getMouseDeltas(IntBuffer delta_buffer);
@ -110,4 +110,4 @@ final class MacOSXMouseEventQueue extends MouseEventQueue {
private static native void nWarpCursor(int x, int y);
static native void nGrabMouse(boolean grab);
}
}

View file

@ -1,297 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
/**
* A native implementation of a LWJGL compatible Keyboard event queue.
* @author elias_naur
* @author mojang
*/
import java.awt.event.KeyEvent;
import java.util.HashMap;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import org.lwjgl.input.Keyboard;
final class MacOSXNativeKeyboard extends EventQueue {
private final byte[] key_states = new byte[Keyboard.KEYBOARD_SIZE];
/** Event scratch array */
private final ByteBuffer event = ByteBuffer.allocate(Keyboard.EVENT_SIZE);
private ByteBuffer window_handle;
private boolean has_deferred_event;
private long deferred_nanos;
private int deferred_key_code;
private byte deferred_key_state;
private int deferred_character;
private HashMap<Short, Integer> nativeToLwjglMap;
MacOSXNativeKeyboard(ByteBuffer window_handle) {
super(Keyboard.EVENT_SIZE);
nativeToLwjglMap = new HashMap<Short, Integer>();
initKeyboardMappings();
this.window_handle = window_handle;
}
private native void nRegisterKeyListener(ByteBuffer window_handle);
private native void nUnregisterKeyListener(ByteBuffer window_handle);
// These are from: <HIToolbox/Events.h>
private void initKeyboardMappings() {
nativeToLwjglMap.put((short)0x1D, Keyboard.KEY_0);
nativeToLwjglMap.put((short)0x12, Keyboard.KEY_1);
nativeToLwjglMap.put((short)0x13, Keyboard.KEY_2);
nativeToLwjglMap.put((short)0x14, Keyboard.KEY_3);
nativeToLwjglMap.put((short)0x15, Keyboard.KEY_4);
nativeToLwjglMap.put((short)0x17, Keyboard.KEY_5);
nativeToLwjglMap.put((short)0x16, Keyboard.KEY_6);
nativeToLwjglMap.put((short)0x1A, Keyboard.KEY_7);
nativeToLwjglMap.put((short)0x1C, Keyboard.KEY_8);
nativeToLwjglMap.put((short)0x19, Keyboard.KEY_9);
nativeToLwjglMap.put((short)0x00, Keyboard.KEY_A);
nativeToLwjglMap.put((short)0x0B, Keyboard.KEY_B);
nativeToLwjglMap.put((short)0x08, Keyboard.KEY_C);
nativeToLwjglMap.put((short)0x02, Keyboard.KEY_D);
nativeToLwjglMap.put((short)0x0E, Keyboard.KEY_E);
nativeToLwjglMap.put((short)0x03, Keyboard.KEY_F);
nativeToLwjglMap.put((short)0x05, Keyboard.KEY_G);
nativeToLwjglMap.put((short)0x04, Keyboard.KEY_H);
nativeToLwjglMap.put((short)0x22, Keyboard.KEY_I);
nativeToLwjglMap.put((short)0x26, Keyboard.KEY_J);
nativeToLwjglMap.put((short)0x28, Keyboard.KEY_K);
nativeToLwjglMap.put((short)0x25, Keyboard.KEY_L);
nativeToLwjglMap.put((short)0x2E, Keyboard.KEY_M);
nativeToLwjglMap.put((short)0x2D, Keyboard.KEY_N);
nativeToLwjglMap.put((short)0x1F, Keyboard.KEY_O);
nativeToLwjglMap.put((short)0x23, Keyboard.KEY_P);
nativeToLwjglMap.put((short)0x0C, Keyboard.KEY_Q);
nativeToLwjglMap.put((short)0x0F, Keyboard.KEY_R);
nativeToLwjglMap.put((short)0x01, Keyboard.KEY_S);
nativeToLwjglMap.put((short)0x11, Keyboard.KEY_T);
nativeToLwjglMap.put((short)0x20, Keyboard.KEY_U);
nativeToLwjglMap.put((short)0x09, Keyboard.KEY_V);
nativeToLwjglMap.put((short)0x0D, Keyboard.KEY_W);
nativeToLwjglMap.put((short)0x07, Keyboard.KEY_X);
nativeToLwjglMap.put((short)0x10, Keyboard.KEY_Y);
nativeToLwjglMap.put((short)0x06, Keyboard.KEY_Z);
nativeToLwjglMap.put((short)0x2A, Keyboard.KEY_BACKSLASH);
nativeToLwjglMap.put((short)0x2B, Keyboard.KEY_COMMA);
nativeToLwjglMap.put((short)0x18, Keyboard.KEY_EQUALS);
nativeToLwjglMap.put((short)0x21, Keyboard.KEY_LBRACKET);
nativeToLwjglMap.put((short)0x1B, Keyboard.KEY_MINUS);
nativeToLwjglMap.put((short)0x27, Keyboard.KEY_APOSTROPHE);
nativeToLwjglMap.put((short)0x1E, Keyboard.KEY_RBRACKET);
nativeToLwjglMap.put((short)0x29, Keyboard.KEY_SEMICOLON);
nativeToLwjglMap.put((short)0x2C, Keyboard.KEY_SLASH);
nativeToLwjglMap.put((short)0x2F, Keyboard.KEY_PERIOD);
nativeToLwjglMap.put((short)0x32, Keyboard.KEY_GRAVE);
nativeToLwjglMap.put((short)0x41, Keyboard.KEY_DECIMAL);
nativeToLwjglMap.put((short)0x43, Keyboard.KEY_MULTIPLY);
nativeToLwjglMap.put((short)0x45, Keyboard.KEY_ADD);
nativeToLwjglMap.put((short)0x47, Keyboard.KEY_CLEAR);
nativeToLwjglMap.put((short)0x4B, Keyboard.KEY_DIVIDE);
nativeToLwjglMap.put((short)0x4C, Keyboard.KEY_NUMPADENTER);
nativeToLwjglMap.put((short)0x4E, Keyboard.KEY_SUBTRACT);
nativeToLwjglMap.put((short)0x51, Keyboard.KEY_NUMPADEQUALS);
nativeToLwjglMap.put((short)0x52, Keyboard.KEY_NUMPAD0);
nativeToLwjglMap.put((short)0x53, Keyboard.KEY_NUMPAD1);
nativeToLwjglMap.put((short)0x54, Keyboard.KEY_NUMPAD2);
nativeToLwjglMap.put((short)0x55, Keyboard.KEY_NUMPAD3);
nativeToLwjglMap.put((short)0x56, Keyboard.KEY_NUMPAD4);
nativeToLwjglMap.put((short)0x57, Keyboard.KEY_NUMPAD5);
nativeToLwjglMap.put((short)0x58, Keyboard.KEY_NUMPAD6);
nativeToLwjglMap.put((short)0x59, Keyboard.KEY_NUMPAD7);
nativeToLwjglMap.put((short)0x5B, Keyboard.KEY_NUMPAD8);
nativeToLwjglMap.put((short)0x5C, Keyboard.KEY_NUMPAD9);
nativeToLwjglMap.put((short)0x24, Keyboard.KEY_RETURN);
nativeToLwjglMap.put((short)0x30, Keyboard.KEY_TAB);
nativeToLwjglMap.put((short)0x31, Keyboard.KEY_SPACE);
nativeToLwjglMap.put((short)0x33, Keyboard.KEY_BACK);
nativeToLwjglMap.put((short)0x35, Keyboard.KEY_ESCAPE);
nativeToLwjglMap.put((short)0x36, Keyboard.KEY_RMETA); // not in Events.h - works on MBP
nativeToLwjglMap.put((short)0x37, Keyboard.KEY_LMETA);
nativeToLwjglMap.put((short)0x38, Keyboard.KEY_LSHIFT);
nativeToLwjglMap.put((short)0x39, Keyboard.KEY_CAPITAL);
nativeToLwjglMap.put((short)0x3A, Keyboard.KEY_LMENU);
nativeToLwjglMap.put((short)0x3B, Keyboard.KEY_LCONTROL);
nativeToLwjglMap.put((short)0x3C, Keyboard.KEY_RSHIFT);
nativeToLwjglMap.put((short)0x3D, Keyboard.KEY_RMENU);
nativeToLwjglMap.put((short)0x3E, Keyboard.KEY_RCONTROL);
nativeToLwjglMap.put((short)0x3F, Keyboard.KEY_FUNCTION);
nativeToLwjglMap.put((short)0x77, Keyboard.KEY_END);
nativeToLwjglMap.put((short)0x7A, Keyboard.KEY_F1);
nativeToLwjglMap.put((short)0x78, Keyboard.KEY_F2);
nativeToLwjglMap.put((short)0x63, Keyboard.KEY_F3);
nativeToLwjglMap.put((short)0x76, Keyboard.KEY_F4);
nativeToLwjglMap.put((short)0x60, Keyboard.KEY_F5);
nativeToLwjglMap.put((short)0x61, Keyboard.KEY_F6);
nativeToLwjglMap.put((short)0x62, Keyboard.KEY_F7);
nativeToLwjglMap.put((short)0x64, Keyboard.KEY_F8);
nativeToLwjglMap.put((short)0x65, Keyboard.KEY_F9);
nativeToLwjglMap.put((short)0x6D, Keyboard.KEY_F10);
nativeToLwjglMap.put((short)0x67, Keyboard.KEY_F11);
nativeToLwjglMap.put((short)0x6F, Keyboard.KEY_F12);
nativeToLwjglMap.put((short)0x69, Keyboard.KEY_F13);
nativeToLwjglMap.put((short)0x6B, Keyboard.KEY_F14);
nativeToLwjglMap.put((short)0x71, Keyboard.KEY_F15);
nativeToLwjglMap.put((short)0x6A, Keyboard.KEY_F16);
nativeToLwjglMap.put((short)0x40, Keyboard.KEY_F17);
nativeToLwjglMap.put((short)0x4F, Keyboard.KEY_F18);
nativeToLwjglMap.put((short)0x50, Keyboard.KEY_F19);
// nativeToLwjglMap.put((short)0x5A, Keyboard.KEY_F20);
nativeToLwjglMap.put((short)0x75, Keyboard.KEY_DELETE);
nativeToLwjglMap.put((short)0x72, Keyboard.KEY_INSERT); // 'Help' in Events.h
nativeToLwjglMap.put((short)0x73, Keyboard.KEY_HOME);
// nativeToLwjglMap.put((short)0xA4, Keyboard.KEY_MUTE);
nativeToLwjglMap.put((short)0x79, Keyboard.KEY_NEXT);
nativeToLwjglMap.put((short)0x74, Keyboard.KEY_PRIOR);
// nativeToLwjglMap.put((short)0x49, Keyboard.KEY_VOLUMEDOWN);
// nativeToLwjglMap.put((short)0x48, Keyboard.KEY_VOLUMEUP);
nativeToLwjglMap.put((short)0x7B, Keyboard.KEY_LEFT);
nativeToLwjglMap.put((short)0x7C, Keyboard.KEY_RIGHT);
nativeToLwjglMap.put((short)0x7D, Keyboard.KEY_DOWN);
nativeToLwjglMap.put((short)0x7E, Keyboard.KEY_UP);
nativeToLwjglMap.put((short)0x0A, Keyboard.KEY_SECTION);
nativeToLwjglMap.put((short)0x6E, Keyboard.KEY_APPS); // not in Events.h
nativeToLwjglMap.put((short)0x129, Keyboard.KEY_COLON); // not in Events.h -- do we need it?
}
public void register() {
nRegisterKeyListener(window_handle);
}
public void unregister() {
nUnregisterKeyListener(window_handle);
}
public void putKeyboardEvent(int key_code, byte state, int character, long nanos, boolean repeat) {
((Buffer)event).clear();
event.putInt(key_code).put(state).putInt(character).putLong(nanos).put(repeat ? (byte)1 : (byte)0);
((Buffer)event).flip();
putEvent(event);
}
public synchronized void poll(ByteBuffer key_down_buffer) {
flushDeferredEvent();
int old_position = key_down_buffer.position();
key_down_buffer.put(key_states);
((Buffer)key_down_buffer).position(old_position);
}
public synchronized void copyEvents(ByteBuffer dest) {
flushDeferredEvent();
super.copyEvents(dest);
}
private synchronized void handleKey(int key_code, byte state, int character, long nanos) {
if (character == KeyEvent.CHAR_UNDEFINED)
character = Keyboard.CHAR_NONE;
if (state == 1) {
boolean repeat = false;
if (has_deferred_event) {
if ((nanos == deferred_nanos && deferred_key_code == key_code)) {
has_deferred_event = false;
repeat = true; // Repeat event
} else
flushDeferredEvent();
}
putKeyEvent(key_code, state, character, nanos, repeat);
} else {
flushDeferredEvent();
has_deferred_event = true;
deferred_nanos = nanos;
deferred_key_code = key_code;
deferred_key_state = state;
deferred_character = character;
}
}
private void flushDeferredEvent() {
if (has_deferred_event) {
putKeyEvent(deferred_key_code, deferred_key_state, deferred_character, deferred_nanos, false);
has_deferred_event = false;
}
}
public void putKeyEvent(int key_code, byte state, int character, long nanos, boolean repeat) {
/* Ignore repeating presses */
int mapped_code = getMappedKeyCode((short)key_code);
if (mapped_code < 0) {
System.out.println("Unrecognized keycode: " + key_code);
/* Unrecognized / unmapped code, do nothing */
return;
}
if ( key_states[mapped_code] == state )
repeat = true;
key_states[mapped_code] = state;
int key_int_char = character & 0xffff;
putKeyboardEvent(mapped_code, state, key_int_char, nanos, repeat);
}
private int getMappedKeyCode(short key_code) {
if (nativeToLwjglMap.containsKey(key_code)) {
return nativeToLwjglMap.get(key_code);
}
return -1;
}
public void keyPressed(int key_code, String chars, long nanos) {
// use only first character of chars returned for key press
int character = (chars == null || chars.length() == 0) ? 0 : (int)chars.charAt(0);
handleKey(key_code, (byte)1, character, nanos);
}
public void keyReleased(int key_code, String chars, long nanos) {
// use only first character of chars returned for key release
int character = (chars == null || chars.length() == 0) ? 0 : (int)chars.charAt(0);
handleKey(key_code, (byte)0, character, nanos);
}
public void keyTyped(KeyEvent e) {
}
}

View file

@ -1,229 +0,0 @@
/*
* Copyright (c) 2002-2008 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
/**
* A Cocoa implementation of a LWJGL compatible Mouse.
* @author mojang
* @author kappaOne <one.kappa@gmail.com>
*/
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.lwjgl.input.Mouse;
import org.lwjgl.LWJGLException;
import java.lang.reflect.*;
import java.lang.Integer;
import java.lang.Long;
import org.lwjgl.BufferUtils;
final class MacOSXNativeMouse extends EventQueue {
private static final int WHEEL_SCALE = 120;
private static final int NUM_BUTTONS = 3;
private ByteBuffer window_handle;
private MacOSXDisplay display;
private boolean grabbed;
/** The accumulated mouse deltas returned by poll() */
private float accum_dx;
private float accum_dy;
private int accum_dz;
/** The last mouse position */
private float last_x;
private float last_y;
/** Saved control key state for ctrl-click right button emulation */
private boolean saved_control_state;
private final ByteBuffer event = ByteBuffer.allocate(Mouse.EVENT_SIZE);
private IntBuffer delta_buffer = BufferUtils.createIntBuffer(2);
private int skip_event;
private final byte[] buttons = new byte[NUM_BUTTONS];
MacOSXNativeMouse(MacOSXDisplay display, ByteBuffer window_handle) {
super(Mouse.EVENT_SIZE);
this.display = display;
this.window_handle = window_handle;
}
private native void nSetCursorPosition(ByteBuffer window_handle, int x, int y);
public static native void nGrabMouse(boolean grab);
private native void nRegisterMouseListener(ByteBuffer window_handle);
private native void nUnregisterMouseListener(ByteBuffer window_handle);
private static native long nCreateCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, int images_offset, IntBuffer delays, int delays_offset) throws LWJGLException;
private static native void nDestroyCursor(long cursor_handle);
private static native void nSetCursor(long cursor_handle) throws LWJGLException;
public synchronized void register() {
nRegisterMouseListener(window_handle);
}
public static long createCursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException {
try {
return nCreateCursor(width, height, xHotspot, yHotspot, numImages, images, images.position(), delays, delays != null ? delays.position() : -1);
} catch (LWJGLException e) {
throw e;
}
}
public static void destroyCursor(long cursor_handle) {
nDestroyCursor(cursor_handle);
}
public static void setCursor(long cursor_handle) throws LWJGLException {
try {
nSetCursor(cursor_handle);
} catch (LWJGLException e) {
throw e;
}
}
public synchronized void setCursorPosition(int x, int y) {
nSetCursorPosition(window_handle, x, y);
}
public synchronized void unregister() {
nUnregisterMouseListener(window_handle);
}
public synchronized void setGrabbed(boolean grabbed) {
this.grabbed = grabbed;
nGrabMouse(grabbed);
skip_event = 1;
accum_dx = accum_dy = 0;
}
public synchronized boolean isGrabbed() {
return grabbed;
}
protected void resetCursorToCenter() {
clearEvents();
accum_dx = accum_dy = 0;
if (display != null) {
last_x = display.getWidth() / 2;
last_y = display.getHeight() / 2;
}
}
private void putMouseEvent(byte button, byte state, int dz, long nanos) {
if (grabbed)
putMouseEventWithCoords(button, state, 0, 0, dz, nanos);
else
putMouseEventWithCoords(button, state, (int)last_x, (int)last_y, dz, nanos);
}
protected void putMouseEventWithCoords(byte button, byte state, int coord1, int coord2, int dz, long nanos) {
((Buffer)event).clear();
event.put(button).put(state).putInt(coord1).putInt(coord2).putInt(dz).putLong(nanos);
((Buffer)event).flip();
putEvent(event);
}
public synchronized void poll(IntBuffer coord_buffer, ByteBuffer buttons_buffer) {
if (grabbed) {
coord_buffer.put(0, (int)accum_dx);
coord_buffer.put(1, (int)accum_dy);
} else {
coord_buffer.put(0, (int)last_x);
coord_buffer.put(1, (int)last_y);
}
coord_buffer.put(2, accum_dz);
accum_dx = accum_dy = accum_dz = 0;
int old_position = buttons_buffer.position();
buttons_buffer.put(buttons, 0, buttons.length);
((Buffer)buttons_buffer).position(old_position);
}
private void setCursorPos(float x, float y, long nanos) {
if ( grabbed )
return;
float dx = x - last_x;
float dy = y - last_y;
addDelta(dx, dy);
last_x = x;
last_y = y;
putMouseEventWithCoords((byte)-1, (byte)0, (int)x, (int)y, 0, nanos);
}
protected void addDelta(float dx, float dy) {
accum_dx += dx;
accum_dy += -dy;
}
public synchronized void setButton(int button, int state, long nanos) {
buttons[button] = (byte)state;
putMouseEvent((byte)button, (byte)state, 0, nanos);
}
public synchronized void mouseMoved(float x, float y, float dx, float dy, float dz, long nanos) {
if (skip_event > 0) {
skip_event--;
if (skip_event == 0) {
last_x = x;
last_y = y;
}
return;
}
if ( dz != 0 ) { // if scroll wheel event
// if no vertical wheel events, then map the horizontal wheel event to it
if (dy == 0) dy = dx;
int wheel_amount = (int)(dy * WHEEL_SCALE);
accum_dz += wheel_amount;
putMouseEvent((byte)-1, (byte)0, wheel_amount, nanos);
}
else if (grabbed) {
if ( dx != 0 || dy != 0 ) {
putMouseEventWithCoords((byte)-1, (byte)0, (int)dx, (int)-dy, 0, nanos);
addDelta(dx, dy);
}
} else {
setCursorPos(x, y, nanos);
}
}
}

View file

@ -45,10 +45,12 @@ import org.lwjgl.LWJGLUtil;
abstract class MacOSXPeerInfo extends PeerInfo {
MacOSXPeerInfo(PixelFormat pixel_format, ContextAttribs attribs, boolean use_display_bpp, boolean support_window, boolean support_pbuffer, boolean double_buffered) throws LWJGLException {
super(createHandle());
if (pixel_format.isFloatingPoint() && !LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 4))
throw new LWJGLException("Floating point pixel format requested, but it requires MacOS X 10.4 or newer");
boolean gl32 = attribs != null && (3 < attribs.getMajorVersion() || (attribs.getMajorVersion() == 3 && 2 <= attribs.getMinorVersion())) && attribs.isProfileCore();
boolean gl32 = attribs != null && attribs.getMajorVersion() == 3 && attribs.getMinorVersion() == 2 && attribs.isProfileCore();
if ( gl32 && !LWJGLUtil.isMacOSXEqualsOrBetterThan(10, 7) )
throw new LWJGLException("OpenGL 3.2+ requested, but it requires MacOS X 10.7 or newer");
throw new LWJGLException("OpenGL 3.2 requested, but it requires MacOS X 10.7 or newer");
choosePixelFormat(pixel_format, gl32, use_display_bpp, support_window, support_pbuffer, double_buffered);
}

View file

@ -81,19 +81,15 @@ class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionLi
public synchronized void register() {
resetCursorToCenter();
if (component != null) {
component.addMouseListener(this);
component.addMouseMotionListener(this);
component.addMouseWheelListener(this);
}
component.addMouseListener(this);
component.addMouseMotionListener(this);
component.addMouseWheelListener(this);
}
public synchronized void unregister() {
if (component != null) {
component.removeMouseListener(this);
component.removeMouseMotionListener(this);
component.removeMouseWheelListener(this);
}
component.removeMouseListener(this);
component.removeMouseMotionListener(this);
component.removeMouseWheelListener(this);
}
protected Component getComponent() {
@ -109,23 +105,18 @@ class MouseEventQueue extends EventQueue implements MouseListener, MouseMotionLi
return grabbed;
}
protected int transformY(int y) {
if (component != null) {
return component.getHeight() - 1 - y;
}
return y;
private int transformY(int y) {
return component.getHeight() - 1 - y;
}
protected void resetCursorToCenter() {
clearEvents();
accum_dx = accum_dy = 0;
if (component != null) {
Point cursor_location = AWTUtil.getCursorPosition(component);
if (cursor_location != null) {
last_x = cursor_location.x;
last_y = cursor_location.y;
}
}
Point cursor_location = AWTUtil.getCursorPosition(component);
if (cursor_location != null) {
last_x = cursor_location.x;
last_y = cursor_location.y;
}
}
private void putMouseEvent(byte button, byte state, int dz, long nanos) {

View file

@ -1,175 +0,0 @@
/*
* Copyright (c) 2002-2012 LWJGL Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'LWJGL' nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.lwjgl.opengl;
import org.lwjgl.Sys;
/**
* A highly accurate sync method that continually adapts to the system
* it runs on to provide reliable results.
*
* @author Riven
* @author kappaOne
*/
class Sync {
/** number of nano seconds in a second */
private static final long NANOS_IN_SECOND = 1000L * 1000L * 1000L;
/** The time to sleep/yield until the next frame */
private static long nextFrame = 0;
/** whether the initialisation code has run */
private static boolean initialised = false;
/** for calculating the averages the previous sleep/yield times are stored */
private static RunningAvg sleepDurations = new RunningAvg(10);
private static RunningAvg yieldDurations = new RunningAvg(10);
/**
* An accurate sync method that will attempt to run at a constant frame rate.
* It should be called once every frame.
*
* @param fps - the desired frame rate, in frames per second
*/
public static void sync(int fps) {
if (fps <= 0) return;
if (!initialised) initialise();
try {
// sleep until the average sleep time is greater than the time remaining till nextFrame
for (long t0 = getTime(), t1; (nextFrame - t0) > sleepDurations.avg(); t0 = t1) {
Thread.sleep(1);
sleepDurations.add((t1 = getTime()) - t0); // update average sleep time
}
// slowly dampen sleep average if too high to avoid yielding too much
sleepDurations.dampenForLowResTicker();
// yield until the average yield time is greater than the time remaining till nextFrame
for (long t0 = getTime(), t1; (nextFrame - t0) > yieldDurations.avg(); t0 = t1) {
Thread.yield();
yieldDurations.add((t1 = getTime()) - t0); // update average yield time
}
} catch (InterruptedException e) {
}
// schedule next frame, drop frame(s) if already too late for next frame
nextFrame = Math.max(nextFrame + NANOS_IN_SECOND / fps, getTime());
}
/**
* This method will initialise the sync method by setting initial
* values for sleepDurations/yieldDurations and nextFrame.
*
* If running on windows it will start the sleep timer fix.
*/
private static void initialise() {
initialised = true;
sleepDurations.init(1000 * 1000);
yieldDurations.init((int) (-(getTime() - getTime()) * 1.333));
nextFrame = getTime();
String osName = System.getProperty("os.name");
if (osName.startsWith("Win")) {
// On windows the sleep functions can be highly inaccurate by
// over 10ms making in unusable. However it can be forced to
// be a bit more accurate by running a separate sleeping daemon
// thread.
Thread timerAccuracyThread = new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(Long.MAX_VALUE);
} catch (Exception e) {}
}
});
timerAccuracyThread.setName("LWJGL Timer");
timerAccuracyThread.setDaemon(true);
timerAccuracyThread.start();
}
}
/**
* Get the system time in nano seconds
*
* @return will return the current time in nano's
*/
private static long getTime() {
return (Sys.getTime() * NANOS_IN_SECOND) / Sys.getTimerResolution();
}
private static class RunningAvg {
private final long[] slots;
private int offset;
private static final long DAMPEN_THRESHOLD = 10 * 1000L * 1000L; // 10ms
private static final float DAMPEN_FACTOR = 0.9f; // don't change: 0.9f is exactly right!
public RunningAvg(int slotCount) {
this.slots = new long[slotCount];
this.offset = 0;
}
public void init(long value) {
while (this.offset < this.slots.length) {
this.slots[this.offset++] = value;
}
}
public void add(long value) {
this.slots[this.offset++ % this.slots.length] = value;
this.offset %= this.slots.length;
}
public long avg() {
long sum = 0;
for (int i = 0; i < this.slots.length; i++) {
sum += this.slots[i];
}
return sum / this.slots.length;
}
public void dampenForLowResTicker() {
if (this.avg() > DAMPEN_THRESHOLD) {
for (int i = 0; i < this.slots.length; i++) {
this.slots[i] *= DAMPEN_FACTOR;
}
}
}
}
}

View file

@ -31,20 +31,62 @@
*/
package org.lwjgl.opengl;
import org.lwjgl.util.generator.opengl.GLenum;
import org.lwjgl.util.generator.opengl.GLuint;
/**
* An implementation of ContextAttribs using WGL_create_context.
*
* @author spasi <spasi@users.sourceforge.net>
*/
final class WindowsContextAttribs implements ContextAttribsImplementation {
public interface AMD_interleaved_elements {
private static final int WGL_CONTEXT_MAJOR_VERSION_ARB = 0x2091;
private static final int WGL_CONTEXT_MINOR_VERSION_ARB = 0x2092;
private static final int WGL_CONTEXT_LAYER_PLANE_ARB = 0x2093;
private static final int WGL_CONTEXT_FLAGS_ARB = 0x2094;
private static final int WGL_CONTEXT_PROFILE_MASK_ARB = 0x9126;
/**
* Accepted by the &lt;pname&gt; parameter of VertexAttribParameteriAMD and
* GetVertexAttrib{iv|dv|fv|Iiv|Iuiv|Ldv}:
*/
int GL_VERTEX_ELEMENT_SWIZZLE_AMD = 0x91A4;
private static final int WGL_CONTEXT_DEBUG_BIT_ARB = 0x0001;
private static final int WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x0002;
/** Selected by the &lt;pname&gt; parameter of ProgramParameteri and GetProgramiv: */
int GL_VERTEX_ID_SWIZZLE_AMD = 0x91A5;
private static final int WGL_CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001;
private static final int WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002;
void glVertexAttribParameteriAMD(@GLuint int index, @GLenum int pname, int param);
WindowsContextAttribs() {
}
public int getMajorVersionAttrib() {
return WGL_CONTEXT_MAJOR_VERSION_ARB;
}
public int getMinorVersionAttrib() {
return WGL_CONTEXT_MINOR_VERSION_ARB;
}
public int getLayerPlaneAttrib() {
return WGL_CONTEXT_LAYER_PLANE_ARB;
}
public int getFlagsAttrib() {
return WGL_CONTEXT_FLAGS_ARB;
}
public int getDebugBit() {
return WGL_CONTEXT_DEBUG_BIT_ARB;
}
public int getForwardCompatibleBit() {
return WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
}
public int getProfileMaskAttrib() {
return WGL_CONTEXT_PROFILE_MASK_ARB;
}
public int getProfileCoreBit() {
return WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
}
public int getProfileCompatibilityBit() {
return WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
}
}

Some files were not shown because too many files have changed in this diff Show more