Results 1 to 7 of 7

Thread: skeleton glut app has low frame rate (code)

  1. #1
    Member Newbie
    Join Date
    Jun 2005
    Posts
    42

    skeleton glut app has low frame rate (code)

    I'm just swapping buffers here and getting only 76 frames per second. Can that be right? In order to maintain 60fps I would need to spend 4/5ths of the time on each frame just swapping the buffer. This is on a GeForce4 TS 2ghz AMD.

    Code :
    #include <gl\glut.h>
    #include <stdio.h>
     
     
    int ticks = 0;
     
    void countFPS(int t)
    {
    	printf("FPS: %d\n", ticks);
    	ticks = 0;
    	glutTimerFunc( 1000, countFPS, 0);
    }
     
    void renderScene(void) //**RENDERSCENE**//
    {	
    	ticks++;
     
    	glutSwapBuffers();
    	glutPostRedisplay();
    }
     
    int main(int argc, char **argv)
    {
    	glutInit(&amp;argc, argv);
    	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
     
    	glutInitWindowPosition(40,175);
    	glutInitWindowSize(800,600);
    	glutCreateWindow("frame rate test");
     
    	glutDisplayFunc(renderScene);
     
    	glutTimerFunc( 1000, countFPS, 0);
    	glutMainLoop();
     
    	return(0);
    }

  2. #2
    Guest

    Re: skeleton glut app has low frame rate (code)

    do you have vsync enabled?

    You can disable it within your app with the WGL extension wglSwapInterval(0).

  3. #3
    Member Newbie
    Join Date
    Jun 2005
    Posts
    42

    Re: skeleton glut app has low frame rate (code)

    I just recomplied with GL_SINGLE and now I get over 340,000 FPS. Could vsync be screwing up double buffering and not single? My desktop refresh is 60hz, so I thought vsync couldn't be an issue.

  4. #4
    Guest

    Re: skeleton glut app has low frame rate (code)

    With a single buffer, there is no buffer to swap.

    You can also disable the vsync from your desktop settings dialog. Try that and see what happens...

  5. #5
    Member Newbie
    Join Date
    Jun 2005
    Posts
    42

    Re: skeleton glut app has low frame rate (code)

    I forgot to say I was calling glFlush with the single buffer.

    But you're right, its vsync. This app runs at 1500fps after disabling vsync in the nvidia control panel.

    I'm not sure what to do now. I'm rendering a heightmap with texture blending and I get an extra 10 to 15 FPS with vsync turned off. Do all games turn vsync off then?

  6. #6
    Guest

    Re: skeleton glut app has low frame rate (code)

    glFlush empties the command buffers, while glFinish blocks until all commands complete. Neither of these calls have anything to do with vsync or frame buffer swapping. With vsync enabled in a double buffer configuration, SwapBuffers() waits for the next vertical retrace to swap the front and back frame buffers. In a single buffer scenario, there is only the front buffer, hence no swap is possible and vsync becomes irrelevant.

    Do all games turn vsync off? Don't know. Some do. Obviously you'd like to leave it on for the visual quality, but I think some games make it an option, so gamers can turn it off for the extra fps, especially on older systems that are struggling with the newer games...

  7. #7
    Member Newbie
    Join Date
    Jun 2005
    Posts
    42

    Re: skeleton glut app has low frame rate (code)

    Thanks Hlz, I'll get the WGL extension. That will be fine for what I'm doing for awhile.

Similar Threads

  1. GLUT: Erratic frame rate despite limiting (Using Windows)
    By officialhopsof in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-27-2013, 05:09 PM
  2. Frame Rate
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-19-2004, 07:00 PM
  3. frame rate
    By KeSh in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-17-2004, 02:27 AM
  4. setting max frame rate with glut?
    By Rad in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-07-2003, 02:06 PM
  5. frame rate
    By dpgraves in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-03-2001, 01:37 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