Lachlan87
Moderator
USA
160 Posts |
|
Sr. Guapo
Swordmaster
USA
272 Posts |
Posted - Jun 10 2004 : 4:14:25 PM
|
That is one way of doing it (and how I do it). You could use QueryPerformanceCounter for more accuracy, but it really isn't needed. That should work fine.
|
|
|
EACam
Warrior
154 Posts |
Posted - Jun 10 2004 : 4:17:55 PM
|
Just to be picky...i like to place the FirstTime = timeGetTime statement LAST because it would supposedly be more accurate that way...but then again, the 2 lines before it would barely take a phemtosecond, so it's no big deal...or even a little deal. |
|
|
Lachlan87
Moderator
USA
160 Posts |
Posted - Jun 10 2004 : 4:26:21 PM
|
Ok, thanks. I have one more question though. Why does useing GetTickCount make my FPS so much lower than using TimeGetTime? TimeGetTime will put me at about 85 FPS, whereas GetTickCount will put me at about 20 FPS. |
|
|
EACam
Warrior
154 Posts |
Posted - Jun 10 2004 : 6:23:37 PM
|
Um...what IS TimeGetTime? I've never heard of it. |
|
|
Sr. Guapo
Swordmaster
USA
272 Posts |
Posted - Jun 10 2004 : 6:29:07 PM
|
I've seen it, but I always though it was the same as GetTickCount... Guess not... |
|
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Jun 10 2004 : 6:49:10 PM
|
That's odd, there shouldn't be that much of a difference between the two functions.
|
|
|
masterbooda
Swordmaster
277 Posts |
Posted - Jun 10 2004 : 7:06:42 PM
|
Just to add my 2cents to this post, Query Perfomance is a lot better to use when you are wanting to manage a frame rate, for example I used the above method and my program starts at 400, but I want it to run to 60fps... It took a long time to go down to 60fps(because the program has to find the best delay)... but with query I can put a delay into the loop that will only allow it to draw 60fps... Of course this is just my opinion... for even better accuracy use timed movement, and then you don't have to worry about fps at all...
DaBooda out...
P.S. If all you are doing is reading the FPS the above method works fine... |
DaBooda Team is back: http://dabooda.789mb.com/ |
|
|
Sr. Guapo
Swordmaster
USA
272 Posts |
Posted - Jun 10 2004 : 7:18:48 PM
|
Yes, QPC (for short) is much better for setting a framerate and doing things like time based modelling, but for only calculating the FPS, getTickCount/timeGetTime should be more than enough... |
|
|
Sr. Guapo
Swordmaster
USA
272 Posts |
Posted - Jun 10 2004 : 9:57:56 PM
|
Also, have you checked your various processes and CPU usage with Task Manager? It is possible that GetTickCount is using a different (and more congested) thread than timeGetTime... If you are still having problems with either of those, just switch to QPC. It is very easy to do, and it never has any problems that I've heard of... |
|
|
game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Jun 11 2004 : 09:25:03 AM
|
will if you agree that there is no game should run with speed of < 5
then put a condition if fps < 5 then fps = 60 (to manage the first second)
another thing the comparing (>=) may do some further calculation than >
so I always like to use x > (y-1) insteed of x >= y ,,,ie > 999 for integers |
|
|
EACam
Warrior
154 Posts |
Posted - Jun 11 2004 : 10:00:05 AM
|
Really? Does that speed it up? I've never heard of it, but doing > (y - 1) seems that it COULD be faster, i wouldn't know. |
|
|
VBBR
Moderator
Brazil
617 Posts |
Posted - Jun 11 2004 : 10:11:56 AM
|
To me it seems slower, because first it needs to do the calculation (y - 1) and then compare the values.
(oh and just for you all to know, I just made my first subscription to pscode , if you want to take a look at it, see here. |
Whatever. Who knows... |
|
|
game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Jun 11 2004 : 10:56:15 AM
|
VBBR : (y - 1) is pre-calculation. I.e. you don't put 1000-1, you just put 999
Still not that sure
There is 2 way to solve (>=)
It may be separate (meaning first compare > then compare = )
I.e. x >= y change to (x > y or x = y)
For this, clearly x > (y-1) faster, where (y-1) is pre-calculated
Or combining method (test >= together): witch I don't know
I don't know what vb is using but doing x > (y-1) seems to got more logic percentage
|
|
|
VBBR
Moderator
Brazil
617 Posts |
Posted - Jun 11 2004 : 12:03:59 PM
|
But it will be slower if (y - 1) can't be pre-calculated i.e. a varible-sized array loop. |
Whatever. Who knows... |
|
|
game_maker
Knave
Saudi Arabia
83 Posts |
Posted - Jun 11 2004 : 12:42:34 PM
|
unquestionably |
|
|