PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

how do i get the frames per second?

I have done game programming in the past, but on pocket frog, i'm a bit stuck on how to get the number of frames per second in integer form (e.g.: "int fps"). I've checked out the "blit" sample but i'm still a little confused. Anybody care to enlighten me?
anybody????
If no one else posts, I'll post something for you later tonight.
You can simply calculate the number of frames you render in a second and update your "fps" counter every second.

For example, at initialization you do:

Code:

m_timeStart = PHAL::GetClock();
m_nbFrame = 0;


Then in the main loop:

Code:


// Render one frame
m_nbFrame += 1;

// Calculate FPS
uint32_t timeNow = PHAL::GetClock();
if (timeNow - m_timeStart >= 1000)
{
float time = (float)(timeNow - m_timeStart) / 1000.0f;
float fps = (float)m_nbFrame / time;

// Display FPS
// ..

// Reset vars
m_timeStart = timeNow;
m_nbFrame = 0;
}


The fps will be calculated each second.
thanks Thierry, it worked!