user279505
user279505

Reputation: 129

How to calculate Frames per second in Qt Graphics Application

I have an Qt based OpenGLES2.0 application, where I want to capture the FPS.

my application draw same geometry for 16 times and then try to know the FPS.

How can I make sure glDrawElements() has finished its job ?

I want to get the correct FPS.

Is there any way to make the glDrawElements()synchronous or Pooling the glDrawElements() complete?

Upvotes: 2

Views: 4935

Answers (1)

user279505
user279505

Reputation: 129

  1. define a Timer object in application window/widget class. QTime frameTime;
  2. Start the timer in initializeGL. frameTime.start();

  3. in PaintGL


paintGL ()
{  
   draw_your_geometry();

   ++frameCount;

  if (frameTime.elapsed() >= 1000)
  {

     double fps = frameCount / ((double)frameTime.elapsed()/1000.0);

  }

}

Upvotes: 4

Related Questions