cpu hog!
I was simply wondering how do I prevent my program from becoming a cpu hog? I am using the PeekMessage method and I cannot switch to get without irritating anyone who wants to use my program. Is there a way to just limit the program to update only 30fps?
Thanks for the help
while (running){ process_messages(); if (time() < next_step) Sleep(0); else do_next_step();}
Well, if your app is running in the foreground, it's perfectly acceptable to use 100% of the CPU. If nothing else is using the CPU, there's no problem. You could also change your process priority if you want to, but I don't think it's really worthwhile.
In my engine, I just do a busy loop with PeekMessage(), then Render() after all messages have been processed for a frame, and if the app gets minimised, it switches to GetMessage() and no rendering.
In my engine, I just do a busy loop with PeekMessage(), then Render() after all messages have been processed for a frame, and if the app gets minimised, it switches to GetMessage() and no rendering.
Quote:Original post by Evil SteveI agree. I also tried this and found no real advantage. Today' scheduler is pretty smart even without those hints.
You could also change your process priority if you want to, but I don't think it's really worthwhile.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement