From: <sp...@us...> - 2010-09-28 21:11:47
|
Revision: 3418 http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3418&view=rev Author: spasi Date: 2010-09-28 21:11:35 +0000 (Tue, 28 Sep 2010) Log Message: ----------- Ported codebase to Java 1.5. Misc OpenCL fixes and API improvements. Changed fractal demo to use events/sync objects instead of cl/glFinish for synchronization. (untested) Modified Paths: -------------- trunk/LWJGL/build.xml trunk/LWJGL/platform_build/build-generator.xml trunk/LWJGL/src/java/org/lwjgl/BufferChecks.java trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/MacOSXSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java trunk/LWJGL/src/java/org/lwjgl/PointerBuffer.java trunk/LWJGL/src/java/org/lwjgl/PointerWrapperAbstract.java trunk/LWJGL/src/java/org/lwjgl/Sys.java trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java trunk/LWJGL/src/java/org/lwjgl/examples/Game.java trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Entity.java trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Game.java trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/GameApplet.java trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/ShotEntity.java trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/SoundManager.java trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Sprite.java trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Texture.java trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/TextureLoader.java trunk/LWJGL/src/java/org/lwjgl/input/Controller.java trunk/LWJGL/src/java/org/lwjgl/input/ControllerEvent.java trunk/LWJGL/src/java/org/lwjgl/input/Controllers.java trunk/LWJGL/src/java/org/lwjgl/input/Cursor.java trunk/LWJGL/src/java/org/lwjgl/input/JInputController.java trunk/LWJGL/src/java/org/lwjgl/input/Keyboard.java trunk/LWJGL/src/java/org/lwjgl/input/Mouse.java trunk/LWJGL/src/java/org/lwjgl/input/OpenGLPackageAccess.java trunk/LWJGL/src/java/org/lwjgl/openal/AL.java trunk/LWJGL/src/java/org/lwjgl/openal/ALC10.java trunk/LWJGL/src/java/org/lwjgl/openal/ALC11.java trunk/LWJGL/src/java/org/lwjgl/openal/ALCcontext.java trunk/LWJGL/src/java/org/lwjgl/openal/ALCdevice.java trunk/LWJGL/src/java/org/lwjgl/openal/EFXUtil.java trunk/LWJGL/src/java/org/lwjgl/opencl/APIUtil.java trunk/LWJGL/src/java/org/lwjgl/opencl/APPLEContextLoggingUtil.java trunk/LWJGL/src/java/org/lwjgl/opencl/CL.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLBuildProgramCallback.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLChecks.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLCommandQueue.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLContext.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLDevice.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLEvent.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLKernel.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLMem.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLObject.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLObjectChild.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLObjectRegistry.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLPlatform.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLProgram.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLSampler.java trunk/LWJGL/src/java/org/lwjgl/opencl/Util.java trunk/LWJGL/src/java/org/lwjgl/opengl/AMDDebugOutputCallback.java trunk/LWJGL/src/java/org/lwjgl/opengl/APIUtil.java trunk/LWJGL/src/java/org/lwjgl/opengl/ARBDebugOutputCallback.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTGLCanvas.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTSurfaceLock.java trunk/LWJGL/src/java/org/lwjgl/opengl/AWTUtil.java trunk/LWJGL/src/java/org/lwjgl/opengl/BaseReferences.java trunk/LWJGL/src/java/org/lwjgl/opengl/CallbackUtil.java trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java trunk/LWJGL/src/java/org/lwjgl/opengl/ContextAttribs.java trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/DisplayMode.java trunk/LWJGL/src/java/org/lwjgl/opengl/GLChecks.java trunk/LWJGL/src/java/org/lwjgl/opengl/GLContext.java trunk/LWJGL/src/java/org/lwjgl/opengl/GLUConstants.java trunk/LWJGL/src/java/org/lwjgl/opengl/GlobalLock.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxEvent.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxKeycodes.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxMouse.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXDisplayPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXFrame.java trunk/LWJGL/src/java/org/lwjgl/opengl/PeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/ReferencesStack.java trunk/LWJGL/src/java/org/lwjgl/opengl/RenderTexture.java trunk/LWJGL/src/java/org/lwjgl/opengl/StateTracker.java trunk/LWJGL/src/java/org/lwjgl/opengl/Util.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsAWTGLCanvasPeerInfo.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsCanvasImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsDisplay.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeyboard.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsKeycodes.java trunk/LWJGL/src/java/org/lwjgl/opengl/WindowsRegistry.java trunk/LWJGL/src/java/org/lwjgl/opengl/XRandR.java trunk/LWJGL/src/java/org/lwjgl/test/DisplayTest.java trunk/LWJGL/src/java/org/lwjgl/test/WindowCreationTest.java trunk/LWJGL/src/java/org/lwjgl/test/applet/AppletLoaderTest.java trunk/LWJGL/src/java/org/lwjgl/test/applet/GearsApplet.java trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenAL.java trunk/LWJGL/src/java/org/lwjgl/test/applet/OpenGL.java trunk/LWJGL/src/java/org/lwjgl/test/applet/Speed.java trunk/LWJGL/src/java/org/lwjgl/test/applet/Test.java trunk/LWJGL/src/java/org/lwjgl/test/glu/tessellation/TessCallback.java trunk/LWJGL/src/java/org/lwjgl/test/glu/tessellation/TessellationTest.java trunk/LWJGL/src/java/org/lwjgl/test/input/HWCursorTest.java trunk/LWJGL/src/java/org/lwjgl/test/input/KeyboardTest.java trunk/LWJGL/src/java/org/lwjgl/test/input/MouseCreationTest.java trunk/LWJGL/src/java/org/lwjgl/test/input/MouseTest.java trunk/LWJGL/src/java/org/lwjgl/test/input/TestControllers.java trunk/LWJGL/src/java/org/lwjgl/test/openal/BasicTest.java trunk/LWJGL/src/java/org/lwjgl/test/openal/OpenALInfo.java trunk/LWJGL/src/java/org/lwjgl/test/openal/PositionTest.java trunk/LWJGL/src/java/org/lwjgl/test/opencl/HelloOpenCL.java trunk/LWJGL/src/java/org/lwjgl/test/opencl/gl/DemoFractal.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/FullScreenWindowedTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/Gears.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/PbufferTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/SyncTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/VBOIndexTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/VBOTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/VersionTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTGears.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTGearsCanvas.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/AWTTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DemoBox.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/awt/DisplayParentTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/multithread/BackgroundLoadTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/multithread/BackgroundLoader.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/pbuffers/PbufferTest.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/pbuffers/UniqueRenderer.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/pbuffers/UniqueRendererRTT.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/shaders/Shader.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/shaders/ShaderFP.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/shaders/ShaderFSH.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/shaders/ShaderUNI.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/shaders/ShaderVP.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/shaders/ShaderVSH.java trunk/LWJGL/src/java/org/lwjgl/test/opengl/shaders/ShadersTest.java trunk/LWJGL/src/java/org/lwjgl/util/Display.java trunk/LWJGL/src/java/org/lwjgl/util/ReadableColor.java trunk/LWJGL/src/java/org/lwjgl/util/ReadableDimension.java trunk/LWJGL/src/java/org/lwjgl/util/ReadablePoint.java trunk/LWJGL/src/java/org/lwjgl/util/ReadableRectangle.java trunk/LWJGL/src/java/org/lwjgl/util/Renderable.java trunk/LWJGL/src/java/org/lwjgl/util/Timer.java trunk/LWJGL/src/java/org/lwjgl/util/WritableColor.java trunk/LWJGL/src/java/org/lwjgl/util/WritableDimension.java trunk/LWJGL/src/java/org/lwjgl/util/WritablePoint.java trunk/LWJGL/src/java/org/lwjgl/util/WritableRectangle.java trunk/LWJGL/src/java/org/lwjgl/util/XPMFile.java trunk/LWJGL/src/java/org/lwjgl/util/applet/AppletLoader.java trunk/LWJGL/src/java/org/lwjgl/util/generator/GeneratorVisitor.java trunk/LWJGL/src/java/org/lwjgl/util/generator/Helper.java trunk/LWJGL/src/java/org/lwjgl/util/generator/JavaMethodsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/NativeMethodStubsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/RegisterStubsGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/Utils.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLCapabilitiesGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLGeneratorProcessorFactory.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opencl/CLPDCapabilitiesGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLCapabilitiesGenerator.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLGeneratorProcessorFactory.java trunk/LWJGL/src/java/org/lwjgl/util/generator/opengl/GLReferencesGeneratorProcessorFactory.java trunk/LWJGL/src/java/org/lwjgl/util/glu/Cylinder.java trunk/LWJGL/src/java/org/lwjgl/util/glu/Disk.java trunk/LWJGL/src/java/org/lwjgl/util/glu/GLU.java trunk/LWJGL/src/java/org/lwjgl/util/glu/GLUtessellator.java trunk/LWJGL/src/java/org/lwjgl/util/glu/GLUtessellatorCallback.java trunk/LWJGL/src/java/org/lwjgl/util/glu/MipMap.java trunk/LWJGL/src/java/org/lwjgl/util/glu/PartialDisk.java trunk/LWJGL/src/java/org/lwjgl/util/glu/PixelStoreState.java trunk/LWJGL/src/java/org/lwjgl/util/glu/Project.java trunk/LWJGL/src/java/org/lwjgl/util/glu/Quadric.java trunk/LWJGL/src/java/org/lwjgl/util/glu/Registry.java trunk/LWJGL/src/java/org/lwjgl/util/glu/Sphere.java trunk/LWJGL/src/java/org/lwjgl/util/glu/Util.java trunk/LWJGL/src/java/org/lwjgl/util/glu/tessellation/GLUhalfEdge.java trunk/LWJGL/src/java/org/lwjgl/util/glu/tessellation/GLUtessellatorImpl.java trunk/LWJGL/src/java/org/lwjgl/util/glu/tessellation/Normal.java trunk/LWJGL/src/java/org/lwjgl/util/glu/tessellation/PriorityQ.java trunk/LWJGL/src/java/org/lwjgl/util/glu/tessellation/PriorityQHeap.java trunk/LWJGL/src/java/org/lwjgl/util/glu/tessellation/PriorityQSort.java trunk/LWJGL/src/java/org/lwjgl/util/glu/tessellation/Render.java trunk/LWJGL/src/java/org/lwjgl/util/glu/tessellation/Sweep.java trunk/LWJGL/src/java/org/lwjgl/util/jinput/KeyMap.java trunk/LWJGL/src/java/org/lwjgl/util/jinput/LWJGLKeyboard.java trunk/LWJGL/src/java/org/lwjgl/util/jinput/LWJGLMouse.java trunk/LWJGL/src/java/org/lwjgl/util/vector/Matrix.java trunk/LWJGL/src/java/org/lwjgl/util/vector/Matrix2f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/Matrix3f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/Matrix4f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/Quaternion.java trunk/LWJGL/src/java/org/lwjgl/util/vector/ReadableVector.java trunk/LWJGL/src/java/org/lwjgl/util/vector/ReadableVector2f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/ReadableVector3f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/ReadableVector4f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/Vector.java trunk/LWJGL/src/java/org/lwjgl/util/vector/Vector2f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/Vector3f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/WritableVector2f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/WritableVector3f.java trunk/LWJGL/src/java/org/lwjgl/util/vector/WritableVector4f.java trunk/LWJGL/src/native/common/extcl_types.h trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.c trunk/LWJGL/src/native/common/org_lwjgl_opencl_CL.h trunk/LWJGL/src/templates/org/lwjgl/opencl/CL10.java trunk/LWJGL/src/templates/org/lwjgl/opencl/KHR_icd.java trunk/LWJGL/src/templates/org/lwjgl/opengl/ARB_sync.java trunk/LWJGL/src/templates/org/lwjgl/opengl/GL32.java Added Paths: ----------- trunk/LWJGL/src/java/org/lwjgl/opencl/CLObjectRetainable.java trunk/LWJGL/src/java/org/lwjgl/opencl/InfoUtil.java trunk/LWJGL/src/java/org/lwjgl/opencl/InfoUtilAbstract.java trunk/LWJGL/src/java/org/lwjgl/opencl/InfoUtilFactory.java trunk/LWJGL/src/templates/org/lwjgl/opencl/AMD_event_callback.java trunk/LWJGL/src/templates/org/lwjgl/opencl/KHR_d3d10_sharing.java Removed Paths: ------------- trunk/LWJGL/src/java/org/lwjgl/opencl/CLDeviceImpl.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLKernelImpl.java trunk/LWJGL/src/java/org/lwjgl/opencl/CLPlatformImpl.java Modified: trunk/LWJGL/build.xml =================================================================== --- trunk/LWJGL/build.xml 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/build.xml 2010-09-28 21:11:35 UTC (rev 3418) @@ -16,74 +16,88 @@ <!-- Initialize build --> <!-- ================================================================== --> <target name="-initialize"> - <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" /> - <mkdir dir="${lwjgl.bin}/lwjgl" taskname="initialiazing bin folder" /> - <mkdir dir="${lwjgl.lib}" taskname="initialiazing lib folder" /> - <mkdir dir="${lwjgl.dist}" taskname="initialiazing dist folder" /> - <mkdir dir="${lwjgl.docs}/javadoc" taskname="initialiazing docs folder" /> - <mkdir dir="${lwjgl.res}" taskname="initialiazing res folder" /> - <mkdir dir="${lwjgl.temp}" taskname="initialiazing temp folder" /> - <mkdir dir="${lwjgl.temp}/jar" taskname="initialiazing temp/jar folder" /> - <mkdir dir="${lwjgl.temp}/doc" taskname="initialiazing temp/doc folder" /> - <mkdir dir="${lwjgl.temp}/res" taskname="initialiazing temp/res folder" /> - <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/macosx" taskname="initialiazing temp/macosx folder" /> - <mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" /> + <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" /> + <mkdir dir="${lwjgl.bin}/lwjgl" taskname="initialiazing native bin folder" /> + <mkdir dir="${lwjgl.lib}" taskname="initialiazing lib folder" /> + <mkdir dir="${lwjgl.dist}" taskname="initialiazing dist folder" /> + <mkdir dir="${lwjgl.docs}/javadoc" taskname="initialiazing docs folder" /> + <mkdir dir="${lwjgl.res}" taskname="initialiazing res folder" /> + <mkdir dir="${lwjgl.temp}" taskname="initialiazing temp folder" /> + <mkdir dir="${lwjgl.temp}/jar" taskname="initialiazing temp/jar folder" /> + <mkdir dir="${lwjgl.temp}/doc" taskname="initialiazing temp/doc folder" /> + <mkdir dir="${lwjgl.temp}/res" taskname="initialiazing temp/res folder" /> + <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/macosx" taskname="initialiazing temp/macosx folder" /> + <mkdir dir="${lwjgl.temp}/native/solaris" taskname="initialiazing temp/solaris folder" /> </target> <!-- Cleans up any files created during the execution of this script --> <target name="clean" description="Cleans the directories controlled by this ant script" depends="clean-generated"> <delete dir="${lwjgl.temp}" quiet="true" failonerror="false" taskname="cleaning temp folder" /> <delete dir="${lwjgl.docs}/javadoc" quiet="true" failonerror="false" taskname="cleaning javadoc folder" /> - <delete dir="${lwjgl.bin}" quiet="true" failonerror="false" taskname="cleaning bin folder" /> + <!-- Delete java classes only to avoid unnecessary native recompilation --> + <delete dir="${lwjgl.bin}/org" quiet="true" failonerror="false" taskname="cleaning bin folder" /> </target> + <!-- Useful when we need to force native recompilation --> + <target name="clean-native" description="Cleans bin folder's native directory" depends="clean-generated-native"> + <delete dir="${lwjgl.bin}/lwjgl" quiet="true" failonerror="false" taskname="cleaning native bin folder" /> + <mkdir dir="${lwjgl.bin}/lwjgl" taskname="initialiazing native bin folder" /> + </target> + + <target name="clean-all" depends="clean, clean-generated-native" description="Cleans all directories controlled by this ant script"> + <delete dir="${lwjgl.bin}/lwjgl" quiet="true" failonerror="false" taskname="cleaning native bin folder" /> + </target> + <!-- 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 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" - addproperty="do.delete" - /> - <condition property="do.abort"> - <equals arg1="no" arg2="${do.delete}"/> - </condition> - <fail if="do.abort">Build aborted by user.</fail> + <input + message="All data in the ${lwjgl.dist} folder will be deleted. Continue? " + validargs="yes,no" + addproperty="do.delete" + /> + <condition property="do.abort"> + <equals arg1="no" arg2="${do.delete}"/> + </condition> + <fail if="do.abort">Build aborted by user.</fail> - <!-- prepare --> - <delete dir="${lwjgl.dist}" quiet="true" failonerror="false" /> - <antcall target="clean" /> - <antcall target="-initialize" /> + <!-- prepare --> + <delete dir="${lwjgl.dist}" quiet="true" failonerror="false" /> + <antcall target="clean" /> + <antcall target="-initialize" /> - <!-- compile and create jars --> - <antcall target="generate-debug"/> - <antcall target="compile" /> - <antcall target="-createdebugjars" /> + <!-- compile and create debug jars --> + <antcall target="generate-debug" /> + <antcall target="compile" /> + <antcall target="-createdebugjars" /> + <!-- Generator will skip all templates if we don't clean --> - <delete dir="${lwjgl.bin}" quiet="true" failonerror="false" taskname="cleaning bin folder" /> - <mkdir dir="${lwjgl.bin}" taskname="initialiazing bin folder" /> - <antcall target="generate-all"/> - <antcall target="compile" /> - <antcall target="-createjars" /> - <antcall target="-jars_NoDEP" /> - <antcall target="javadoc" /> - <antcall target="applet-release" /> + <delete dir="${lwjgl.bin}/org" quiet="true" failonerror="false" taskname="cleaning bin folder" /> - <!-- copy resources to res folder --> - <copy todir="${lwjgl.temp}/res"> - <fileset dir="res"/> - </copy> + <!-- compile and create jars --> + <antcall target="generate-all" /> + <antcall target="compile" /> + <antcall target="-createjars" /> - <!-- copy docs --> + <antcall target="-jars_NoDEP" /> + <antcall target="javadoc" /> + <antcall target="applet-release" /> + + <!-- copy resources to res folder --> + <copy todir="${lwjgl.temp}/res"> + <fileset dir="res"/> + </copy> + + <!-- copy docs --> <copy todir="${lwjgl.temp}/doc"> <fileset dir="${lwjgl.docs}"> <patternset refid="lwjgl-docs.fileset" /> </fileset> - </copy> + </copy> <!-- create distribution from files in libs/ and temp/ --> <antcall target="-distribution_javadoc" /> @@ -219,7 +233,7 @@ <class name="org.lwjgl.opengl.LinuxContextImplementation" /> <class name="org.lwjgl.opengl.LinuxCanvasImplementation" /> </javah> - + <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/windows" force="yes"> <class name="org.lwjgl.opengl.WindowsKeyboard" /> <class name="org.lwjgl.opengl.WindowsPbufferPeerInfo" /> @@ -231,7 +245,7 @@ <class name="org.lwjgl.opengl.WindowsDisplayPeerInfo" /> <class name="org.lwjgl.opengl.WindowsContextImplementation" /> </javah> - + <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.native}/macosx" force="yes"> <class name="org.lwjgl.MacOSXSysImplementation" /> <class name="org.lwjgl.opengl.MacOSXMouseEventQueue" /> @@ -241,7 +255,7 @@ <class name="org.lwjgl.opengl.MacOSXDisplay" /> <class name="org.lwjgl.opengl.MacOSXContextImplementation" /> </javah> - + <javah classpath="${lwjgl.bin}" destdir="${lwjgl.src.headers}" force="yes"> <class name="org.lwjgl.opengl.AWTSurfaceLock" /> <class name="org.lwjgl.DefaultSysImplementation" /> @@ -342,6 +356,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.5" target="1.5" classpath="${lwjgl.lib}/jinput.jar:${lwjgl.lib}/AppleJavaExtensions.jar" taskname="core"> + <!--<compilerarg value="-Xlint:unchecked"/>--> <src path="${lwjgl.src}/java/"/> <src path="${lwjgl.src}/generated/"/> <include name="org/lwjgl/*.java"/> @@ -493,7 +508,7 @@ <!-- Creates the Javadoc --> <target name="javadoc" description="Creates javadoc from java source code"> - <javadoc destdir="${lwjgl.docs}/javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.4" windowtitle="LWJGL API" useexternalfile="true"> + <javadoc destdir="${lwjgl.docs}/javadoc" classpath="${lwjgl.lib}/jinput.jar" author="true" version="true" use="true" source="1.5" windowtitle="LWJGL API" useexternalfile="true"> <fileset refid="lwjgl.javadoc.fileset" /> <doctitle><![CDATA[<h1>Lightweight Java Game Toolkit</h1>]]></doctitle> <bottom><![CDATA[<i>Copyright © 2002-2009 lwjgl.org. All Rights Reserved.</i>]]></bottom> Modified: trunk/LWJGL/platform_build/build-generator.xml =================================================================== --- trunk/LWJGL/platform_build/build-generator.xml 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/platform_build/build-generator.xml 2010-09-28 21:11:35 UTC (rev 3418) @@ -1,13 +1,18 @@ <project name="generator"> <!-- clean the generated files --> - <target name="clean-generated" description="Deletes the generated java and native source"> + <target name="clean-generated" description="Deletes the generated java source"> <delete quiet="true" failonerror="false"> <fileset dir="${lwjgl.src}/generated" includes="**"/> - <fileset dir="${lwjgl.src.native}/generated" includes="**"/> </delete> </target> + <target name="clean-generated-native" description="Deletes the generated native source"> + <delete quiet="true" failonerror="false"> + <fileset dir="${lwjgl.src.native}/generated" includes="**"/> + </delete> + </target> + <!-- Compiles the Java generator source code --> <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"> Modified: trunk/LWJGL/src/java/org/lwjgl/BufferChecks.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/BufferChecks.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/BufferChecks.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -157,7 +157,7 @@ } public static void checkArray(Object[] array) { - if ( LWJGLUtil.CHECKS && array == null ) + if ( LWJGLUtil.CHECKS && (array == null || array.length == 0) ) throw new IllegalArgumentException("Invalid array"); } Modified: trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/LWJGLUtil.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -338,7 +338,7 @@ */ public static String[] getLibraryPaths(String libname, String[] platform_lib_names, ClassLoader classloader) { // need to pass path of possible locations of library to native side - List possible_paths = new ArrayList(); + List<String> possible_paths = new ArrayList<String>(); String classloader_path = getPathFromClassLoader(libname, classloader); if (classloader_path != null) { @@ -346,18 +346,17 @@ possible_paths.add(classloader_path); } - for (int i = 0; i < platform_lib_names.length; i++) { - String platform_lib_name = platform_lib_names[i]; + for ( String platform_lib_name : platform_lib_names ) { String lwjgl_classloader_path = getPathFromClassLoader("lwjgl", classloader); - if (lwjgl_classloader_path != null) { + if ( lwjgl_classloader_path != null ) { log("getPathFromClassLoader: Path found: " + lwjgl_classloader_path); possible_paths.add(lwjgl_classloader_path.substring(0, lwjgl_classloader_path.lastIndexOf(File.separator)) - + File.separator + platform_lib_name); + + File.separator + platform_lib_name); } // add Installer path String alternative_path = getPrivilegedProperty("org.lwjgl.librarypath"); - if (alternative_path != null) { + if ( alternative_path != null ) { possible_paths.add(alternative_path + File.separator + platform_lib_name); } @@ -365,7 +364,7 @@ String java_library_path = getPrivilegedProperty("java.library.path"); StringTokenizer st = new StringTokenizer(java_library_path, File.pathSeparator); - while (st.hasMoreTokens()) { + while ( st.hasMoreTokens() ) { String path = st.nextToken(); possible_paths.add(path + File.separator + platform_lib_name); } @@ -379,15 +378,13 @@ } //create needed string array - String[] paths = new String[possible_paths.size()]; - possible_paths.toArray(paths); - return paths; + return possible_paths.toArray(new String[possible_paths.size()]); } static void execPrivileged(final String[] cmd_array) throws Exception { try { - Process process = (Process)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { + Process process = AccessController.doPrivileged(new PrivilegedExceptionAction<Process>() { + public Process run() throws Exception { return Runtime.getRuntime().exec(cmd_array); } }); @@ -401,8 +398,8 @@ } private static String getPrivilegedProperty(final String property_name) { - return (String)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + return AccessController.doPrivileged(new PrivilegedAction<String>() { + public String run() { return System.getProperty(property_name); } }); @@ -422,16 +419,15 @@ private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) { try { log("getPathFromClassLoader: searching for: " + libname); - Class c = classloader.getClass(); + Class<?> c = classloader.getClass(); while (c != null) { - final Class clazz = c; + final Class<?> clazz = c; try { - return (String)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - Method findLibrary = clazz.getDeclaredMethod("findLibrary", new Class[]{String.class}); + return AccessController.doPrivileged(new PrivilegedExceptionAction<String>() { + public String run() throws Exception { + Method findLibrary = clazz.getDeclaredMethod("findLibrary", String.class); findLibrary.setAccessible(true); - Object[] arguments = new Object[] {libname}; - String path = (String)findLibrary.invoke(classloader, arguments); + String path = (String)findLibrary.invoke(classloader, libname); return path; } }); @@ -450,12 +446,12 @@ * Gets a boolean property as a privileged action. */ private static boolean getPrivilegedBoolean(final String property_name) { - Boolean value = (Boolean)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return new Boolean(Boolean.getBoolean(property_name)); + Boolean value = AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + public Boolean run() { + return Boolean.getBoolean(property_name); } }); - return value.booleanValue(); + return value; } /** Modified: trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/LinuxSysImplementation.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -39,7 +39,7 @@ * $Id$ */ final class LinuxSysImplementation extends J2SESysImplementation { - private final static int JNI_VERSION = 19; + private static final int JNI_VERSION = 19; static { java.awt.Toolkit.getDefaultToolkit(); // This will make sure libjawt.so is loaded @@ -55,8 +55,7 @@ String[] browsers = {"xdg-open", "firefox", "mozilla", "opera", "konqueror", "nautilus", "galeon", "netscape"}; - for (int i = 0; i < browsers.length; i ++) { - final String browser = browsers[i]; + for ( final String browser : browsers ) { try { LWJGLUtil.execPrivileged(new String[] { browser, url }); return true; Modified: trunk/LWJGL/src/java/org/lwjgl/MacOSXSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/MacOSXSysImplementation.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/MacOSXSysImplementation.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -42,7 +42,7 @@ * $Id$ */ final class MacOSXSysImplementation extends J2SESysImplementation { - private final static int JNI_VERSION = 19; + private static final int JNI_VERSION = 19; static { // Make sure AWT is properly initialized. This avoids hangs on Mac OS X 10.3 Modified: trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/NondirectBufferWrapper.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -49,16 +49,16 @@ * $Id: BufferChecks.java 2762 2007-04-11 16:13:05Z elias_naur $ */ public final class NondirectBufferWrapper { - private final static int INITIAL_BUFFER_SIZE = 1; + private static final int INITIAL_BUFFER_SIZE = 1; - private final static ThreadLocal thread_buffer = new ThreadLocal() { - protected Object initialValue() { + 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 = (CachedBuffers)thread_buffer.get(); + 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); @@ -378,7 +378,7 @@ return direct_buffer; } - private final static class CachedBuffers { + private static final class CachedBuffers { private final ByteBuffer byte_buffer; private final ShortBuffer short_buffer_big; private final IntBuffer int_buffer_big; Modified: trunk/LWJGL/src/java/org/lwjgl/PointerBuffer.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/PointerBuffer.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/PointerBuffer.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -49,7 +49,7 @@ boolean is64 = false; try { Method m = Class.forName("org.lwjgl.Sys").getDeclaredMethod("is64Bit", (Class[])null); - is64 = ((Boolean)m.invoke(null, (Object[])null)).booleanValue(); + is64 = (Boolean)m.invoke(null, (Object[])null); } catch (Throwable t) { // ignore } finally { @@ -63,10 +63,22 @@ protected final IntBuffer view32; protected final LongBuffer view64; + /** + * Creates a new PointerBuffer with the specified capacity. + * + * @param capacity the PointerBuffer size, in number of pointers + */ public PointerBuffer(final int capacity) { this(BufferUtils.createByteBuffer(capacity * getPointerSize())); } + /** + * Creates a new PointerBuffer using the specified ByteBuffer as its pointer + * data source. This is useful for users that do their own memory management + * over a big ByteBuffer, instead of allocating many small ones. + * + * @param source the source buffer + */ public PointerBuffer(final ByteBuffer source) { if ( !source.isDirect() ) throw new IllegalArgumentException("ByteBuffer is not direct"); @@ -91,6 +103,11 @@ return pointers; } + /** Returns true if the underlying architecture is 64bit. */ + public static boolean is64Bit() { + return is64Bit; + } + /** * Returns the pointer size in bytes, based on the underlying architecture. * @@ -769,7 +786,7 @@ * @return A summary string */ public String toString() { - StringBuffer sb = new StringBuffer(48); + StringBuilder sb = new StringBuilder(48); sb.append(getClass().getName()); sb.append("[pos="); sb.append(position()); Modified: trunk/LWJGL/src/java/org/lwjgl/PointerWrapperAbstract.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/PointerWrapperAbstract.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/PointerWrapperAbstract.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -44,16 +44,30 @@ this.pointer = pointer; } - public final boolean isNull() { - return pointer == 0; + /** + * Returns true if this object represents a valid pointer. + * The pointer might be invalid because it is NULL or because + * some other action has deleted the object that this pointer + * represents. + * + * @return true if the pointer is valid + */ + public boolean isValid() { + return pointer != 0; } - public final void checkNull() { - if ( LWJGLUtil.DEBUG && pointer == 0 ) - throw new IllegalStateException("This pointer is null."); + /** + * Checks if the pointer is valid and throws an IllegalStateException if + * it is not. This method is a NO-OP, unless the org.lwjgl.util.Debug + * property has been set to true. + */ + public final void checkValid() { + if ( LWJGLUtil.DEBUG && !isValid() ) + throw new IllegalStateException("This pointer is not valid."); } - public long getPointer() { + public final long getPointer() { + checkValid(); return pointer; } @@ -72,4 +86,7 @@ return (int)(pointer ^ (pointer >>> 32)); } + public String toString() { + return getClass().getSimpleName() + " pointer (0x" + Long.toHexString(pointer) + ")"; + } } \ No newline at end of file Modified: trunk/LWJGL/src/java/org/lwjgl/Sys.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/Sys.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/Sys.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -63,7 +63,7 @@ private static final boolean is64Bit; private static void doLoadLibrary(final String lib_name) { - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { String library_path = System.getProperty("org.lwjgl.librarypath"); if (library_path != null) { @@ -215,22 +215,22 @@ // Attempt to use Webstart if we have it available try { // Lookup the javax.jnlp.BasicService object - final Class serviceManagerClass = Class.forName("javax.jnlp.ServiceManager"); - Method lookupMethod = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - return serviceManagerClass.getMethod("lookup", new Class[] {String.class}); + final Class<?> serviceManagerClass = Class.forName("javax.jnlp.ServiceManager"); + Method lookupMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() { + public Method run() throws Exception { + return serviceManagerClass.getMethod("lookup", String.class); } }); Object basicService = lookupMethod.invoke(serviceManagerClass, new Object[] {"javax.jnlp.BasicService"}); - final Class basicServiceClass = Class.forName("javax.jnlp.BasicService"); - Method showDocumentMethod = (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - return basicServiceClass.getMethod("showDocument", new Class[] {URL.class}); + final Class<?> basicServiceClass = Class.forName("javax.jnlp.BasicService"); + Method showDocumentMethod = AccessController.doPrivileged(new PrivilegedExceptionAction<Method>() { + public Method run() throws Exception { + return basicServiceClass.getMethod("showDocument", URL.class); } }); try { - Boolean ret = (Boolean) showDocumentMethod.invoke(basicService, new Object[] {new URL(url)}); - return ret.booleanValue(); + Boolean ret = (Boolean)showDocumentMethod.invoke(basicService, new URL(url)); + return ret; } catch (MalformedURLException e) { e.printStackTrace(System.err); return false; Modified: trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/WindowsSysImplementation.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -45,12 +45,12 @@ * $Id$ */ final class WindowsSysImplementation extends DefaultSysImplementation { - private final static int JNI_VERSION = 23; + private static final int JNI_VERSION = 23; static { Sys.initialize(); } - + public int getRequiredJNIVersion() { return JNI_VERSION; } @@ -64,7 +64,7 @@ } private static native long nGetTime(); - public final boolean has64Bit() { + public boolean has64Bit() { return true; } @@ -75,19 +75,17 @@ * public */ try { - Long hwnd_obj = (Long)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation", null); + return AccessController.doPrivileged(new PrivilegedExceptionAction<Long>() { + public Long run() throws Exception { + Method getImplementation_method = Display.class.getDeclaredMethod("getImplementation"); getImplementation_method.setAccessible(true); - Object display_impl = getImplementation_method.invoke(null, null); - Class WindowsDisplay_class = Class.forName("org.lwjgl.opengl.WindowsDisplay"); - Method getHwnd_method = WindowsDisplay_class.getDeclaredMethod("getHwnd", null); + Object display_impl = getImplementation_method.invoke(null); + Class<?> WindowsDisplay_class = Class.forName("org.lwjgl.opengl.WindowsDisplay"); + Method getHwnd_method = WindowsDisplay_class.getDeclaredMethod("getHwnd"); getHwnd_method.setAccessible(true); - Long hwnd = (Long)getHwnd_method.invoke(display_impl, null); - return hwnd; + return (Long)getHwnd_method.invoke(display_impl); } }); - return hwnd_obj.longValue(); } catch (PrivilegedActionException e) { throw new Error(e); } Modified: trunk/LWJGL/src/java/org/lwjgl/examples/Game.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/examples/Game.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/examples/Game.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -1,31 +1,31 @@ -/* +/* * 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 + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * 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 + * * 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 + * 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 + * 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. */ @@ -35,8 +35,9 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.openal.AL; import org.lwjgl.opengl.Display; -import org.lwjgl.opengl.GL11; +import static org.lwjgl.opengl.GL11.*; + /** * * This is a <em>very basic</em> skeleton to init a game and run it. @@ -46,24 +47,24 @@ * $Id$ */ public class Game { - + /** Game title */ public static final String GAME_TITLE = "My Game"; - + /** Desired frame time */ private static final int FRAMERATE = 60; - + /** Exit the game */ private static boolean finished; - + /** A rotating square! */ private static float angle; - + /** * No constructor needed - this class is static */ private Game() {} - + /** * Application init * @param args Commandline args @@ -78,10 +79,10 @@ } finally { cleanup(); } - + System.exit(0); } - + /** * Initialise the game * @throws Exception if init fails @@ -94,25 +95,25 @@ // Enable vsync if we can Display.setVSyncEnabled(true); - + Display.create(); - + // Start up the sound system AL.create(); - + // TODO: Load in your textures etc here - + // Put the window into orthographic projection mode with 1:1 pixel ratio. // We haven't used GLU here to do this to avoid an unnecessary dependency. - GL11.glMatrixMode(GL11.GL_PROJECTION); - GL11.glLoadIdentity(); - GL11.glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0); - GL11.glMatrixMode(GL11.GL_MODELVIEW); - GL11.glLoadIdentity(); - GL11.glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); - + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0.0, Display.getDisplayMode().getWidth(), 0.0, Display.getDisplayMode().getHeight(), -1.0, 1.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glViewport(0, 0, Display.getDisplayMode().getWidth(), Display.getDisplayMode().getHeight()); + } - + /** * Runs the game (the "main loop") */ @@ -120,7 +121,7 @@ while (!finished) { // Always call Window.update(), all the time Display.update(); - + if (Display.isCloseRequested()) { // Check for O/S close requests finished = true; @@ -144,7 +145,7 @@ } } } - + /** * Do any game-specific cleanup */ @@ -153,11 +154,11 @@ // Stop the sound AL.destroy(); - + // Close the window Display.destroy(); } - + /** * Do all calculations, handle input, etc. */ @@ -170,24 +171,24 @@ // TODO: all your game logic goes here. angle += 2.0f % 360; } - + /** * Render the current frame */ private static void render() { - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // TODO: all your rendering goes here - GL11.glClear(GL11.GL_COLOR_BUFFER_BIT); - GL11.glPushMatrix(); - GL11.glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f); - GL11.glRotatef(angle, 0, 0, 1.0f); - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex2i(-50, -50); - GL11.glVertex2i(50, -50); - GL11.glVertex2i(50, 50); - GL11.glVertex2i(-50, 50); - GL11.glEnd(); - GL11.glPopMatrix(); + glClear(GL_COLOR_BUFFER_BIT); + glPushMatrix(); + glTranslatef(Display.getDisplayMode().getWidth() / 2, Display.getDisplayMode().getHeight() / 2, 0.0f); + glRotatef(angle, 0, 0, 1.0f); + glBegin(GL_QUADS); + glVertex2i(-50, -50); + glVertex2i(50, -50); + glVertex2i(50, 50); + glVertex2i(-50, 50); + glEnd(); + glPopMatrix(); } } Modified: trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Entity.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Entity.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Entity.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -1,31 +1,31 @@ -/* +/* * 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 + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * 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 + * * 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 + * 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 + * 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. */ @@ -37,13 +37,13 @@ * An entity represents any element that appears in the game. The * entity is responsible for resolving collisions and movement * based on a set of properties defined either by subclass or externally. - * + * * Note that doubles are used for positions. This may seem strange * given that pixels locations are integers. However, using double means * that an entity can move a partial pixel. It doesn't of course mean that * they will be display half way through a pixel but allows us not lose * accuracy as we move. - * + * * @author Kevin Glass */ public abstract class Entity { @@ -71,12 +71,12 @@ /** * Construct a entity based on a sprite image and a location. - * - * @param ref The reference to the image to be displayed for this entity + * + * @param sprite The reference to the image to be displayed for this entity * @param x The initial x location of this entity * @param y The initial y location of this entity */ - public Entity(Sprite sprite, int x, int y) { + protected Entity(Sprite sprite, int x, int y) { this.sprite = sprite; this.x = x; this.y = y; @@ -85,7 +85,7 @@ /** * Request that this entity move itself based on a certain ammount * of time passing. - * + * * @param delta The ammount of time that has passed in milliseconds */ public void move(long delta) { @@ -96,7 +96,7 @@ /** * Set the horizontal speed of this entity - * + * * @param dx The horizontal speed of this entity (pixels/sec) */ public void setHorizontalMovement(float dx) { @@ -105,7 +105,7 @@ /** * Set the vertical speed of this entity - * + * * @param dy The vertical speed of this entity (pixels/sec) */ public void setVerticalMovement(float dy) { @@ -114,7 +114,7 @@ /** * Get the horizontal speed of this entity - * + * * @return The horizontal speed of this entity (pixels/sec) */ public float getHorizontalMovement() { @@ -123,7 +123,7 @@ /** * Get the vertical speed of this entity - * + * * @return The vertical speed of this entity (pixels/sec) */ public float getVerticalMovement() { @@ -146,7 +146,7 @@ /** * Get the x location of this entity - * + * * @return The x location of this entity */ public int getX() { @@ -155,7 +155,7 @@ /** * Get the y location of this entity - * + * * @return The y location of this entity */ public int getY() { @@ -164,7 +164,7 @@ /** * Check if this entity collised with another. - * + * * @param other The other entity to check collision against * @return True if the entities collide with each other */ @@ -177,7 +177,7 @@ /** * Notification that this entity collided with another. - * + * * @param other The entity with which this entity collided. */ public abstract void collidedWith(Entity other); Modified: trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Game.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Game.java 2010-09-27 12:09:52 UTC (rev 3417) +++ trunk/LWJGL/src/java/org/lwjgl/examples/spaceinvaders/Game.java 2010-09-28 21:11:35 UTC (rev 3418) @@ -1,31 +1,31 @@ -/* +/* * 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 + * modification, are permitted provided that the following conditions are * met: - * - * * Redistributions of source code must retain the above copyright + * + * * 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 + * * 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 + * 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 + * 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. */ @@ -39,32 +39,33 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; import org.lwjgl.opengl.DisplayMode; -import org.lwjgl.opengl.GL11; +import static org.lwjgl.opengl.GL11.*; + /** * The main hook of our game. This class with both act as a manager - * for the display and central mediator for the game logic. - * + * for the display and central mediator for the game logic. + * * Display management will consist of a loop that cycles round all * entities in the game asking them to move and then drawing them * in the appropriate place. With the help of an inner class it * will also allow the player to control the main ship. - * + * * As a mediator it will be informed when entities within our game * detect events (e.g. alient killed, played died) and will take * appropriate game actions. - * + * * <p> * NOTE:<br> * This game is a LWJGLized implementation of the Space Invaders game by Kevin - * Glass. The original implementation is renderer agnostic and supports other + * Glass. The original implementation is renderer agnostic and supports other * OpenGL implementations as well as Java2D. This version has been made specific - * for LWJGL, and has added input control as well as sound (which the original doesn't, + * for LWJGL, and has added input control as well as sound (which the original doesn't, * at the time of writing). * You can find the original article here:<br> * <a href="http://www.cokeandcode.com/" target="_blank">http://www.cokeandcode.com</a> * </p> - * + * * @author Kevin Glass * @author Brian Matzon */ @@ -83,10 +84,10 @@ private TextureLoader textureLoader; /** The list of all the entities that exist in our game */ - private ArrayList entities = new ArrayList(); + private ArrayList<Entity> entities = new ArrayList<Entity>(); /** The list of entities that need to be removed from the game this loop */ - private ArrayList removeList = new ArrayList(); + private ArrayList<Entity> removeList = new ArrayList<Entity>(); /** The entity representing the player */ private ShipEntity ship; @@ -113,7 +114,7 @@ private float moveSpeed = 300; /** The time at which last fired a shot */ - private long lastFire = 0; + private long lastFire; /** The interval between our players shot (ms) */ private long firingInterval = 500; @@ -125,16 +126,16 @@ private boolean waitingForKeyPress = true; /** True if game logic needs to be applied this loop, normally as a result of a game event */ - private boolean logicRequiredThisLoop = false; + private boolean logicRequiredThisLoop; /** The time at which the last rendering looped started from the point of view of the game logic */ private long lastLoopTime = getTime(); /** True if the fire key has been released */ - private boolean fireHasBeenReleased = false; + private boolean fireHasBeenReleased; /** The time since the last record of fps */ - private long lastFpsTime = 0; + private long lastFpsTime; /** The recorded fps */ private int fps; @@ -167,15 +168,14 @@ /** Mouse movement on x axis */ private int mouseX; - + /** Is this an application or applet */ - private static boolean isApplication = false; + private static boolean isApplication; /** * Construct our game and set it running. * @param fullscreen - * - * @param renderingType The type of rendering to use (should be one of the contansts from ResourceFactory) + * */ public Game(boolean fullscreen) { this.fullscreen = fullscreen; @@ -184,7 +184,7 @@ /** * Get the high resolution time in milliseconds - * + * * @return The high resolution time in milliseconds */ public static long getTime() { @@ -196,8 +196,8 @@ } /** - * Sleep for a fixed number of milliseconds. - * + * Sleep for a fixed number of milliseconds. + * * @param duration The amount of time in milliseconds to sleep for */ public static void sleep(long duration) { @@ -217,25 +217,25 @@ Display.setTitle(WINDOW_TITLE); Display.setFullscreen(fullscreen); Display.create(); - + // grab the mouse, dont want that hideous cursor when we're playing! - if (isApplication) { + if (isApplication) { Mouse.setGrabbed(true); } // enable textures since we're going to use these for our sprites - GL11.glEnable(GL11.GL_TEXTURE_2D); + glEnable(GL_TEXTURE_2D); // disable the OpenGL depth test since we're rendering 2D graphics - GL11.glDisable(GL11.GL_DEPTH_TEST); + glDisable(GL_DEPTH_TEST); - GL11.glMatrixMode(GL11.GL_PROJECTION); - GL11.glLoadIdentity(); + glMatrixMode(GL_PROJECTION); + glLoad... [truncated message content] |