windows - What is the most efficient way to keep a steady frame rate with DirectX and C++? -


I am learning DirectX from a book about game programming, and it uses the following method for a game loop Is:

  long int start = GetTickCount (); While (true) GameRun (); Void GameRun (if (GetTickCount () - Start> gt; = 30) // do stuff}  

This is the start equals (I

My question is, will not, I would not want that, the number of ticks 'counting the number of ticks' since the program began), and then, after 30 ticks, all the A , Rendering, etc. It is more efficient to do all AI etc, first, if time is over, wait until the frame needs to be changed. So, what would be a better way to keep the static frame rate? (Generally using only DirectX headers that I already have sound, images and notifications (like D3 D9H )

And, on the related note, what exactly does GetTickCount () do, and for how long a 'tick' is

Read, for your game loop, it adds your options and makes your choice clear. .

Now for GetTickCount (), this is the easiest way to get time in Windows (I do not know one for Unix OS). QueryPerformanceFrequency and QueryPerformanceCounter give more accuracy, but it can be hard to understand how to use them.

The way you are interested in reading (). They have added some code to deal with some of the possible problems with those tasks and have code for many platforms.

You can take codes and use it in your app.

In this way you can focus on your game loop and game code.


Timely on update time: Now if you can use the last boost version, then provide a high-precise clock, stable_clock, which is cross platform and in fact, crono There is a proposal other than the standard library.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -