Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbPerformanceTimer function

Author
Message
FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 6th May 2008 23:04
Hi, has anyone used the dbPerformanceTimer() function ?
Because when i use it, my application doesnt compile, it gives me this error:

error LNK2019: unresolved external symbol \"__int64 __cdecl dbPerformanceTimer(void)\" (?dbPerformanceTimer@@YA_JXZ)

cheers and thanks in advance
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 7th May 2008 07:18 Edited at: 7th May 2008 08:08
I will look into that for you, perhaps it is in a library that is not being included by default. I don't use GDK much yet, but...that function just calls the Windows function QueryPerformanceCounter, which you can call yourself directly, after you ensure that the windows.h header is included in the source file making the call. If you call QueryPerformanceFrequency first, and take the reciprocal of that, you will be able to multiply to get time slice values, instead of having to divide.
i.e. 1.0 / frequency = period
and
period * count = time

EDIT: NVM, I found it! Its in core.lib, but the include file is incorrect, its name is PerformanceTimer, not dbPerformanceTimer.

I think in this case, you might change the include file DarkSDKCore.h, line 82:
LONGLONG dbPerformanceTimer ( void );

I'd comment that out and put this in there:
LONGLONG PerformanceTimer ( void );

That should do it. (Of course, now your code must call PerformanceTimer, and not dbPerformanceTimer.)
FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 7th May 2008 17:29
Oh, thank you very much
And sorry for being lazy and not look it for myself
Im trying to do time based movement ,and im failing terribly
Cheers
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 8th May 2008 05:24
That's not lazy, unless you already knew how to search a library file. (I mean using VS, or another automatic search utility because I am that lazy - no apologies offered.)

The code you are writing is a part that I think is vital to get going early in the process. I think that most other methods fall apart very quickly, and then you've got an application that needs time-based control, but does not have anything to support it, or be driven by it. I think that alot of stuff that is otherwise good winds up by being scrapped on that basis. A few iterations of that starts to make the development system look limited and limiting.

Animation is time-based. I've not seen an animation technique that was not time based at a basic level. Tweening is all about time, in fact.

Physics is also implemented most often by some sort of time based integration/approximation. GDK already has Euler based rotation; Euler integration of physics seems appropriate in this case. While I have not done much in terms of applying my own physics to mimic ballistics for example, I can easily use the Euler rotation to aim my bullets, for example. Then, it is simple to use time-based movement of the bullet. It is like getting a ray cast for free. That certainly amortizes the cost of setting up the timing code first.

So, what are the issues with your implementation?
FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 8th May 2008 18:22 Edited at: 8th May 2008 18:23
Hi ,thanks for your kind reply.
This is a basic code ,just as a example of my problem:

Im telling to move a distance of 100 for each second, until it reachs 800. (you can imagine that as meters)
BUT ,it reachs 802-804 or some other value.
Its not too accurate and that is my issue.

Thanks for your help.
EDIT: some typos, im not a native English speaker
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 8th May 2008 18:57 Edited at: 8th May 2008 19:00
I think that your trouble is smaller than you might think. Let me say a few more things to consider.

You are using GetTickCount(). That is fine for now. Certainly the higher resolution of the performance counter is desireable, but I do not think that is your issue here...not yet anyway.

You have set the sync rate to 30, and your error is still very small, despite your frame period being ~33mSec. First, comment the line out that sets the frame rate to 30, leaving it at 60 (Frame period is then ~17mSec). GetTickCount is often blamed for timing issues that are not its fault, really. It might not improve, 0.5% is not a very large error in a program that does not have some type of preemption working for it, especially in a multi-tasking environment.

Later, if someone else has not already done so...I will show you how to use the performance counter. It has more resolution and accuracy, but you will never get to use ~1mSec accuracy until your sync rate is > 2000fps, unless you create multiple threads of execution. Still, I'm not certain that you will ever get an accuracy much higher than you have already in a game of much substance.

I think that if you want to limit the absoulte amount moved, you will need to try that one the last fame before the limit is reached. This is a common issue with collision detection, too. (You might move past the collision point before you are able to check for collision.)
FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 8th May 2008 19:05
When you say : 'I will show you how to use the performance counter'
you mean QueryPerformanceCounter() and QueryPerformanceFrequency() ?
I know what they are ,but dont know how to use it.

so what you say is that the code is not super wrong right ?

I didnt understand this part:
'you will need to try that one the last fame before the limit is reached'

Thanks again.
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 8th May 2008 19:38
1. Yes.
2. Yes. Really, its very nice looking code, I think.
3. Well, English is my native language, but typing is not my best skill! I meant during the last FRAME before the limit is reached! (You move it to 795, and notice that it will be past 800 on the next frame, so...you cheat, and move it to 800 anyway.)

I would do it now, but...I need a nap first.
FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 8th May 2008 20:10
thanks for all the replys
go and take that well earned nap
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th May 2008 21:57
Why not do something like this:


FERSIS
18
Years of Service
User Offline
Joined: 17th May 2006
Location:
Posted: 8th May 2008 22:43
I have a question tough. what value would have mspermove?
Thanks Diggsey.

Login to post a reply

Server time is: 2024-11-20 09:34:44
Your offset time is: 2024-11-20 09:34:44