Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: my simple demos often cause CPU usage 100%,why?

  1. #1
    Junior Member Newbie
    Join Date
    May 2005
    Location
    China
    Posts
    6

    my simple demos often cause CPU usage 100%,why?

    ...
    ...

  2. #2
    Intern Contributor
    Join Date
    Feb 2004
    Location
    Dallas/ Nottingham
    Posts
    96

    Re: my simple demos often cause CPU usage 100%,why?


  3. #3
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,142

    Re: my simple demos often cause CPU usage 100%,why?

    Most code frameworks use a "render as many frames as possible" scheme. This means that either a part of the GPU pipeline or the CPU will always run at 100%. This is expected behaviour and nothing to worry about.

  4. #4
    Guest

    Re: my simple demos often cause CPU usage 100%,why?

    For a full-screen app, I think it is ok.
    But, for a windowed app, I don't think it is always good.

  5. #5
    Guest

    Re: my simple demos often cause CPU usage 100%,why?

    Insert a 1ms delay somewhere in the loop of your code. This will drasticly reduce cpu usage and makes almost no difference in game performance.

    Mark

  6. #6
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,527

    Re: my simple demos often cause CPU usage 100%,why?

    Most of the simple tutorials put their rendering calls into the idle loop. This is "game style".
    If you don't need that, write a standard window message handler and do the drawing inside the WM_PAINT handler and you won't use any CPU cycles if your demo doesn't need to react on paint messages.
    If you want it animated, setup a timer with SetTimer() and a WM_TIMER message handler calling InvalidateRect() which sends WM_PAINT messages to your handler.
    Very clean, but not to be used for fullspeed or benchmarks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •