diff options
author | Kenneth Russel <[email protected]> | 2008-06-01 10:47:02 +0000 |
---|---|---|
committer | Kenneth Russel <[email protected]> | 2008-06-01 10:47:02 +0000 |
commit | 5cfe97f36cf9187eb92900a7da0ef92af98a462f (patch) | |
tree | 2e5dbad7db41afc599e48e44e8c64f8504b5ce08 /src | |
parent | 04053312e8b8d27fb95aed807009a58489025923 (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')
-rwxr-xr-x | src/demos/es1/RedSquare.java | 11 |
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 |