The problem with sync is that yielding in a loop don't work that well with the new timer. Use sleep(1) instead. That is a change I think everyone will have to do in their game loop.
Here is a smal complete app that shows the difference:
package sh.tests;
import org.lwjgl.*;
import org.lwjgl.opengl.*;
import org.lwjgl.input.*;
public class LWJGL96Test {
static boolean useMiscPerf = true;
static sun.misc.Perf perf = sun.misc.Perf.getPerf();
static boolean sleep = false;
static long getFreq() {
if (useMiscPerf) {
return perf.highResFrequency();
} else {
return Sys.getTimerResolution();
}
}
static long getTime() {
if (useMiscPerf) {
return perf.highResCounter();
} else {
return Sys.getTime();
}
}
public static void main(String args[]) throws Exception {
try {
Display.setDisplayMode(new DisplayMode(640, 480));
Display.create();
GL11.glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
float ballx = 320;
float bally = 240;
float dirx = 250f;
float diry = 200f;
long timerFreq = getFreq();
long lastTime = getTime();
System.out.println("Use sun.misc.Perf="+useMiscPerf);
System.out.println("sleep="+sleep);
while (!Display.isCloseRequested()) {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
GL11.glLoadIdentity();
GL11.glTranslatef(ballx, bally, 0);
while (Keyboard.next()) {
if (Keyboard.getEventKeyState()) {
if (Keyboard.getEventKey() == Keyboard.KEY_F1) {
useMiscPerf = !useMiscPerf;
timerFreq = getFreq();
lastTime = getTime();
System.out.println("Use sun.misc.Perf="+useMiscPerf);
} else if (Keyboard.getEventKey() == Keyboard.KEY_F2) {
sleep = !sleep;
System.out.println("sleep="+sleep);
}
}
}
long now = getTime();
double timeDelta = (now-lastTime)/(double)timerFreq;
lastTime = now;
ballx += (float)(dirx * timeDelta);
bally += (float)(diry * timeDelta);
dirx = (ballx > 640 ? -250 : dirx);
dirx = (ballx < 0 ? 250 : dirx);
diry = (bally > 480 ? -200 : diry);
diry = (bally < 0 ? 200 : diry);
float radius = 30;
GL11.glBegin(GL11.GL_TRIANGLE_FAN);
GL11.glVertex3f(0, 0, 0);
for (int i=0; i<=64; i++) {
double angle = (Math.PI*2*i)/64;
GL11.glVertex3f((float)Math.sin(angle)*radius, (float)Math.cos(angle)*radius, 0);
}
GL11.glEnd();
Display.update();
if (sleep) {
Thread.sleep(1);
} else {
Thread.yield();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
Display.destroy();
}
}
}
Press F1 to switch between LWJGL 0.96 timer and sun.misc.Perf timer. Sorry if they removed the Perf timer in java 5.
Press F2 to switch between yield and sleep(1)
It is not smooth with LWJGL timer and yield.