TimeSinceLastFrame when not using framelisteners...possible?

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

TimeSinceLastFrame when not using framelisteners...possible?

Post by LordMyth »

Is it possible to get the time since the last frame if you don't use framelisteners?
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
johnhpus
Platinum Sponsor
Platinum Sponsor
Posts: 1186
Joined: Sat Apr 17, 2004 2:49 am
x 3

Post 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
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post 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();
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post 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)
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post 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 :)
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post by LordMyth »

But ehh, how can OGRE calculate average frames per second and all of those things huh?
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
Emmeran
Goblin
Posts: 272
Joined: Wed Jun 02, 2004 11:47 am
Location: Erlangen
Contact:

Post 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();
}
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post by LordMyth »

Ah! Didn't know that there where timer objects like that! I'll try it now.
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post 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;
}
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
bal
Greenskin
Posts: 100
Joined: Thu Dec 09, 2004 7:29 pm
Location: Geluwe, Belgium

Post by bal »

But then you can't do any other calculations with the same timer, LordMyth.
User avatar
Emmeran
Goblin
Posts: 272
Joined: Wed Jun 02, 2004 11:47 am
Location: Erlangen
Contact:

Post by Emmeran »

exactly.
User avatar
LordMyth
Gremlin
Posts: 181
Joined: Thu Jan 06, 2005 10:19 pm
Location: Belgium
Contact:

Post by LordMyth »

Ah well, Nothing ever happens outside the While loop, so that won't be a problem.
Have a kiss from me!
Gentoo Linux on AMD64 3200+
NForce4 Chipset
Dual Channel DDR 2x512MB
PCX 16 GeForce 6600 256MB
User avatar
Emmeran
Goblin
Posts: 272
Joined: Wed Jun 02, 2004 11:47 am
Location: Erlangen
Contact:

Post 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.
Post Reply