MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Com_Frame

Function Com_Frame

code/qcommon/common.cpp:1352–1553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1350#endif
1351
1352void Com_Frame( void ) {
1353 try
1354 {
1355 int timeBeforeFirstEvents = 0, timeBeforeServer = 0, timeBeforeEvents = 0, timeBeforeClient = 0, timeAfter = 0;
1356 int msec, minMsec;
1357 int timeVal;
1358 static int lastTime = 0, bias = 0;
1359
1360 // write config file if anything changed
1361 Com_WriteConfiguration();
1362
1363 //
1364 // main event loop
1365 //
1366 if ( com_speeds->integer ) {
1367 timeBeforeFirstEvents = Sys_Milliseconds ();
1368 }
1369
1370 // Figure out how much time we have
1371 if(com_minimized->integer && com_maxfpsMinimized->integer > 0)
1372 minMsec = 1000 / com_maxfpsMinimized->integer;
1373 else if(com_unfocused->integer && com_maxfpsUnfocused->integer > 0)
1374 minMsec = 1000 / com_maxfpsUnfocused->integer;
1375 else if(com_maxfps->integer > 0)
1376 minMsec = 1000 / com_maxfps->integer;
1377 else
1378 minMsec = 1;
1379
1380 timeVal = com_frameTime - lastTime;
1381 bias += timeVal - minMsec;
1382
1383 if (bias > minMsec)
1384 bias = minMsec;
1385
1386 // Adjust minMsec if previous frame took too long to render so
1387 // that framerate is stable at the requested value.
1388 minMsec -= bias;
1389
1390 timeVal = Com_TimeVal(minMsec);
1391 do {
1392 // Busy sleep the last millisecond for better timeout precision
1393 if(com_busyWait->integer || timeVal < 1)
1394 Sys_Sleep(0);
1395 else
1396 Sys_Sleep(timeVal - 1);
1397 } while( (timeVal = Com_TimeVal(minMsec)) != 0 );
1398 IN_Frame();
1399
1400 lastTime = com_frameTime;
1401 com_frameTime = Com_EventLoop();
1402
1403 msec = com_frameTime - lastTime;
1404
1405 Cbuf_Execute ();
1406
1407 // mess with msec if needed
1408 float fractionMsec=0.0f;
1409 msec = Com_ModifyMsec( msec, fractionMsec);

Callers 1

mainFunction · 0.50

Calls 15

Com_WriteConfigurationFunction · 0.70
Com_TimeValFunction · 0.70
Com_EventLoopFunction · 0.70
Cbuf_ExecuteFunction · 0.70
Com_ModifyMsecFunction · 0.70
Com_PrintfFunction · 0.70
FS_FOpenFileWriteFunction · 0.70
FS_WriteFunction · 0.70
FS_ForceFlushFunction · 0.70
Com_sprintfFunction · 0.70
Com_CatchErrorFunction · 0.70
Com_ErrorStringFunction · 0.70

Tested by

no test coverage detected