renderOneFrame( deltaTime ) what?

Get answers to all your basic programming questions. No Ogre questions, please!
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56

renderOneFrame( deltaTime ) what?

Post by Klaim »

(Ogre 1.8.x, recent revision)
This might be a dumb question, but I can't figure out the point of the renderOneFrame() function which take the time since last frame:

Code: Select all

/** Render one frame, with custom frame time information. 
		@remarks
		Updates all the render targets automatically and then returns,
		raising frame events before and after - all per-frame times are based on
		the time value you pass in.
		*/
		bool renderOneFrame(Real timeSinceLastFrame);
This suggests that it is useful only if you use frame events? The use cases are not clear to me.

Code: Select all

bool Root::renderOneFrame(Real timeSinceLastFrame)
	{
		FrameEvent evt;
		evt.timeSinceLastFrame = timeSinceLastFrame;

		unsigned long now = mTimer->getMilliseconds();
		evt.timeSinceLastEvent = calculateEventTime(now, FETT_ANY); // what?

		if(!_fireFrameStarted(evt))
			return false;

		if (!_updateAllRenderTargets(evt))
			return false;

		now = mTimer->getMilliseconds();
		evt.timeSinceLastEvent = calculateEventTime(now, FETT_ANY);

		return _fireFrameEnded(evt);
	}
Doesn't the commented line kill the point of the function?
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: renderOneFrame( deltaTime ) what?

Post by bstone »

I don't know the details but I'd think "timeSinceLastFrame" and "timeSinceLastEvent" are two different things, no?
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56

Re: renderOneFrame( deltaTime ) what?

Post by Klaim »

bstone wrote:I don't know the details but I'd think "timeSinceLastFrame" and "timeSinceLastEvent" are two different things, no?
Ah yes, sorry I misread, it solves the second question.

I still don't know in which case this function is used though.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 535

Re: renderOneFrame( deltaTime ) what?

Post by Kojack »

This is used internally for things like particle systems. Unlike animations where you have to manually add time to make them animate, particle systems run on their own. If you want your game world to change speed (slow down, speed up or pause) you pass in different delta times to renderOneFrame and it uses those instead of it's own calculated time. Anything else that uses frame listeners but you want to speed up or slow down (hydrax wave animation, possibly ribbon trail fading, etc) can be affected by it too.
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56

Re: renderOneFrame( deltaTime ) what?

Post by Klaim »

Kojack wrote:This is used internally for things like particle systems. Unlike animations where you have to manually add time to make them animate, particle systems run on their own. If you want your game world to change speed (slow down, speed up or pause) you pass in different delta times to renderOneFrame and it uses those instead of it's own calculated time. Anything else that uses frame listeners but you want to speed up or slow down (hydrax wave animation, possibly ribbon trail fading, etc) can be affected by it too.
Ok, thank you very much because this seems damn important for my context! I didn't know the particle system was dependant on that. That would explain a lot.
This function comments should be enhanced. I'll make a little patch.