Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DblStkSldr

CPU time in very basic win32 code

This topic is 5535 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Why does the code below use 99% of the CPUs time in the task manager when an application like the first tutorial in the Direct3D section on two-kings.de simply runs idle taking up 0%? They are both simple applications that create a window and have a window procedure and message loop. I can''t pick out what is causing the difference. Thanks for any help.
  // Main message loop

  while (true)  {
    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {

      if (msg.message == WM_QUIT)
        break;

      TranslateMessage(&msg);
      DispatchMessage(&msg);
    }      
  }

  return msg.message;

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Sleep(1); will reduce the cpu usage... though its not really recommended. 99% cpu usage is fine for a game.

Share this post


Link to post
Share on other sites
Well, after an admittedly quick glance at the tutorial, their main loop uses GetMessage instead of PeekMessage. GetMessage blocks until there is a message to process, so your not really eating much processor time. PeekMessage returns immediately whether there was a message or not, so your loop is running continuously. But as the AP already noted, 99% for a game really isn't a big deal...

[edited by - rimtgd on July 27, 2003 2:04:09 AM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!