Results 1 to 5 of 5

Thread: How to save some CPU time?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Poland
    Posts
    10

    How to save some CPU time?

    Hello

    I have a simple animation in 2D using OpenGL and when I run it, it takes almost 95% of the CPU. Why? How can I decrease this usage?

    Regards

  2. #2
    Member Contributor
    Join Date
    Jul 2000
    Posts
    60

    Re: How to save some CPU time?

    Try limiting the rendering rate to say 30hz. To do this you will have to determine how long you spent rendering and then sleep for the remaining time in that particular frame. This will ofcourse free up your cpu but this may not be what you are wanting to do.

    In most cases, I would imagine that your program is running a single animation loop and it attempts to run this continously as fast as it can. Which by the sounds of it is happening. This is great but if you want to decrease the cpu usage, you will have have it rest every once and a while, these sleep operations will do that for you.

    Neil Witcomb

  3. #3
    Member Contributor
    Join Date
    Dec 2000
    Location
    Halifax, Nova Scotia, Canada
    Posts
    86

    Re: How to save some CPU time?

    Something as simple as synchronising to the monitor refresh may help. If you are not doing this you may be rendering many times for each actual 'draw'.
    Joe

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    352

    Re: How to save some CPU time?

    You can even tell your program to redraw only once every 3 monitor refreshes... in any case, the extension to use is WGL_EXT_swap_control

  5. #5
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Poland
    Posts
    10

    Re: How to save some CPU time?

    Originally posted by Morglum:
    You can even tell your program to redraw only once every 3 monitor refreshes... in any case, the extension to use is WGL_EXT_swap_control
    Hi
    Can you send me or point me to an example which uses this mechanism?

    Thanks

Similar Threads

  1. Please, Save me.
    By GodDamn in forum OpenGL: User Software
    Replies: 6
    Last Post: 03-21-2010, 08:18 AM
  2. clock time as the current time ??
    By John22 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-08-2009, 05:54 PM
  3. wglCreateContext failing from time to time
    By Janko Jerinic in forum OpenGL: Windows
    Replies: 3
    Last Post: 07-23-2009, 02:40 PM
  4. glDrawElements() crash from time to time
    By _NK47 in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 07-14-2008, 11:34 AM
  5. Small sprites - Favour fragment time over vertex time?
    By centipede in forum OpenGL: GLSL
    Replies: 4
    Last Post: 11-24-2005, 12:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean