• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# GetTickCount is not perfect!

## Recommended Posts

Yesterday, I ran one of my programs. It uses GetTickCount for animations. I just multiply the distance or angles with the GetTickCount result. The problem: It ran at half the normal speed!!! But after a reset, all went back to normal. Are there more people who even encountered such a problem?

##### Share on other sites
i think maybe it had to do somthing with your computer's buffers, not your program. i think that there is a function that can refreshes your video buffers when your program starts to fix this problem.

but i like timeGetTime() better anyways for my FPS regulations and animations.

Edited by - gameprogrammerwiz on June 15, 2000 6:21:54 PM

##### Share on other sites
Yes, using the timer functions can be really anyoying sometimes. There is a better set of functions in the mmsystem.h include file called the high performance counter functions, which are super accurate. The only problem with them is they don''t work on older systems (486 and under I believe, if I am wrong someone correct me). Other than that, I have used hires timer for everything and haven''t run into a single problem yet.

the two functions you use are:
QueryPerformanceFrequency and QueryPerformanceCounter

##### Share on other sites
That''s the function I was looking for! Um, is it compatible with GetTickCount? Like, does it use the same intervals.

------------------------
Captured Reality.

##### Share on other sites
Just thought I would throw in my experiences with the hires timers.

I used to use GetTickCount() to time animations and move objects based on the frame rate. That worked fine for my pIII600 but when I went and tried it on a p200 I would get jerkiness. Then I decided to try out QueryPerformanceFrequency and QueryPerformanceCounter. After trying those out my program ran smoothly on both pc''s.

nes8bit:
To get the time intervel/resolution of the hires timer call
QueryPerformanceFrequency, that will give you the ticks per
second.

ao

##### Share on other sites
HTH.
gimp

init:

LARGE_INTEGER		Freq, OldTick,CurTick,DeltaTick;QueryPerformanceFrequency(&Freq);QueryPerformanceCounter(&OldTick);

and the actual timer(I convert to a float)

QueryPerformanceCounter(&CurTick);SubLarge(&OldTick, &CurTick, &DeltaTick);OldTick = CurTick;if (DeltaTick.LowPart > 0)	ElapsedTime =  1.0f / (((float)Freq.LowPart / (float)DeltaTick.LowPart));else 	ElapsedTime = 0.001f;

Utility for 64bit interger math
void SubLarge(LARGE_INTEGER *start, LARGE_INTEGER *end, LARGE_INTEGER *delta){	_asm 	{		mov ebx,dword ptr [start]		mov esi,dword ptr [end]		mov eax,dword ptr [esi+0]		sub eax,dword ptr [ebx+0]		mov edx,dword ptr [esi+4]		sbb edx,dword ptr [ebx+4]		mov ebx,dword ptr [delta]		mov dword ptr [ebx+0],eax		mov dword ptr [ebx+4],edx	}}

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627653
• Total Posts
2978433

• 10
• 12
• 22
• 13
• 33