FPS/Ping & More FOV Codes
#13


15 minutes ago, Desarija said:




you have added it in the wrong place, search for this line: 


pDrawPort->PutTextExCX( strServerInfo, m_nPosX +this->GetWidth()/2 + 50, m_nLocalTimeY + 17, 0xFFA600FF );


which already exists in uiradar.cpp

then add this below:


// timer variables
#define FRAMES_AVERAGING_MAX 20L
static CTimerValue _tvLasts[FRAMES_AVERAGING_MAX];
static CTimerValue _tvDelta[FRAMES_AVERAGING_MAX];
static INDEX _iCheckNow = 0;
static INDEX _iCheckMax = 0;
#define FPS_LAST_CACHED 120
static INDEX _aiFPS[FPS_LAST_CACHED];
static INDEX _iStartingFPSIndex = 0;
static INDEX _iLastFPSOut = 0;
static INDEX hud_bShowClock = FALSE;
static INDEX hud_bShowNetGraph = FALSE;
static INDEX hud_bShowResolution = FALSE;
static INDEX hud_bShowPauseText = TRUE;
static INDEX dem_bOSD = FALSE;
static INDEX dem_bPlay = FALSE;
static INDEX dem_bPlayByName = FALSE;
static INDEX dem_bProfile = FALSE;
static INDEX dem_iProfileRate = 5;
static FLOAT dem_fMotionBlurStrength = 0.5f; // 0.1=min, 1=max
static CTString dem_strPostExec = "";
INDEX hud_iStats = 3;
static INDEX hud_iFPSGraphSpeed = 4;
static INDEX hud_iFPSGraphMax = 400;
static INDEX hud_bShowTime = FALSE;
// if required, print real time
if (hud_bShowClock) {
// set font, spacing and scale
// determine time
struct tm *newtime;
time_t long_time;
time(&long_time);
newtime = localtime(&long_time);
// printout
CTString strTime;
}
// clamp stat values
extern ENGINE_API INDEX _iStatsMode;
hud_iStats = Clamp(hud_iStats, 0L, 4L);
_iStatsMode = hud_iStats; // send it to engine
hud_iFPSGraphSpeed = Clamp(hud_iFPSGraphSpeed, 0L, 50L);
hud_iFPSGraphMax = Clamp(hud_iFPSGraphMax, 50L, 500L);
// calculate FPS
FLOAT fFPS = 0.0f;
_iCheckMax++;
if (_iCheckMax >= FRAMES_AVERAGING_MAX) {
for (INDEX i = 0; i<FRAMES_AVERAGING_MAX; i++) fFPS += _tvDelta[i].GetSeconds();
fFPS = FRAMES_AVERAGING_MAX*FRAMES_AVERAGING_MAX / fFPS;
_iCheckMax = FRAMES_AVERAGING_MAX;
}

// determine newest time
CTimerValue tvNow = _pTimer->GetHighPrecisionTimer();
_tvDelta[_iCheckNow] = tvNow - _tvLasts[_iCheckNow];
_tvLasts[_iCheckNow] = tvNow;
_iCheckNow = (_iCheckNow + 1) % FRAMES_AVERAGING_MAX;

// fill FPS graph
INDEX iTimeNow = tvNow.GetSeconds() * 2 * hud_iFPSGraphSpeed;
if (iTimeNow != _iLastFPSOut && iTimeNow % 2) {
_iStartingFPSIndex = (_iStartingFPSIndex + 1) % FPS_LAST_CACHED;
_aiFPS[_iStartingFPSIndex] = fFPS;
_iLastFPSOut = iTimeNow;
}

