hi
i'm here again with a new problem !!
i'm sure that you know all games FPS(frame per second) must be limited for executing games in every graphical card with a constant speed . how can i do it in irrlicht ?? i found getFPS() function but isn't there any other function for limiting the FPS .
Help me please . thanks
Limiting The FPS
-
Unforgivable.Course
- Posts: 46
- Joined: Tue Feb 07, 2006 6:28 pm
Limiting The FPS
Get Ready For an Amazing Journey Into the World of Game Development
this isn't a new, or an advanced help question.
you can use Sleep() from windows.h if you want to limit the fps, but what happens if your pc can't manage 60fps? you want your simulation to be the same no matter how many frames per-sec you're getting-
http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=68133
i'm moving this multi-dupe newbie question to beginners help
you can use Sleep() from windows.h if you want to limit the fps, but what happens if your pc can't manage 60fps? you want your simulation to be the same no matter how many frames per-sec you're getting-
http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=68133
i'm moving this multi-dupe newbie question to beginners help
recording to me the simplest way for having the same framerate on all pc is
to sleep (period_ms - elapsed_ms), and period_ms is your fixed time for each loop.
There is a good example in this post:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=42343
I put the code here because it's very clean.
to sleep (period_ms - elapsed_ms), and period_ms is your fixed time for each loop.
There is a good example in this post:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?p=42343
I put the code here because it's very clean.
Code: Select all
void run()
{
u32 start, end, elapsed, frame = 10; // 10 millisec per frame = 100 hz
while(videoDevice->run())
{
start = videoDevice->getTimer()->getTime();
videoDriver->beginScene(true, true, video::SColor(0,87,133,157));
sceneManager->drawAll();
gameController->onRenderFrame();
videoDriver->endScene();
end = videoDevice->getTimer()->getTime();
elapsed = end-start;
if(elapsed < frame)
{
#ifdef LINUX
usleep(1000* (frame - elapsed));
#endif
#ifdef WINDOWS
Sleep(frame - elapsed);
#endif
}
}
videoDevice->drop();
}
-
Unforgivable.Course
- Posts: 46
- Joined: Tue Feb 07, 2006 6:28 pm
Has anyone had any difficulty with the above posted method? I need to limit my framerate to 60Hz. But in the code timer->getTime() only seems to increment by 2ms. So I can only get my frame rate to 55Hz or 62Hz. Any suggestions? Is there a higher fidelity timer? (I'm on a 2.4GHz machine, so it's not a slow clock problem)
Well, once again, take a look at
Main Loop with Fixed Time Steps, by Javier Arevalo:
http://www.iguanademos.com/Jare/Article ... ew=FixLoop
Main Loop with Fixed Time Steps, by Javier Arevalo:
http://www.iguanademos.com/Jare/Article ... ew=FixLoop