There is no flaw in your logic. Because the two computers update at different intervals they are going to get different results. This is because the iterative integration that we perform in these formulae are only approximations of the true integration. This is the only reason why you should lock the framerate at times, because you need to get the exact same result on both machines. Note you don''t have to lock the frame rate of your game, only the rate of updating the positions and velocities.
You should also know that with the simple formulae we have in our particle example can be integrated to a higher formula (of second degree) that can then be used to compute the position of the particle each frame without using iterative integration.
- WitchLord
Locking FPS- Part II
ahhhh this thing is driving me insaneeeee!!!
Ok Masterworks I did what you told me in your pseudocode but it still runs too fast!
what mistake(s) am I making?
Here is the code I used:
beginning of the code i have this:
....
QueryPerformanceFrequency((LARGE_INTEGER *) &timer.frequency);
QueryPerformanceCounter((LARGE_INTEGER *)&timer.performance_timer_start);
timer.resolution = (float)1.0/timer.frequency;
....
now in the draw routine I have this:
{
__int64 time;
static double angle = 0.0, nt = 0.0;
double milli = timer.resolution*1000.0; //convert to ms
QueryPerformanceCounter((LARGE_INTEGER *) &time);
nt = (double)(time - timer.performance_timer_start)*milli;
angle= angle+(360*nt/1000.0);
....//rotate the line using angle.
...swap buffer
}
and it still doesn''t work!! (well its out of control)
sig u say?
Ok Masterworks I did what you told me in your pseudocode but it still runs too fast!
what mistake(s) am I making?
Here is the code I used:
beginning of the code i have this:
....
QueryPerformanceFrequency((LARGE_INTEGER *) &timer.frequency);
QueryPerformanceCounter((LARGE_INTEGER *)&timer.performance_timer_start);
timer.resolution = (float)1.0/timer.frequency;
....
now in the draw routine I have this:
{
__int64 time;
static double angle = 0.0, nt = 0.0;
double milli = timer.resolution*1000.0; //convert to ms
QueryPerformanceCounter((LARGE_INTEGER *) &time);
nt = (double)(time - timer.performance_timer_start)*milli;
angle= angle+(360*nt/1000.0);
....//rotate the line using angle.
...swap buffer
}
and it still doesn''t work!! (well its out of control)
sig u say?
ok i managed to get it work!!!
all i had to do was to reset the timer:
thanks to all those who have helped me
sig u say?
all i had to do was to reset the timer:
quote:Original post by Xtreme
ahhhh this thing is driving me insaneeeee!!!
Ok Masterworks I did what you told me in your pseudocode but it still runs too fast!
what mistake(s) am I making?
Here is the code I used:
beginning of the code i have this:
....
QueryPerformanceFrequency((LARGE_INTEGER *) &timer.frequency);
QueryPerformanceCounter((LARGE_INTEGER *)&timer.performance_timer_start);
timer.resolution = (float)1.0/timer.frequency;
....
now in the draw routine I have this:
{
__int64 time;
static double angle = 0.0, nt = 0.0;
double milli = timer.resolution*1000.0; //convert to ms
QueryPerformanceCounter((LARGE_INTEGER *) &time);
nt = (double)(time - timer.performance_timer_start)*milli;
<-----reset timer here----->
angle= angle+(360*nt/1000.0);
....//rotate the line using angle.
...swap buffer
}
and it still doesn''t work!! (well its out of control)
sig u say?
thanks to all those who have helped me
sig u say?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement