MCPcopy Create free account
hub / github.com/ddnet/ddnet / RenderDebug

Method RenderDebug

src/engine/client/client.cpp:916–1041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

914}
915
916void CClient::RenderDebug()
917{
918 if(!g_Config.m_Debug)
919 {
920 return;
921 }
922
923 const std::chrono::nanoseconds Now = time_get_nanoseconds();
924 if(Now - m_NetstatsLastUpdate > 1s)
925 {
926 m_NetstatsLastUpdate = Now;
927 m_NetstatsPrev = m_NetstatsCurrent;
928 net_stats(&m_NetstatsCurrent);
929 }
930
931 char aBuffer[512];
932 const float FontSize = 16.0f;
933
934 Graphics()->TextureSet(m_DebugFont);
935 Graphics()->MapScreen(0, 0, Graphics()->ScreenWidth(), Graphics()->ScreenHeight());
936 Graphics()->QuadsBegin();
937
938 str_format(aBuffer, sizeof(aBuffer), "Game/predicted tick: %d/%d", m_aCurGameTick[g_Config.m_ClDummy], m_aPredTick[g_Config.m_ClDummy]);
939 Graphics()->QuadsText(2, 2, FontSize, aBuffer);
940
941 str_format(aBuffer, sizeof(aBuffer), "Prediction time: %d ms", GetPredictionTime());
942 Graphics()->QuadsText(2, 2 + FontSize, FontSize, aBuffer);
943
944 str_format(aBuffer, sizeof(aBuffer), "FPS: %3d", round_to_int(1.0f / m_FrameTimeAverage));
945 Graphics()->QuadsText(20.0f * FontSize, 2, FontSize, aBuffer);
946
947 str_format(aBuffer, sizeof(aBuffer), "Frametime: %4d us", round_to_int(m_FrameTimeAverage * 1000000.0f));
948 Graphics()->QuadsText(20.0f * FontSize, 2 + FontSize, FontSize, aBuffer);
949
950 str_format(aBuffer, sizeof(aBuffer), "%16s: %" PRIu64 " KiB", "Texture memory", Graphics()->TextureMemoryUsage() / 1024);
951 Graphics()->QuadsText(32.0f * FontSize, 2, FontSize, aBuffer);
952
953 str_format(aBuffer, sizeof(aBuffer), "%16s: %" PRIu64 " KiB", "Buffer memory", Graphics()->BufferMemoryUsage() / 1024);
954 Graphics()->QuadsText(32.0f * FontSize, 2 + FontSize, FontSize, aBuffer);
955
956 str_format(aBuffer, sizeof(aBuffer), "%16s: %" PRIu64 " KiB", "Streamed memory", Graphics()->StreamedMemoryUsage() / 1024);
957 Graphics()->QuadsText(32.0f * FontSize, 2 + 2 * FontSize, FontSize, aBuffer);
958
959 str_format(aBuffer, sizeof(aBuffer), "%16s: %" PRIu64 " KiB", "Staging memory", Graphics()->StagingMemoryUsage() / 1024);
960 Graphics()->QuadsText(32.0f * FontSize, 2 + 3 * FontSize, FontSize, aBuffer);
961
962 // Network
963 {
964 const uint64_t OverheadSize = 14 + 20 + 8; // ETH + IP + UDP
965 const uint64_t SendPackets = m_NetstatsCurrent.sent_packets - m_NetstatsPrev.sent_packets;
966 const uint64_t SendBytes = m_NetstatsCurrent.sent_bytes - m_NetstatsPrev.sent_bytes;
967 const uint64_t SendTotal = SendBytes + SendPackets * OverheadSize;
968 const uint64_t RecvPackets = m_NetstatsCurrent.recv_packets - m_NetstatsPrev.recv_packets;
969 const uint64_t RecvBytes = m_NetstatsCurrent.recv_bytes - m_NetstatsPrev.recv_bytes;
970 const uint64_t RecvTotal = RecvBytes + RecvPackets * OverheadSize;
971
972 str_format(aBuffer, sizeof(aBuffer), "Send: %3" PRIu64 " %5" PRIu64 "+%4" PRIu64 "=%5" PRIu64 " (%3" PRIu64 " Kibit/s) average: %5" PRIu64,
973 SendPackets, SendBytes, SendPackets * OverheadSize, SendTotal, (SendTotal * 8) / 1024, SendPackets == 0 ? 0 : SendBytes / SendPackets);

Callers

nothing calls this directly

Calls 15

time_get_nanosecondsFunction · 0.85
net_statsFunction · 0.85
GraphicsFunction · 0.85
str_formatFunction · 0.85
round_to_intFunction · 0.85
TextureSetMethod · 0.80
ScreenWidthMethod · 0.80
ScreenHeightMethod · 0.80
QuadsBeginMethod · 0.80
QuadsTextMethod · 0.80
GetDataRateMethod · 0.80
GetItemNameMethod · 0.80

Tested by

no test coverage detected