Dark Bit Factory & Gravity

GENERAL => Projects => Topic started by: Rbz on February 06, 2007

Title: Delta Time test
Post by: Rbz on February 06, 2007
I'm working on delta time function using winapi  "QueryPerformanceCounter" and wondering if you can test it for me.
If everything is fine you will see a FPS counter, "Sytem OK" and a spinning cube, if not, an error message will appear.

Any feedback will be much appreciated, thanks.



Title: Re: Delta Time test
Post by: benny! on February 06, 2007
- Approx. 72 fps
- System OK
- But the spinning cube is on exctasy.
Title: Re: Delta Time test
Post by: Rbz on February 06, 2007
Do you mean it was spinning too fast ?
Title: Re: Delta Time test
Post by: benny! on February 06, 2007
Do you mean it was spinning too fast ?

Yup. Sorry to say that. But it is like the scroller. Way too fast. It's nearly just
flickering. You cannot really see that the cube is spinning.
Title: Re: Delta Time test
Post by: Rbz on February 06, 2007
hmm, Ok Benny! thanks a lot for your fast response  :)

I'll keep working on it
Title: Re: Delta Time test
Post by: Jim on February 06, 2007
Exactly the same here.  60Hz, but the cube is going crazy.  Just like the scrolly.

Jim
Title: Re: Delta Time test
Post by: Jim on February 06, 2007
I can see you're calling the drawing code in WM_PAINT, how is that message generated?  Also, you're not using QueryPerformanceFrequency().  Without that, QueryPerformanceCounter() isn't any use because you don't knwo how fast it's ticking.  Right now you're just dividing by 1000.

Jim
Title: Re: Delta Time test
Post by: Clyde on February 07, 2007
The cube is spinning nicely on my Geforce FX5500, this must be a gfx card issue. And my fps read is 74fps and system ok.
Title: Re: Delta Time test
Post by: Rbz on February 07, 2007
I can see you're calling the drawing code in WM_PAINT, how is that message generated?  Also, you're not using QueryPerformanceFrequency().  Without that, QueryPerformanceCounter() isn't any use because you don't knwo how fast it's ticking.  Right now you're just dividing by 1000.

Jim

Thanks a lot Jim, I guess the problem is solved, I was ignoring the "QueryPerformanceFrequency" that return diferents results for each computer, dividing "QueryPerformanceCounter" by 1000 is completely wrong  :-[

Here you will find some nice info about timing -> http://www.geisswerks.com/ryan/FAQS/timing.html

Code: [Select]
void Set_Frames_Counter()
{
QueryPerformanceFrequency(&HTimerVal);
HTimerFreq = HTimerVal.QuadPart;   
QueryPerformanceCounter(&HTimerVal);
LastTickCount = HTimerVal.QuadPart;
}

float Get_Frames_Delay()
{
float delay;

QueryPerformanceCounter(&HTimerVal);
delay = (float)((HTimerVal.QuadPart - LastTickCount)/HTimerFreq);
LastTickCount = (int)HTimerVal.QuadPart;

return delay;
}


Fixed the main loop, I'm using this now:

Code: [Select]
    //----------------------------- Main Loop ------------------------------
do
{
if(PeekMessage(&msg,hWnd,0,0,PM_REMOVE) != 0)
{
// translate and dispatch
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// Update and Draw OGL scene
glUpdate(Get_Frames_Delay());
glDraw();
SwapBuffers ( hDC );
}

}while(msg.message != WM_QUIT);
    //---------------------------------------------------------------------

The cube is spinning nicely on my Geforce FX5500, this must be a gfx card issue. And my fps read is 74fps and system ok.
Thanks Clyde, but it was bugged on some PC's..




Title: Re: Delta Time test
Post by: rdc on February 07, 2007
I get 75 fps and System OK on the new one. Seems to work fine.
Title: Re: Delta Time test
Post by: Jim on February 07, 2007
It's still not working right here. :(
Title: Re: Delta Time test
Post by: benny! on February 07, 2007
Works great now !!! Well done !!!
Title: Re: Delta Time test
Post by: taj on February 07, 2007
Rbraz:

61 fps, system ok, cube going mental...unwatchably fast.

ATI x600 laptop.
Title: Re: Delta Time test
Post by: Shockwave on February 07, 2007
I'm getting up to 180fps, system OK, cube spinning perfectly.

Intel Centrio Duo 1.83ghz.
Title: Re: Delta Time test
Post by: Ghost^BHT on February 07, 2007
my Office MAchine P4 2.8G Built in shit gfx  = 120fps and looks just fine here.
Title: Re: Delta Time test
Post by: Rbz on February 07, 2007
I found some problems in the code, changed "LastTickCount" and "HTimerFreq" to float variables.

Can you test it again, plz  :)
Title: Re: Delta Time test
Post by: benny! on February 07, 2007
@rbraz:

Still runs perfect on my machine !!!
Title: Re: Delta Time test
Post by: Clyde on February 07, 2007
My full monitors refresh rate dude of 75fps.
Title: Re: Delta Time test
Post by: Rbz on February 07, 2007
thx dudes  :)
Title: Re: Delta Time test
Post by: Ghost^BHT on February 08, 2007
Still runs the same here on my orafice machine   :||
Title: Re: Delta Time test
Post by: Jim on February 08, 2007
Now it's working!
The only difference between this PC and home now is that this PC says 60fps and home says 500+fps.  But both are drawing at the right rate.

Karma+ for sticking with it!

Jim
Title: Re: Delta Time test
Post by: Rbz on February 09, 2007
@wham:  thanks mate

@Jim:  Cool, of course with your help  :cheers: