Share this post

Link to post

Share on other sites

The easiest way in my opinion would be to use multimedia timers and run your graphics through a callback. The associated functions are:timeBeginPeriodtimeEndPeriodtimeGetDevCapstimeGetSystemTimetimeGetTimetimeKillEventTimeProctimeSetEvent

These can be looked up in MSDN for explanations and usage.Good luck! =]

Share this post

Link to post

Share on other sites

Thanks, I'll look into those.. I think also that I remember there being a function which you call in such times when you're doing nothing that will transfer the CPU over to another application.. Anyone know if I'm imagining things or if there's such a function?

Just for clarification, this is MSVC++6 and a windows app.

Edited by - Ivko on December 30, 2001 1:54:26 PM

0

Share this post

Link to post

Share on other sites

Try Sleep(1). That will give up your remaining timeslice. Or if you have an idea of how many milliseconds you need to burn, just to Sleep(milliseconds). Remember though that no timer function is going to be exact, so err on the side of caution. Also, GetTickCount() has a granularity of 10ms.

-Brannon

0

Share this post

Link to post

Share on other sites

I guess my first question would be what are you saving the CPU for? Unless you are running under an operating system that is not pre-emptive or you have to pay for the CPU you use or your boss is monitoring how much CPU you are using then I don''t see the point. Use it or lose it. Running at 50% for a week doesn''t mean you can run at 150% the next week.

0

Share this post

Link to post

Share on other sites

Even under a pre-emptive OS, if your process is constantly trying to run, it can still "choke out" other processes. There are a finite number of timeslices per second. The OS can only do so much to try to give each process enough time..

Ivko, you have the right idea .. if you aren''t going to use the timeslice, give it up for another process/thread to use. Be a good citizen.

-Brannon

0

Share this post

Link to post

Share on other sites

Tell me. The last time you played a real-time game what important task were you running in the background? Hum, maybe you were defraging the hard drive. That is I/O bound, not CPU bound, but would you seriously do that while playing a game?

0

Share this post

Link to post

Share on other sites

Thanks for your input. What would I do? Play mp3s, use IRC, and be able to switch tasks to do something quick without the system grinding to a halt. It's just good practice, at the moment my game does nothing other than run the main loop and it takes up 100% CPU usage. There's no reason not to do it, and it just doesn't seem right. Another example is if I decided later to make something that's not a fullscreen game, I don't want it wasting all CPU power.