Ok, one last question and I'll stop bothering you for a bit
:
Why does my script run 10 times slower when VSYNC wait is enabled ?
I measure the time that it takes to run a given script so that I can call it every
n milliseconds. When I activate "wait for refresh" in my video card's drivers, that script takes much, much longer to finish: without VSYNC wait it takes an average of 9 milliseconds; with VSYNC wait on, at 75 Hz, it takes about 110 ms.
At 75Hz a call to "wait for VSYNC" takes at most 13 ms, so it's not just that the script is interrupted by screen draw each time it runs, there has to be something else.
Does anyone know what is going on ? Maybe it's just that I don't understand how script execution is scheduled... in this case is there something that documents it ?
Cheers,
Olivier
Here's my main loop from
scene_init.script:
while (DropGame.GameState != "end")
{
var duration;
var frame_time = 20;
var start_time = Game.CurrentTime;
// update
DropGame.Update();
duration = (Game.CurrentTime - start_time );
var sleep_time = frame_time - duration ;
if ( 0 < sleep_time)
Sleep(sleep_time);
Game.LOG("Frame time is "+duration);
}
DropGame.Update() does some array management and creates an Object every 3 frames. It used to update sprites but I took out all the graphics functions to see if they were causing the slowdown (it made things a little better but not much.)