Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reorganized java a bit; added gwtbox2d target.

  • Loading branch information...
commit f766aeeef5d29d4081239a77c802a3fd0e601f77 1 parent 517af3e
@joelgwebber authored
View
5 java/.classpath
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gwt"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/jbox2d-library-2.1.2.1-SNAPSHOT-jar-with-dependencies.jar"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="lib" path="lib/playn-jbox2d-1.1-SNAPSHOT.jar"/>
+ <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
+ <classpathentry kind="output" path="war/WEB-INF/classes"/>
</classpath>
View
1  java/.gitignore
@@ -1 +1,2 @@
bin
+.settings
View
11 java/.project
@@ -10,8 +10,19 @@
<arguments>
</arguments>
</buildCommand>
+ <buildCommand>
+ <name>com.google.gdt.eclipse.core.webAppProjectValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>com.google.gwt.eclipse.core.gwtNature</nature>
</natures>
</projectDescription>
View
2  java/build.xml
@@ -16,7 +16,7 @@
</target>
<target name='run' depends='compile'>
- <java classname='bench2d.Bench2d'>
+ <java classname='j15r.bench2d.Bench2d'>
<classpath>
<pathelement location='lib/jbox2d-library-2.1.2.1-SNAPSHOT-jar-with-dependencies.jar'/>
<pathelement location='bin'/>
View
17 java/gwt/j15r/bench2d/GwtBench2d.java
@@ -0,0 +1,17 @@
+package j15r.bench2d;
+
+import com.google.gwt.core.client.EntryPoint;
+
+public class GwtBench2d extends Bench2d implements EntryPoint {
+
+ @Override
+ public void onModuleLoad() {
+ warmup();
+ bench();
+ }
+
+ @Override
+ native void log(String msg) /*-{
+ console.log(msg);
+ }-*/;
+}
View
BIN  java/lib/playn-jbox2d-1.1-SNAPSHOT.jar
Binary file not shown
View
7 java/src/j15r/Bench2d.gwt.xml
@@ -0,0 +1,7 @@
+<module rename-to='bench2d'>
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name='org.jbox2d.GwtBox2D'/>
+ <source path='bench2d'/>
+ <set-property name='user.agent' value='safari'/>
+ <entry-point class='j15r.bench2d.GwtBench2d'/>
+</module>
View
23 java/src/bench2d/Bench2d.java → java/src/j15r/bench2d/Bench2d.java
@@ -1,4 +1,4 @@
-package bench2d;
+package j15r.bench2d;
import java.util.Date;
@@ -13,28 +13,30 @@
static final int FRAMES = 256;
static final int PYRAMID_SIZE = 40;
- World world;
- Body groundBody;
-
public static void main(String[] args) {
Bench2d bench = new Bench2d();
-
bench.warmup();
+ bench.bench();
+ }
+
+ World world;
+ Body groundBody;
+ public void bench() {
int[] times = new int[FRAMES];
for (int i = 0; i < FRAMES; ++i) {
long begin = new Date().getTime();
- bench.step();
+ step();
long end = new Date().getTime();
times[i] = (int)(end - begin);
- System.out.println(times[i]);
+ log("" + times[i]);
}
int total = 0;
for (int i = 0; i < FRAMES; ++i) {
total += times[i];
}
- System.out.println("Average: " + (float) total / FRAMES);
+ log("Average: " + (float) total / FRAMES);
}
void warmup() {
@@ -87,5 +89,8 @@ void step() {
float timeStep = 1f / 60f;
world.step(timeStep, 3, 3);
}
-}
+ void log(String msg) {
+ System.out.println(msg);
+ }
+}
View
1  java/war/.gitignore
@@ -0,0 +1 @@
+bench2d
View
3  java/war/WEB-INF/.gitignore
@@ -0,0 +1,3 @@
+lib
+classes
+deploy
View
10 java/war/WEB-INF/web.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xmlns="http://java.sun.com/xml/ns/javaee"
+xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
+ <!-- TODO: Add <servlet> tags for each servlet here. -->
+ <!-- TODO: Add <servlet-mapping> tags for each <servlet> here. -->
+ <!-- TODO: Optionally add a <welcome-file-list> tag to display a welcome file. -->
+</web-app>
View
8 java/war/bench2d.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Bench2d, GWT Edition!</title>
+ <script src='bench2d/bench2d.nocache.js'></script>
+ </head>
+</html>
+
Please sign in to comment.
Something went wrong with that request. Please try again.