Added experimental sync2() method to Display. We'll see which one works best and remove the worst one.
This commit is contained in:
parent
60352fe5e0
commit
deb08476ef
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue