Sunday, April 24, 2016

Frame.Rate

[]

  1. FPS: Frame Per Second
  2. F: Frame


[]

  1. What is Frame?  (in OpenGL)
  2. Does A Frame Mean One Time of Drawing Scene in OpenGL ?


[]
Some Insightful Points

URL: https://www.techopedia.com/definition/7297/frames-per-second-fps

Definition - What does Frames Per Second (FPS) mean?
Frames per second (FPS) is a unit that measures display device performance. It consists of the number of complete scans of the display screen that occur each second. This is the number of times the image on the screen is refreshed each second, or the rate at which an imaging device produces unique sequential images called frames.
Techopedia explains Frames Per Second (FPS)Each frame consists of a number of horizontal scan lines. These represent the number of scan lines per frame.
Currently, there are three main FPS standards (plus a few others) used in TV and movie making: 24p, 25p and 30p (The "p" stands for frame progressive).
  • 30p imitates a film camera's frame rate.
  • 24p is widely used when transferring a video signal to film.
  • 25p is used for direct compatibility with television. It also works better for progressive scan output to LCD displays and computer monitors and projectors.
  • High-end high definition TV (HDTV) uses 50p and 60p progressive formats.
  • 72p is an experimental format.
The greater the FPS, the smoother the video motion appears. Full-motion video is usually 30 FPS or greater. Different formats of video files have different FPS rates. Slower FPS rates produce smaller computer files.
Some of the first 3D video games used a frame rate of only 6 FPS. In today’s action-oriented games, the frame rate may range from 30 FPS (for example, in "Halo 3") to over 100 FPS (as in"Unreal Tournament 3"). Computer game enthusiasts may use the FPS ratings of a game to demonstrate computer power and efficiency.


[]
_________________________________________
____
____

URL: http://www.lighthouse3d.com/tutorials/glut-tutorial/frames-per-second/
The frame rate varies from frame to frame, i.e. not all frames take the same time to render because our application is not alone. The operating system takes its toll, and the camera maybe moving thereby changing what’s being rendered. Therefore we’re going to avoid computing the frame rate in each and every frame, and instead we’re going to compute it roughly once per second. This also provides a more accurate figure, since its an average.
We’re going to declare three variables: frametime, and timebase, where timebase and frame are both initialized to zero.

We’re going to declare three variables: frametime, and timebase, where timebase and frame are both initialized to zero.
int frame=0,time,timebase=0;
The meaning of these variables is:
  • frame – the number of frames since we last computed the frame rate
  • time – the current number of milliseconds
  • timebase – the time when we last computed the frame rate
The following piece of code, when placed inside the registered idle function, will do the job (see bellow for a detailed description):
 ...

 frame++;
 time=glutGet(GLUT_ELAPSED_TIME);

 if (time - timebase > 1000) {
  fps = frame*1000.0/(time-timebase));
   timebase = time;
  frame = 0;
 }
 ...
We start by increasing the number of frames, i.e. increasing the variable frame. We then get the current time into time. Next we compare it with timebase to check if a second has elapsed, i.e. if the difference between time and timebase is greater than 1000 millisecond. If this is not the case then we skip the computation part. However when the difference is larger than one second we’ll do the computation.

Computing the difference between time and timebase gives us the number of milliseconds elapsed since we last computed the number of frames per second. Dividing 1000 by the number of milliseconds elapsed provides the inverse of the number of seconds elapsed. All its left is to multiply this value by the number of frames rendered since the last time the frame rate was computed, and we get the number of frames per second. Finally we reset timebase to the current number of milliseconds, and frame to zero.

Note that when the application starts timebase is zero, you’ll have to wait one second to get the first value. This first few values however are very misleading because they include the time required to initialize the window. If you run some tests you’ll see that this value is much lower than the actual frame rate.

If you want to print the number of frames per second you can use the following piece of code
 ...
 frame++;
 time=glutGet(GLUT_ELAPSED_TIME);
 if (time - timebase > 1000) {
  sprintf(s,"FPS:%4.2f",
   frame*1000.0/(time-timebase));
  timebase = time;
  frame = 0;
 }

 glColor3f(0.0f,1.0f,1.0f);

 glPushMatrix();
 glLoadIdentity();
 setOrthographicProjection();
 renderBitmapString(30,35,(void *)font,s);
 glPopMatrix();
 restorePerspectiveProjection();

 ...



No comments:

Post a Comment