Timing in win32
#1 Members - Reputation: 122
Posted 14 October 1999 - 12:42 AM
#5 Members - Reputation: 122
Posted 08 October 1999 - 04:10 PM
The following code should work:int timerFrequency;
if (!QueryPerformanceTimer(&timerFrequency)) {
// Insert fall back code using GetTickCount here
}
else {
// A high resolution timer exists, the number of "ticks" per second is in timerFrequency
int currTime;
QueryPerformanceCounter(&currTime);
// Now we have the current tick count in currTime
}
So, basically you just need QueryPerformanceCounter and Frequency, and both can be included in with "winbase.h" (or i think if you use other WinAPI functions bay already be included)
#6 Members - Reputation: 122
Posted 10 October 1999 - 10:33 PM
#7 Members - Reputation: 122
Posted 11 October 1999 - 03:22 AM
I personally find seperating the game in 4 threads connected with queues very usefull. One for "AI" (essentially anything complicated that require lots of processing and doesn't need to update with the same frequency as the framerate), one for rendering, one for UI and one for networking.
/Niels
#8 Members - Reputation: 122
Posted 13 October 1999 - 12:00 PM
The problem with your multithreaded approach is that there are several more threads that you don't even seem. For example, Flip() spawns a thread, async WinSock spawns a thread, etc. At most I could definately see a need for a second thread that handle's non-framerate dependant low priority stuff like AI, but the rest you might as well put into a well-organized main loop that will in the long run save you debugging time, speed up your program, ease portability AND readability issues and just make for a better program
#9 Members - Reputation: 122
Posted 14 October 1999 - 12:42 AM
:http://home.worldonline.dk/~noshit/scrshots.html
(35fps on a 90Mhz pentium with 4Meg VMem, 90fps on a 400 PII (limited by screen refresh rate))..
But you're right - unless you do a proper design, your threads will spend more time waiting for each other, than getting actual work done....
/Niels
[This message has been edited by Niels (edited October 14, 1999).]






