summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXerxes Rånby <[email protected]>2012-09-20 13:20:13 +0200
committerXerxes Rånby <[email protected]>2012-09-20 13:20:13 +0200
commit59c6358dbcfbb70e3796fef5d3063ffb9491ae8b (patch)
treece326d02158b5f6f86075bb54296d7b9a3adf42c
parent970515a87942224361a036d3ad17713ee3dac366 (diff)
Improve frame rendering smoothness in src/demos/es2/RawGL2ES2demo.java
by using Animator instead of FPSAnimator. Calculate the time deltas for the theta movement using milliseconds passed between two frames. Signed-off-by: Xerxes Rånby <[email protected]>
-rw-r--r--src/demos/es2/RawGL2ES2demo.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/demos/es2/RawGL2ES2demo.java b/src/demos/es2/RawGL2ES2demo.java
index 6cccc6f..4423c33 100644
--- a/src/demos/es2/RawGL2ES2demo.java
+++ b/src/demos/es2/RawGL2ES2demo.java
@@ -222,8 +222,9 @@ static final String fragmentShader =
* yet it do take some extra lines of code to setup.
*
*/
- private double theta=0;
- private double s=0;
+ private double t0 = System.currentTimeMillis();
+ private double theta;
+ private double s;
private static int width=1920;
private static int height=1080;
@@ -281,7 +282,7 @@ static final String fragmentShader =
// GLWindow will call the GLEventListener init, reshape, display and dispose
// functions when needed.
glWindow.addGLEventListener(new RawGL2ES2demo() /* GLEventListener */);
- FPSAnimator animator = new FPSAnimator(glWindow,60);
+ Animator animator = new Animator(glWindow);
animator.add(glWindow);
animator.start();
}
@@ -374,7 +375,9 @@ static final String fragmentShader =
public void display(GLAutoDrawable drawable) {
// Update variables used in animation
- theta += 0.08;
+ double t1 = System.currentTimeMillis();
+ theta += (t1-t0)*0.005f;
+ t0 = t1;
s = Math.sin(theta);
// Get gl