Made Display.timeNow local

This commit is contained in:
Elias Naur 2007-08-30 12:19:34 +00:00
parent 3d81b7715d
commit 7e05654cd2
1 changed files with 4 additions and 4 deletions

View File

@ -75,7 +75,7 @@ public final class Display {
private static DisplayMode current_mode; private static DisplayMode current_mode;
/** Timer for sync() */ /** Timer for sync() */
private static long timeNow, timeThen; private static long timeThen;
/** X coordinate of the window */ /** X coordinate of the window */
private static int x = -1; private static int x = -1;
@ -353,7 +353,7 @@ public final class Display {
public static void sync3(int fps) { public static void sync3(int fps) {
synchronized (GlobalLock.lock) { synchronized (GlobalLock.lock) {
float frameTime = 1.0f / (fps > 1 ? fps - 1 : 1); float frameTime = 1.0f / (fps > 1 ? fps - 1 : 1);
timeNow = Sys.getTime(); long timeNow = Sys.getTime();
while (timeNow > timeThen && (float) (timeNow - timeThen) / (float) Sys.getTimerResolution() < frameTime) { while (timeNow > timeThen && (float) (timeNow - timeThen) / (float) Sys.getTimerResolution() < frameTime) {
// This is a system-friendly way of allowing other stuff to use CPU if it wants to // This is a system-friendly way of allowing other stuff to use CPU if it wants to
Thread.yield(); Thread.yield();
@ -373,7 +373,7 @@ public final class Display {
public static void sync2(int fps) { public static void sync2(int fps) {
synchronized (GlobalLock.lock) { synchronized (GlobalLock.lock) {
long gapTo = Sys.getTimerResolution() / fps + timeThen; long gapTo = Sys.getTimerResolution() / fps + timeThen;
timeNow = Sys.getTime(); long timeNow = Sys.getTime();
while (gapTo > timeNow + timeLate) { while (gapTo > timeNow + timeLate) {
Thread.yield(); Thread.yield();
@ -397,7 +397,7 @@ public final class Display {
public static void sync(int fps) { public static void sync(int fps) {
synchronized (GlobalLock.lock) { synchronized (GlobalLock.lock) {
long gapTo = Sys.getTimerResolution() / fps + timeThen; long gapTo = Sys.getTimerResolution() / fps + timeThen;
timeNow = Sys.getTime(); long timeNow = Sys.getTime();
while (gapTo > timeNow + timeLate) { while (gapTo > timeNow + timeLate) {
try { try {