Page 1 of 1

Delta time

Posted: Sat Sep 19, 2009 3:16 pm
by omar shaaban
it seems peaple are still asking about delta time (which makes vitek write the code to them....about 25% of vitek posts is wrting this code lol...just kidding :lol: )
here it is the code we all know:

Code: Select all

	while(device->run())
	{
 u32 now = timer->getTime();
 f32 elapsedSeconds = (now - then) / 1000.f;
	if(elapsedSeconds>=deltatime)
{
     driver->beginScene(true, true, SColor(255,100,101,140));
	smgr->drawAll();
    guienv->drawAll();
then = now;
driver->endScene();
///////////////////////////////
     int fps = driver->getFPS();

     if (lastFPS != fps)
     {
        core::stringw str = L"Delta time - Irrlicht Engine [";		  str += driver->getName();
		  str += "] FPS:";
		  str += fps;

		  device->setWindowCaption(str.c_str());
		  lastFPS = fps;}

//////////////////////////////
}}

Posted: Thu Jan 14, 2010 12:30 pm
by humbrol
may be a dumb question but where is deltatime declared and what is it set to?

Posted: Sat Jan 30, 2010 9:24 pm
by Boogy

Code: Select all

u32 then = device->getTimer()->getTime();

while(device->run())
 {
   // Work out a frame delta time.
   const u32 now = device->getTimer()->getTime();
   const f32 frameDeltaTime = (f32)(now - then) / 1000.f; // Time in seconds
   then = now;

}
I've got this code from here: Tutorial!