I'm learning DirectX from a book about game programming, and it uses the following method for a game loop:
long int start = GetTickCount();
while(true)
GameRun();
void GameRun()
{
if(GetTickCount() - start >= 30)
//do stuff
}
This makes start
equal whatever the time is (I'm guessing get tick count gives the number of 'ticks' since the program started), and then, 30 ticks later, does all of the AI, rendering, etc.
My question is, wouldn't it be more efficient to do all of the AI, etc. first, then, if theres time left over, wait until the frame needs to be changed?
So, what would be a better way to keep a steady frame rate? (Preferably only using DirectX headers that I would already be using for sound, images and imput (like d3d9.h))
And, on a related note, what exactly does GetTickCount() do, and how long is a 'tick'