com.jibberia.gl.util
Class GLTimer
java.lang.Object
com.jibberia.gl.util.GLTimer
public class GLTimer
- extends java.lang.Object
GLTimer is a simple class for timing the math required to do 3D animation. Use it
to separate time-related things from the frame rate.
Someday, this should also provide pause() and restart() methods.
Basic usage:
public class MyOpenGLThing implements TimedRenderable {
GLTimer timer;
public MyOpenGLThing() {
initStuff();
timer = new GLTimer(this, 0.001f);
while(running) {
render(); // render as fast as possible in the main loop
}
}
public void updatePhysics() {
// do motion-related math, ie:
rotation += 0.06f;
}
}
- Version:
- 0.1
- Author:
- Kevin Cox, http://www.jibberia.com/
|
Method Summary |
void |
stop()
Stop the timer forever. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GLTimer
public GLTimer(TimedRenderable parent,
float deltaSeconds)
- Constructor for GLTimer. Pass in a
TimedRenderable and a
time interval, and it will call that class's updatePhysics() every
time interval.
- Parameters:
parent - an instantiated class that implements TimedRenderable (almost always 'this')deltaSeconds - a float time interval in seconds to call updatePhysics() in the parent class
stop
public void stop()
- Stop the timer forever. Use it to quit your program.