Page 1 of 1
TimeSinceLastFrame when not using framelisteners...possible?
Posted: Sat Feb 12, 2005 6:18 pm
by LordMyth
Is it possible to get the time since the last frame if you don't use framelisteners?
Posted: Sat Feb 12, 2005 6:57 pm
by johnhpus
I'm not sure but it seems possible. In a quick look this was the closest I could find " RenderWindow::getStatistics() " which returns a struct FrameStatistics. No exact time since last frame though.
I question why you would want to not use a frame listener.
Also, it occurs to me that if your not using a frame listener that your manually telling Ogre to render. If that's so just store get the time from the system yourself and it should very easy to figure out the time since last frame.
good luck
John
Posted: Sat Feb 12, 2005 7:06 pm
by LordMyth
Yeah, but getting the time from the system is a bit eh.. system specific... I knew how to do it in SDL, But I don't want to compile Ogre in SDL you know... I'll look at your getStatistics();
Posted: Sat Feb 12, 2005 7:10 pm
by LordMyth
It is not for what I want, it returns the average, best, worst, and another thing framerates. Bu if OGRE calculates all these, it must have a Time since last frame variable eh? Because the way I make my app makes it hard to use frame listeners (segmentation faults etc...) and also, like Robomaniac says: more control (at least the feeling of it)
Posted: Sat Feb 12, 2005 7:47 pm
by sinbad
If you're running the rendering loop then Ogre doesn't calculate this stuff for you, you have to do it yourself. With great power, comes great responsibility

Posted: Sat Feb 12, 2005 8:21 pm
by LordMyth
But ehh, how can OGRE calculate average frames per second and all of those things huh?
Posted: Sat Feb 12, 2005 8:27 pm
by Emmeran
Just take a timer and try something like this:
Code: Select all
Timer* mTimer = PlatformManager::getSingleton().createTimer();
long mLastFrame = 0;
float deltaT = 0.0f;
bool mStop;
(...)
mTimer->reset();
while(!mStop)
{
mSceneMgr->renderOneFrame();
// let's call the time since last frame in seconds deltaT:
deltaT = (mTimer->getMilliseconds() - mLastFrame) / 1000.0f;
(...)
mLastFrame = mTimer->getMilliseconds();
}
Posted: Sat Feb 12, 2005 8:55 pm
by LordMyth
Ah! Didn't know that there where timer objects like that! I'll try it now.
Posted: Sat Feb 12, 2005 9:29 pm
by LordMyth
Thanks it worked but I did it like this (I think it's better then what you did):
Code: Select all
while (1) {
Timer->reset();
//Do something
TimeSinceLastFrame = Timer->getMilliseconds()/1000;
}
Posted: Sat Feb 12, 2005 9:30 pm
by bal
But then you can't do any other calculations with the same timer, LordMyth.
Posted: Sat Feb 12, 2005 9:37 pm
by Emmeran
exactly.
Posted: Sat Feb 12, 2005 9:38 pm
by LordMyth
Ah well, Nothing ever happens outside the While loop, so that won't be a problem.
Posted: Sat Feb 12, 2005 10:22 pm
by Emmeran
But maybe somewhen u want to know the time the program is up. And then u need to change ur code or to add another timer. and changing code is better I think.