summaryrefslogtreecommitdiffstats
path: root/src/demos/es1/RedSquare.java
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2008-06-01 10:47:02 +0000
committerKenneth Russel <[email protected]>2008-06-01 10:47:02 +0000
commit5cfe97f36cf9187eb92900a7da0ef92af98a462f (patch)
tree2e5dbad7db41afc599e48e44e8c64f8504b5ce08 /src/demos/es1/RedSquare.java
parent04053312e8b8d27fb95aed807009a58489025923 (diff)
Made rotation speed independent of frame rate. Removed sleep.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/jogl-demos/trunk@242 3298f667-5e0e-4b4a-8ed4-a3559d26a5f4
Diffstat (limited to 'src/demos/es1/RedSquare.java')
-rwxr-xr-xsrc/demos/es1/RedSquare.java11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/demos/es1/RedSquare.java b/src/demos/es1/RedSquare.java
index fa6b435..4596310 100755
--- a/src/demos/es1/RedSquare.java
+++ b/src/demos/es1/RedSquare.java
@@ -105,8 +105,7 @@ public class RedSquare implements MouseListener {
long startTime = System.currentTimeMillis();
long curTime;
- int ang = 0;
- while (!ml.quit && (System.currentTimeMillis() - startTime) < 20000) {
+ while (!ml.quit && ((curTime = System.currentTimeMillis()) - startTime) < 20000) {
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
// Set location in front of camera
@@ -119,8 +118,9 @@ public class RedSquare implements MouseListener {
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0, 0, -10);
+ // One rotation every four seconds
+ float ang = (((float) (curTime - startTime)) * 360.0f) / 4000.0f;
gl.glRotatef(ang, 0, 0, 1);
- ang++;
// Draw a square
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4);
@@ -133,11 +133,6 @@ public class RedSquare implements MouseListener {
}
window.pumpMessages();
-
- try {
- Thread.sleep(10);
- } catch (InterruptedException e) {
- }
}
// Shut things down cooperatively