// set display interface (proportional) font
CTString strDebug;
strDebug = "";
// display colored FPS
COLOR colFPS = C_RED;
if (fFPS >= 20) colFPS = C_GREEN;
if (fFPS >= 60) colFPS = C_WHITE;
//if (fFPS < 10) pdpDrawPort->SetTextScaling(fTextScale*1.5); // enlarge output if FPS is extremely low
// prepare FPS string for printing
CTString strFPS = "?";
CTString strRomain = "?";
if (fFPS >= 30) strFPS.PrintF("%s%3.0f", (const char*)strDebug, fFPS);
else if (fFPS >= 0.1f) strFPS.PrintF("%s%3.1f", (const char*)strDebug, fFPS);
// printout FPS number (if allowed)
//pdpDrawPort->PutTextC(strFPS, slDPWidth*0.75f, slDPHeight*0.005f, colFPS | 192);
strRomain.PrintF("Arcania - FPS");
pDrawPort->PutTextExCX(strRomain, m_nPosX + this->GetWidth() / 2 + 50, m_nLocalTimeY + 34, 0xFFFFFFFF);
pDrawPort->PutTextExCX(strFPS, m_nPosX + this->GetWidth() / 2 + 50, m_nLocalTimeY + 54, 0x4BE100FF);

extern ENGINE_API INDEX cli_iCurrentFPS;
cli_iCurrentFPS = fFPS;
// display extensive statistics
CTString strReport;
// printout statistics
strFPS.PrintF( " frame =%3.0f ms\n---------------\n", 1000.0f/fFPS);
//pDrawPort->PutTextExCX(strFPS, 0, 30, C_WHITE | CT_OPAQUE, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 48, 0x72D02EFF);
//pDrawPort->PutTextExCX(strReport, 4, 55, C_WHITE | CT_OPAQUE, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 55, 0x72D02EFF);
if (!hud_bShowNetGraph)
{ // draw canvas
const INDEX iWidth = FPS_LAST_CACHED;
const INDEX iHeight = 60;
// calculate FPS
FLOAT fFPS = 0.0f;
_iCheckMax++;
if (_iCheckMax >= FRAMES_AVERAGING_MAX)
{
for (INDEX i = 0; i<FRAMES_AVERAGING_MAX; i++) fFPS += _tvDelta[i].GetSeconds();
fFPS = FRAMES_AVERAGING_MAX*FRAMES_AVERAGING_MAX / fFPS;
_iCheckMax = FRAMES_AVERAGING_MAX;
}

// draw graph lines
for (INDEX i = 0; i<FPS_LAST_CACHED; i++)
{
const INDEX iValue = ClampUp(_aiFPS[(i + _iStartingFPSIndex + 1) % FPS_LAST_CACHED], hud_iFPSGraphMax);
COLOR iCol = C_RED;
if (iValue>100) iCol = C_lBLUE;
if (iValue> 60) iCol = C_WHITE;
if (iValue> 20) iCol = C_GREEN;
const INDEX iNormalizedValue = ((FLOAT)iValue) / hud_iFPSGraphMax * iHeight;
}
// print max normalization value
CTString strMaxFPS;
strMaxFPS.PrintF("%d", hud_iFPSGraphMax);
//Show Max FPS
//pDrawPort->PutTextExCX(strMaxFPS, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 40, 0x72D02EFF);
}


 




 

tyy worked Smile)



Messages In This Thread
[No subject] - by nicolasg - 03-24-2022, 01:04 AM
[No subject] - by Desarija - 03-24-2022, 01:56 PM
[No subject] - by nicolasg - 03-24-2022, 07:26 PM
[No subject] - by WhosUrDaddi - 03-24-2022, 08:29 PM
[No subject] - by nicolasg - 03-25-2022, 12:38 AM
[No subject] - by Desarija - 03-25-2022, 12:47 AM
[No subject] - by nicolasg - 03-25-2022, 01:06 AM
[No subject] - by Exodus - 03-25-2022, 11:01 AM
[No subject] - by nicolasg - 03-25-2022, 12:18 PM
[No subject] - by deudas - 01-28-2023, 10:22 PM
[No subject] - by nicolasg - 01-28-2023, 10:26 PM
[No subject] - by Desarija - 01-28-2023, 10:34 PM
[No subject] - by deudas - 01-28-2023, 10:50 PM
[No subject] - by WhosUrDaddi - 01-30-2023, 08:32 PM
[No subject] - by WhosUrDaddi - 01-30-2023, 09:42 PM
[No subject] - by Stormax - 01-31-2023, 11:00 AM
[No subject] - by nicolasg - 01-31-2023, 11:05 AM
[No subject] - by Stormax - 01-31-2023, 11:39 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)