I’ve been following a youtube tutorial(The Coding Universe) for LWJGL and everything’s been working fine up until the section on timers.
I copied it directly as he was saying but when i did System.out.println(getDelta());
it’s returning not only extremly large numbers there are also negatives!
[quote]-46529436
-1408005007
1916619492
946277273
-219630599
-1189971696
2134655081
968748809
-1590588
-971929407
-2137834079
1186795520
216458401
-949444671
-1919780668
1404851209
238949737
-731384560
-1701718279
1427349145
457016548
[/quote]
private long getTime() {
//returns time in milliseconds
return (Sys.getTime()* 1000) / (Sys.getTimerResolution());
}
private int getDelta() {
long currentTime = getTime();
int delta = (int)(currentTime * lastFrame);
lastFrame = getTime();
return delta;
}
i get similar results with System.currentTimeMillis() and System.nanoTime()
[quote=currentTimeMillis()]1389113138376
1389113138393
1389113138409
1389113138426
1389113138443
1389113138459
1389113138476
[/quote]
[quote=nanoTime()]98300200493549
98300217430225
98300234429621
98300250546376
98300267714546
98300284704819
98300300789074
[/quote]
i wanted to see if it would affect the rest of the code, so i kept going (supposed to use the delta to move a box off the screen) but where you should see the box move off, it doesnt even show up. (or does and gets flung off the screen faster than i can see it?!)
and removing or keeping Display.sync(60); in the code doesnt change anything.
the code he linked in the comments for the example isnt quite the same either (same code pieces but main loop and opengl initialization is placed in the main instead of creating a method and starting it in the main.
working in eclipse on windows 8 pro if that makes any difference…