From 2384bdba64c1d79aafc87ae68df5344db1074be1 Mon Sep 17 00:00:00 2001
From: Gary Frost <frost.gary@gmail.com>
Date: Wed, 9 Nov 2011 23:43:32 +0000
Subject: [PATCH] Fix for defect #2 (API for JOGL changed). Also simplified
 building nbody.

---
 examples/nbody/.classpath                     |   5 +-
 examples/nbody/build.xml                      | 163 ++++++++++++------
 examples/nbody/nbody.bat                      |  11 +-
 examples/nbody/nbody.sh                       |  10 +-
 .../com/amd/aparapi/examples/nbody/Main.java  |   2 +-
 5 files changed, 122 insertions(+), 69 deletions(-)

diff --git a/examples/nbody/.classpath b/examples/nbody/.classpath
index b3420b22..4af9b71d 100644
--- a/examples/nbody/.classpath
+++ b/examples/nbody/.classpath
@@ -4,8 +4,9 @@
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/com.amd.aparapi"/>
+	<classpathentry kind="var" path="JOGLDIR/jar/jogl-all-natives-windows-i586.jar"/>
 	<classpathentry kind="var" path="JOGLDIR/jar/jogl.all.jar"/>
-	<classpathentry kind="var" path="JOGLDIR/jar/gluegen-rt.jar"/>
-	<classpathentry kind="var" path="JOGLDIR/jar/nativewindow.all.jar"/>
+	<classpathentry kind="lib" path="C:/Users/gfrost/jogl/gluegen-2.0-b434-20111107-windows-i586/jar/gluegen-rt.jar"/>
+	<classpathentry kind="lib" path="C:/Users/gfrost/jogl/gluegen-2.0-b434-20111107-windows-i586/jar/gluegen-rt-natives-windows-i586.jar"/>
 	<classpathentry kind="output" path="classes"/>
 </classpath>
diff --git a/examples/nbody/build.xml b/examples/nbody/build.xml
index faee25e7..48dc677a 100644
--- a/examples/nbody/build.xml
+++ b/examples/nbody/build.xml
@@ -1,13 +1,12 @@
 <?xml version="1.0"?>
 
 <project name="nbody" default="build" basedir=".">
-   <property name="jogldir" value="..\..\..\..\jogl\jogl-2.0-b23-20110303-windows-i586"/>
+   <property name="jogamp-jar-url" value="http://jogamp.org/deployment/archive/rc/gluegen_28-joal_17-jogl_41-jocl_25/jar/"/>
 
    <path id="compiler.class.path">
       <pathelement path="../../com.amd.aparapi/aparapi.jar"/>
-      <pathelement path="${jogldir}/jar/jogl.all.jar"/>
-      <pathelement path="${jogldir}/jar/nativewindow.all.jar"/>
-      <pathelement path="${jogldir}/jar/gluegen-rt.jar"/>
+      <pathelement path="lib/jogl.all.jar"/>
+      <pathelement path="lib/gluegen-rt.jar"/>
    </path>
 
    <path id="runtime.class.path" cache="true">
@@ -15,46 +14,7 @@
       <pathelement path="${ant.project.name}.jar"/>
    </path>
 
-   <target name="check">
-      <fail message="Error:">
-         <condition>
-            <not><isset property="jogldir"/></not>
-         </condition>
-         <![CDATA[
-         You will need to edit build.xml
-
-         At present jogldir is not set.  It needs to point to an jogl install directory.
-         ]]>
-      </fail>
-      <available file="${jogldir}" type="dir" property="jogldir.exists"/>
-      <fail message="Error:">
-         <condition>
-            <not><isset property="jogldir.exists"/></not>
-         </condition>
-         <![CDATA[
-         You will need to edit build.xml
-
-         At present jogldir is set to ${jogldir} but that dir does not exist
-         ]]>
-      </fail>
-      <available file="${jogldir}/jar" type="dir" property="jogldir.jar.exists"/>
-      <available file="${jogldir}/lib" type="dir" property="jogldir.lib.exists"/>
-      <fail message="Error:">
-         <condition>
-            <or>
-               <not><isset property="jogldir.jar.exists"/></not>
-               <not><isset property="jogldir.jar.exists"/></not>
-            </or>
-         </condition>
-         <![CDATA[
-         You will need to edit build.xml
-
-         At present jogldir is set to ${jogldir} but that does not seem to be a valid jogl install. 
-         ]]>
-      </fail>
-   </target>
-
-   <target name="build" depends="clean,check">
+   <target name="build" depends="clean">
       <mkdir dir="classes"/>
       <javac srcdir="src" destdir="classes" debug="on" includeantruntime="false">
          <classpath refid="compiler.class.path"/>
