MCPcopy Create free account
hub / github.com/axmolengine/axmol / showStats

Method showStats

core/base/Director.cpp:1269–1319  ·  view source on GitHub ↗

display the FPS using a LabelAtlas updates the FPS every frame

Source from the content-addressed store, hash-verified

1267// display the FPS using a LabelAtlas
1268// updates the FPS every frame
1269void Director::showStats()
1270{
1271 if (_isStatusLabelUpdated)
1272 {
1273 createStatsLabel();
1274 _isStatusLabelUpdated = false;
1275 }
1276
1277 static uint32_t prevCalls = 0;
1278 static uint32_t prevVerts = 0;
1279
1280 ++_frames;
1281 _accumDt += _deltaTime;
1282
1283 if (_statsDisplay && _FPSLabel && _drawnBatchesLabel && _drawnVerticesLabel)
1284 {
1285 char buffer[30];
1286
1287 // Probably we don't need this anymore since
1288 // the framerate is using a low-pass filter
1289 // to make the FPS stable
1290 if (_accumDt > AX_DIRECTOR_STATS_INTERVAL)
1291 {
1292 auto msg = fmt::format_to_z(buffer, "{:.1f} / {:.3f}", _frames / _accumDt, _secondsPerFrame);
1293 _FPSLabel->setString(msg);
1294 _accumDt = 0;
1295 _frames = 0;
1296 }
1297
1298 auto currentCalls = (uint32_t)_renderer->getDrawnBatches();
1299 auto currentVerts = (uint32_t)_renderer->getDrawnVertices();
1300 if (currentCalls != prevCalls)
1301 {
1302 auto msg = fmt::format_to_z(buffer, "GL calls:{:6d}", currentCalls);
1303 _drawnBatchesLabel->setString(msg);
1304 prevCalls = currentCalls;
1305 }
1306
1307 if (currentVerts != prevVerts)
1308 {
1309 auto msg = fmt::format_to_z(buffer, "GL verts:{:6d}", currentVerts);
1310 _drawnVerticesLabel->setString(msg);
1311 prevVerts = currentVerts;
1312 }
1313
1314 const Mat4& identity = Mat4::IDENTITY;
1315 _drawnVerticesLabel->visit(_renderer, identity, 0);
1316 _drawnBatchesLabel->visit(_renderer, identity, 0);
1317 _FPSLabel->visit(_renderer, identity, 0);
1318 }
1319}
1320
1321void Director::calculateMPF()
1322{

Callers

nothing calls this directly

Calls 3

format_to_zFunction · 0.85
setStringMethod · 0.45
visitMethod · 0.45

Tested by

no test coverage detected