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 4 of 4

Thread: how to control the mainloop interval?

Hybrid View

  1. #1
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Kaifeng,He'nan,PRC
    Posts
    68

    how to control the mainloop interval?

    I used to set a timer in MFC and make my render step with the TIMER Message,so I can control the interval of my app to swapbuffers,and it do well.

    but I am now lost in glut.*&%^$^$%$#^%%$#$@#$
    I only know the func glutMainLoop(void),but how can i control the loop interval by myself?

    thank for your help or your notice me.
    ========================
    As an old Chinese saying:One Live a Short while Die a Long...
    If I am useful to this world,I am reasonable to myself.
    =========================

  2. #2
    Guest

    Re: how to control the mainloop interval?

    In glut you can't. You must use winbloze code for that. (since glut is shell to winbloze)

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: how to control the mainloop interval?

    You can use the glutIdleFunc to control the framerate. The following pseudocode will lock the applicaiton at 50 FPS using GLUT.
    Code :
    int main()
    {
        ...
        glutIdleFunc(Idle);
        ...
        glutMainLoop();
    }
    void Idle(void)
    {
        while((GetCurrentTime - lastTime) < 20 milliseconds) {do nothing}
        lastTime = GetCurrentTime();
        glutPostRedisplay();
    }

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: how to control the mainloop interval?

    There's also a glutTimerFunc. I haven't used it much, but my guess is that it's accuracy is comparable to the Win32/MFC timer events.
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

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