@@ -68,12 +28,14 @@
       <delete file="${ant.project.name}.jar"/>
    </target>
 
-  
 
-   <target name="run-jtp" depends="check">
+
+   <target name="run-jtp">
+
+
       <java classname="com.amd.aparapi.examples.nbody.Main" fork="true">
          <classpath refid="runtime.class.path"/>
-         <sysproperty key="java.library.path" path="..\..\com.amd.aparapi.jni:${jogldir}\lib"/>
+         <sysproperty key="java.library.path" path="..\..\com.amd.aparapi.jni;lib"/>
          <sysproperty key="com.amd.aparapi.executionMode" value="JTP"/>
          <sysproperty key="bodies" value="16384"/>
          <sysproperty key="height" value="800"/>
@@ -81,10 +43,10 @@
       </java>
    </target>
 
-   <target name="run-gpu" depends="check">
+   <target name="run-gpu">
       <java classname="com.amd.aparapi.examples.nbody.Main" fork="true">
          <classpath refid="runtime.class.path"/>
-         <sysproperty key="java.library.path" path="..\..\com.amd.aparapi.jni:${jogldir}\lib"/>
+         <sysproperty key="java.library.path" path="..\..\com.amd.aparapi.jni;lib"/>
          <sysproperty key="com.amd.aparapi.executionMode" value="GPU"/>
          <sysproperty key="bodies" value="16384"/>
          <sysproperty key="height" value="800"/>
@@ -94,4 +56,107 @@
 
    <target name="run" depends="run-gpu"/>
 
+   <target name="getjogl-windows-i586" if="use.win32">
+      <delete dir="lib"/>
+      <get dest="lib">
+         <url url="${jogamp-jar-url}/jogl-all-natives-windows-i586.jar"/> 
+         <url url="${jogamp-jar-url}/jogl.all.jar"/> 
+         <url url="${jogamp-jar-url}/gluegen-rt.jar"/> 
+         <url url="${jogamp-jar-url}/gluegen-rt-natives-windows-i586.jar"/> 
+      </get>
+      <unzip src="lib/jogl-all-natives-windows-i586.jar" dest="lib"/>
+      <unzip src="lib/gluegen-rt-natives-windows-i586.jar" dest="lib"/>
+      <delete dir="lib/META-INF"/>
+   </target>
+
+   <target name="getjogl-windows-amd64" if="use.win64">
+      <delete dir="lib"/>
+      <get dest="lib">
+         <url url="${jogamp-jar-url}/jogl-all-natives-windows-amd64.jar"/> 
+         <url url="${jogamp-jar-url}/gluegen-rt-natives-windows-amd64.jar"/> 
+      </get>
+      <unzip src="lib/jogl-all-natives-windows-amd64.jar" dest="lib"/>
+      <unzip src="lib/gluegen-rt-natives-windows-amd64.jar" dest="lib"/>
+      <delete dir="lib/META-INF"/>
+   </target>
+
+   <target name="getjogl-linux-i586" if="use.linux32">
+      <delete dir="lib"/>
+      <get dest="lib">
+         <url url="${jogamp-jar-url}/jogl-all-natives-linux-i586.jar"/> 
+         <url url="${jogamp-jar-url}/gluegen-rt-windows-linux-i586.jar"/> 
+      </get>
+      <unzip src="lib/jogl-all-natives-linux-i586.jar" dest="lib"/>
+      <unzip src="lib/gluegen-rt-natives-linux-i586.jar" dest="lib"/>
+      <delete dir="lib/META-INF"/>
+   </target>
+
+   <target name="getjogl-linux-amd64" if="use.linux64">
+      <delete dir="lib"/>
+      <get dest="lib">
+         <url url="${jogamp-jar-url}/jogl-all-natives-linux-amd64.jar"/> 
+         <url url="${jogamp-jar-url}/gluegen-rt-natives-linux-amd64.jar"/> 
+      </get>
+      <unzip src="lib/jogl-all-natives-linux-amd64.jar" dest="lib"/>
+      <unzip src="lib/gluegen-rt-natives-linux-amd64.jar" dest="lib"/>
+      <delete dir="lib/META-INF"/>
+   </target>
+
+   <target name="checkos">
+      <condition property="use.win32">
+         <and>
+            <os family="windows" />
+            <or>
+               <os arch="x86" />
+               <os arch="i386" />
+            </or>
+         </and>
+      </condition>
+      <condition property="use.win64">
+         <and>
+            <os family="windows" />
+            <not>
+               <or>
+                  <os arch="x86" />
+                  <os arch="i386" />
+               </or>
+            </not>
+         </and>
+      </condition>
+      <condition property="use.linux32">
+         <and>
+            <os family="unix" />
+            <not>
+               <os family="mac" />
+            </not>
+            <or>
+               <os arch="x86" />
+               <os arch="i386" />
+            </or>
+         </and>
+      </condition>
+      <condition property="use.linux64">
+         <and>
+            <os family="unix" />
+            <not>
+               <os family="mac" />
+            </not>
+            <not>
+               <or>
+                  <os arch="x86" />
+                  <os arch="i386" />
+               </or>
+            </not>
+         </and>
+      </condition>
+   </target>
+
+   <target name="getjogl" depends="checkos, getjogl-windows-i586, getjogl-windows-amd64, getjogl-linux-i586, getjogl-linux-amd64">
+      <get dest="lib">
+         <url url="${jogamp-jar-url}/jogl.all.jar"/> 
+         <url url="${jogamp-jar-url}/gluegen-rt.jar"/> 
+      </get>
+   </target>
+
+
 </project>
diff --git a/examples/nbody/nbody.bat b/examples/nbody/nbody.bat
index c2e4ff1b..ec363229 100644
--- a/examples/nbody/nbody.bat
+++ b/examples/nbody/nbody.bat
@@ -1,19 +1,12 @@
 @echo off
 
-set JOGLDIR=..\..\..\..\jogl\jogl-2.0-b23-20110303-windows-i586
-
-set JOGLJARS=
-set JOGLJARS=%JOGLJARS%;%JOGLDIR%\jar\jogl.all.jar
-set JOGLJARS=%JOGLJARS%;%JOGLDIR%\jar\nativewindow.all.jar
-set JOGLJARS=%JOGLJARS%;%JOGLDIR%\jar\gluegen-rt.jar
-
 java ^
-  -Djava.library.path=..\..\com.amd.aparapi.jni;%JOGLDIR%\lib ^
+  -Djava.library.path=..\..\com.amd.aparapi.jni;lib ^
   -Dcom.amd.aparapi.executionMode=%1 ^
   -Dbodies=%2 ^
   -Dheight=600 ^
   -Dwidth=600 ^
-  -classpath %JOGLJARS%;..\..\com.amd.aparapi\aparapi.jar;nbody.jar ^
+  -classpath lib\gluegen-rt.jar;lib\jogl.all.jar;..\..\com.amd.aparapi\aparapi.jar;nbody.jar ^
   com.amd.aparapi.examples.nbody.Main 
 
 
diff --git a/examples/nbody/nbody.sh b/examples/nbody/nbody.sh
index 720e1016..4c85079c 100644
--- a/examples/nbody/nbody.sh
+++ b/examples/nbody/nbody.sh
@@ -1,16 +1,10 @@
-export JOGLDIR=../../../../jogl/jogl-2.0-b23-20110303-linux-amd64
-
-export JOGLJARS=
-export JOGLJARS=${JOGLJARS}:${JOGLDIR}/jar/jogl.all.jar
-export JOGLJARS=${JOGLJARS}:${JOGLDIR}/jar/nativewindow.all.jar
-export JOGLJARS=${JOGLJARS}:${JOGLDIR}/jar/gluegen-rt.jar
 
 java \
-  -Djava.library.path=../../com.amd.aparapi.jni:${JOGLDIR}/lib \
+  -Djava.library.path=../../com.amd.aparapi.jni:lib \
   -Dcom.amd.aparapi.executionMode=$1 \
   -Dbodies=$1 \
   -Dheight=600 \
   -Dwidth=600 \
-  -classpath ${JOGLJARS}:../../com.amd.aparapi/aparapi.jar:nbody.jar \
+  -classpath lib/jogl.all.jar:lib/gluegen-rt.jar:../../com.amd.aparapi/aparapi.jar:nbody.jar \
   com.amd.aparapi.examples.nbody.Main 
 
diff --git a/examples/nbody/src/com/amd/aparapi/examples/nbody/Main.java b/examples/nbody/src/com/amd/aparapi/examples/nbody/Main.java
index cda5f490..ae92a90a 100644
--- a/examples/nbody/src/com/amd/aparapi/examples/nbody/Main.java
+++ b/examples/nbody/src/com/amd/aparapi/examples/nbody/Main.java
@@ -287,7 +287,7 @@ public class Main{
             try {
                InputStream textureStream = Main.class.getResourceAsStream("particle.jpg");
                Texture texture = TextureIO.newTexture(textureStream, false, null);
-               texture.enable();
+               texture.enable(gl);
             } catch (IOException e) {
                e.printStackTrace();
             } catch (GLException e) {
-- 
GitLab