R – How to get games’ FPS (with OpenGL) to like 800 FPS

frame-rateopengl

How can we run a OpenGL applications (say a games) in higher frame rate like 500 – 800 FPS ?

For a example AOE 2 is running with more than 700 FPS (I know it is about DirectX). Eventhough I just clear buffers and swap buffers within the game loop, I can only get about 200 (max) FPS. I know that FPS isn't a good messurenment (and also depend on the hardware), but I feel I missed some concepts in OpenGL. Did I ? Pls anyone can give me a hint ?

Best Answer

I'm getting roughly 5.600 FPS with an empty display loop (GeForce 260 GTX, 1920x1080). Adding glClear lowers it to 4.000 FPS which is still way over 200... A simple graphics engine (AoE2 style) should run at about 100-200 FPS (GeForce 8 or similar). Probably more if it's multi-threaded and fully optimized.

I don't know what exactly you do in your loop or what hardware that is running on, but 200 FPS sounds like you are doing something else besides drawing nothing (sleep? game logic stuff? greedy framework? Aero?). The swapbuffer function should not take 5ms even if both framebuffers have to be copied. You can use a profile to check where the most CPU time is spent (timing results from gl* functions are mostly useless though)

If you are doing something with OpenGL (drawing stuff, creating textures, etc.) there is a nice extension to measure times called GL_EXT_timer_query.

Some general optimization tips:

  • don't use immediate mode (glBegin/glEnd), use VBO and/or display lists+vertex arrays instead
  • use some culling technique to remove objects outside your view (opengl would have to cull every polygon separately)
  • try minimizing state changes, especially changing the bound texture or vertex buffer
Related Topic