Results 1 to 5 of 5

Thread: limit frames per second

  1. #1
    Guest

    limit frames per second

    hello all,

    for a viewer for a human evacuation simulation tool for architectural structures which i am developing i want to limit the fps to a fixed number. the viewer is written in c/c++ using open gl and the glu/glut libraries. maybe someones knows a cheap line of code to limit the fps output.

    greetings,
    kermit

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: limit frames per second

    dirty pseudocode :

    Code :
      render() {
        /* actual render code goes here */
        glFlush();
        while (getCurrentTime() < lastTime +delta) {
          sleep(10);
        }
        lastTime=lastTime+delta;
        SwapBuffers();
      }
    Maybe better, call render() in a timer set to your desired delta (and remove the glFlush).

  3. #3
    Guest

    Re: limit frames per second

    thx for the fast answer.
    of a "sleep" i have thinked allready myself, just wondering if there isn't some nice thing build in in GLU/GLUT to limit fps.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2005
    Location
    Berlin, Germany
    Posts
    188

    Re: limit frames per second

    If you already use glut, you can try something like

    Code :
    void timer(int) {
        glutPostRedisplay();
        glutTimerFunc(1000/DESIRED_FPS, timer, 0);
    }
    355/113 -- Not the famous irrational number PI, but an incredible simulation!

  5. #5
    Guest

    Re: limit frames per second

    thx for the answer, will try it later.

Similar Threads

  1. Frames Per Second??
    By in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 01-28-2004, 03:29 AM
  2. help with frames per second
    By mdog1234 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 12-06-2002, 01:26 PM
  3. Frames per second
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-29-2002, 11:06 AM
  4. Frames Per Second
    By smiley in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-28-2002, 07:05 AM
  5. frames ???
    By Blza in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 06-26-2000, 07:06 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