Game Development Community

Framerate limiter

by Ian Omroth Hardingham · in Technical Issues · 09/02/2010 (3:24 pm) · 3 replies

Hey guys.

I would love to limit Torque (TGB 1.1.3 in this case) to 80fps or so... anyone know if this has been done or is especially easy?

Ian

#1
09/02/2010 (7:43 pm)
Couldn't you insert some piece of sleep code in your main rendering loop that puts it to sleep whenever the number of frames to draw during this specific time slice has been reached?
#2
09/04/2010 (5:24 pm)
I made a test with TGE (main.cc)

while(Game->isRunning())
   {
	   // add this line
	   U32 loopStartTime = GetTickCount(); 
	   
            PROFILE_START(MainLoop);
            PROFILE_START(JournalMain);
      Game->journalProcess();
            PROFILE_END();
            PROFILE_START(NetProcessMain);
      Net::process();      // read in all events
            PROFILE_END();
            PROFILE_START(PlatformProcessMain);
      Platform::process(); // keys, etc.
            PROFILE_END();
            PROFILE_START(TelconsoleProcessMain);
      TelConsole->process();
            PROFILE_END();
            PROFILE_START(TelDebuggerProcessMain);
      TelDebugger->process();
            PROFILE_END();
            PROFILE_START(TimeManagerProcessMain);
      TimeManager::process(); // guaranteed to produce an event
            PROFILE_END();
            PROFILE_START(GameProcessEvents);
      Game->processEvents(); // process all non-sim posted events.
            PROFILE_END();
            PROFILE_END();

	// ... and add this line
	while ( (GetTickCount() - loopStartTime) < 24);
	

	//Con::printf("I am the main loop");
   }

Replace "24" with any number.

48 = 16 FPS
24 = 32 FPS
12 = 64 FPS
#3
09/13/2010 (9:38 am)
Perfect, thankyou so much Thomas!