ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i really need to make an fps limiter, but i just can't find any time function that will return the time in milliseconds. it's for windows and c++ (if that matters)... please help.
For windows you might want to look at timeGetTime, which I believe is in winmm.lib and mmsystem.h. timeGetTime will give you the number of milliseconds since the machine was last rebooted. It wraps at something like 49 days, so depending on your application, you might want to keep that in mind.
For even more accurate timing, you can use a combination of QueryPerformanceCounter and QueryPerformanceFrequency.
And yes, it is ok to ask Windows questions here.
BTW, why do you need to limit FPS? If this is to slow down an animation for something like a 3D app, a better way is usually to base the animation on time rather than frame counts. This method allows faster computers to display smoother animation, and is how most games work. Trying to lock the animation to a fixed rate you could also potentially run into the problem of slower computers that can't keep up.
Originally posted by iriad thanks. i think that'll be good enough, i don't really expect the client of an mmorpg to be running for that long.
It doesn't wrap based on how long your client has been running, though. It is based on how long since Windows has started. So if you have someone who hasn't rebooted for 49 days (I know, not very likely with Windows, but I think I have come close to that a few times... ) you could have the timer wrap on you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.