I’m just trying to cap the fps at 60, and get a fps counter, but my loop seems to be eating a ton of my resources:
public static void main(String[] args) {
joglplat m = new joglplat();
while(true){
fpscounter = 1000;
long startTime = System.nanoTime() / 1000000;
//startTime = System.currentTimeMillis();
//System.out.println("st2: " + startTime);
try
{
m.controls();
m.update();
m.repaint();
fpscounter = ((System.nanoTime() / 1000000)-startTime);
do {
Thread.yield();
} while ((System.nanoTime() / 1000000)-startTime < 17);
}
catch(Exception e){
e.printStackTrace();
}
//System.out.println("framerate: " + (60 - fpscounter));
}
}