Added experimental sync2() method to Display. We'll see which one works best and remove the worst one.

This commit is contained in:
Caspian Rychlik-Prince 2004-07-09 11:20:14 +00:00
parent 60352fe5e0
commit deb08476ef
1 changed files with 22 additions and 0 deletions

View File

@ -284,6 +284,28 @@ public final class Display {
}
timeThen = timeNow;
}
/**
* Alternative sync method which works better on triple-buffered GL displays.
* @param fps The desired frame rate, in frames per second
*/
private static long timeLate;
public static void sync2(int fps) {
long gapTo = Sys.getTimerResolution() / fps + timeThen;
timeNow = Sys.getTime();
while (gapTo > timeNow + timeLate) {
Thread.yield();
timeNow = Sys.getTime();
}
if (gapTo < timeNow)
timeLate = timeNow - gapTo;
else
timeLate = 0;
timeThen = timeNow;
}
/**
* Initialize and return the current display mode.