LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Orangy Tang on October 25, 2006, 16:47:08

Title: Odd Display.sync timing issues
Post by: Orangy Tang on October 25, 2006, 16:47:08
This is baffling me, to the point where I feel I must be missing something obvious - the following code works just dandy on my home pc, and on several other pcs, but my work pc runs at twice the framerate instead of the capped 60fps.


while (gameRunning)
{
Display.sync(FRAME_RATE);

update();

render();

if (Display.isCloseRequested() || Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
gameRunning = false;

Display.update();
                                }

sync() runs at ~120fps. sync2() gives 75fps, and sync3() gives ~220fps. On other machines these stick to 60fps as expected.

This is windowed, and I don't try and set vsync either. I don't understand how I could be seeing such different behaviours on this machine. Oddly, Cas' Titan Attacks seems to be normal speed, and the Space Invaders demo seems to be normal speed too. As far as I can see my loop is identical to the one in Space Invaders.

Has anyone any ideas as to what to try next? Cheers

Just from eyeballing the values from Sys.getTime(), they appear to be counting up twice as fast as they should be. Why would this be so?
Title: Odd Display.sync timing issues
Post by: Orangy Tang on October 25, 2006, 17:07:34
Hmm. I upgraded to lwjgl beta 3 and it seems to be fixed, IIRC my previous version was beta 1.

Edit: and now it's broken again. Without actually changing any code. WTF?
Title: hmmmmmmm....
Post by: Fool Running on October 25, 2006, 17:26:37
Can you actually verify that Sys.getTime() is counting too fast?

Is it possible that the machine doesn't support 1ms time of the timers? We don't seem to be checking for errors in org_lwjgl_Sys.Java_org_lwjgl_NativeSysImplementation_getTime(). It might be possible that we are getting an error and ignoring it. We just spit out a hard-coded 1000 for the Java_org_lwjgl_NativeSysImplementation_getTimerResolution() as well, instead of actually checking to see if its possible :D

This might possibly be a bug in the way LWJGL handles the timers :cry:

EDIT: This was all assuming you are working on Windows :) I can't seem to find the Sys implementation code for the other platforms :?
Title: Odd Display.sync timing issues
Post by: Orangy Tang on October 25, 2006, 17:28:15
Even System.currentTimeMillis is twice as fast as it should be. :(
Title: Re: hmmmmmmm....
Post by: Orangy Tang on October 25, 2006, 17:30:38
Quote from: "Fool Running"Can you actually verify that Sys.getTime() is counting too fast?
How? At the moment I'm just printing it out, just watching it it's quite clear that it's counting faster than 1000 every second.

I was just about to verify it in code by comparing against System.currentTimeMillis, but that seems to be too fast too. The code is currently 1.4 so I can't easily check against the new nano timer, but I might look into it.
Title: Odd Display.sync timing issues
Post by: Fool Running on October 26, 2006, 13:21:26
QuoteHow? At the moment I'm just printing it out, just watching it it's quite clear that it's counting faster than 1000 every second.
That's good enough for me :lol:

QuoteI was just about to verify it in code by comparing against System.currentTimeMillis, but that seems to be too fast too.
That's really strange... :?

Well, I'm out of ideas. Anyone else can chime in here :D
Title: Odd Display.sync timing issues
Post by: MarneusCalgarXP on October 27, 2006, 08:44:48
Just an question : did you overclock your CPU ?
Title: Odd Display.sync timing issues
Post by: Orangy Tang on October 28, 2006, 10:59:21
No, no overclocking going on.

Oddly enough the problem seems to come and go. I'm starting to wonder whether particular other programs may be messing with the clock or something equally stupid.
Title: Odd Display.sync timing issues
Post by: princec on October 28, 2006, 11:16:04
Same old problem: system changes its clock speed to cope with internal load. Probably because it's a cheapass heap of rubbish they gave you in the office, yes?

Cas :)
Title: Odd Display.sync timing issues
Post by: Orangy Tang on October 30, 2006, 13:23:12
Well it's a dual Intel Xeon 3.0Ghz, so it's supposed to be quite good. However theres definately something funny going on. I'm going to have a poke around in the BIOS and see if I can spot anything to disable.
Title: Odd Display.sync timing issues
Post by: Matzon on October 30, 2006, 14:28:41
try disabling HT if it has it