PocketMatrix forums

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

Adaptative framerate ?

Hi,

I'm trying to use a kind of adaptative framerate with gapidraw, but without success.

I use a GapiDrawApplication, and here is the code I put in the ProcessNextFrame method :

Code:

if ((dwFlags & GDAPP_FRAMETIMEOVERFLOW) == GDAPP_FRAMETIMEOVERFLOW)
{
if (TargetFPS > 5)
{
TargetFPS -= 5;
this->m_config.dwTargetFPS = TargetFPS;
}
}else{
TargetFPS = FPS;
this->m_config.dwTargetFPS = TargetFPS;
}


Any idea ???

Thanks


julien
Hi,

Try this one:

Code:
if ((dwFlags & GDAPP_FRAMETIMEOVERFLOW) == GDAPP_FRAMETIMEOVERFLOW)
{
    if (TargetFPS > 5)
    {
        TargetFPS -= 5;
        m_timer.StartTimer(TargetFPS);
    }
}
else
{
    TargetFPS = FPS;
}


From the documentation on CGapiTimer: "It is safe to call StartTimer multiple times for the same objects, in case the frame rate need to be adjusted during game play."
Thanks a lot, it seems to be working :D
Just a little correction on the code above :

Code:

if ((dwFlags & GDAPP_FRAMETIMEOVERFLOW) == GDAPP_FRAMETIMEOVERFLOW)
{
if (TargetFPS > 5)
{
TargetFPS -= 5;
m_timer.StartTimer(TargetFPS);
}
}
else
{
TargetFPS = FPS;
m_timer.StartTimer(TargetFPS);
}