• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KGLLib

KGLLib::FPSCounter

KGLLib::FPSCounter Class Reference

#include <fpscounter.h>

List of all members.


Detailed Description

Utility class that measures FPS.

FPSCounter is a utility class that keeps track of FPS (frames per second) of your application. It can be a simple performance measurement tool.

Using FPSCounter is simple: if you're using GLWidget then all you have to do is calling fps() or fpsString() method to find out the current FPS. You can also call timeElapsed() to find out how much time has elapsed since last frame was rendered. This could be useful e.g. in animations where an object has a fixed speed and you multiply it by the elapsed time every frame to find out how much the object should be moved.

If you don't use GLWidget then you need to call nextFrame() every time that another frame is rendered.

The fps value is recalculated once a second.

You can also use totalTimeElapsed() to find out how much time has elapsed since nextFrame() was called the very first time.

See also:
GLWidget

Definition at line 54 of file fpscounter.h.


Public Member Functions

float fps () const
 FPSCounter ()
QString fpsString () const
void nextFrame ()
void resetTimeElapsed ()
float timeElapsed ()
float totalTimeElapsed ()

Protected Attributes

float mFPS
int mFrames
QTime mLastTime
QTime mTime
float mTimeElapsed
float mTotalTimeElapsed

Constructor & Destructor Documentation

KGLLib::FPSCounter::FPSCounter (  ) 

Creates new FPS counter.

The counter isn't started until nextFrame() is called for the first time.

Definition at line 23 of file fpscounter.cpp.


Member Function Documentation

float KGLLib::FPSCounter::fps (  )  const [inline]

Returns the current FPS value.

Note that the value is recalculated by nextFrame() about once a second.

See also:
fpsString(), timeElapsed(), nextFrame()

Definition at line 80 of file fpscounter.h.

QString KGLLib::FPSCounter::fpsString (  )  const

Returns the current FPS value as string.

Number of significant digits in the string is kept at 3, so possible return values include "123", "42.7" and "3.84".

See also:
fps()

Definition at line 52 of file fpscounter.cpp.

void KGLLib::FPSCounter::nextFrame (  ) 

This method should be called whenever a frame is rendered.

It increases the internal counters and updates the calculated FPS value once a second.

See also:
fps(), timeElapsed()

Definition at line 38 of file fpscounter.cpp.

void KGLLib::FPSCounter::resetTimeElapsed (  ) 

Definition at line 31 of file fpscounter.cpp.

float KGLLib::FPSCounter::timeElapsed (  )  [inline]

Returnes time elapsed between last two calls to nextFrame() method.

Usually that gives you the time elapsed since last frame and could be used e.g. for animation purposes.

The return value is in seconds, thus a value of 0.075 would indicate that 75 milliseconds have elapsed.

See also:
fps()

Definition at line 101 of file fpscounter.h.

float KGLLib::FPSCounter::totalTimeElapsed (  )  [inline]

Returns amount of time that has elapsed since the first call to nextFrame().

See also:
timeElapsed(), nextFrame()

Definition at line 108 of file fpscounter.h.


Member Data Documentation

float KGLLib::FPSCounter::mFPS [protected]

Definition at line 113 of file fpscounter.h.

int KGLLib::FPSCounter::mFrames [protected]

Definition at line 112 of file fpscounter.h.

QTime KGLLib::FPSCounter::mLastTime [protected]

Definition at line 117 of file fpscounter.h.

QTime KGLLib::FPSCounter::mTime [protected]

Definition at line 111 of file fpscounter.h.

float KGLLib::FPSCounter::mTimeElapsed [protected]

Definition at line 115 of file fpscounter.h.

float KGLLib::FPSCounter::mTotalTimeElapsed [protected]

Definition at line 116 of file fpscounter.h.


The documentation for this class was generated from the following files:
  • fpscounter.h
  • fpscounter.cpp

KGLLib

Skip menu "KGLLib"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KGLLib
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal