+// Engine info panel (#13)
+//
+float prevfps;
+float prevfps_time;
+float framecounter;
+void HUD_EngineInfo(void)
+{
+ float id = HUD_PANEL_ENGINEINFO;
+ vector pos, mySize;
+ pos = HUD_Panel_GetPos(id);
+ mySize = HUD_Panel_GetSize(id);
+
+ HUD_Panel_DrawBg(id, pos, mySize, 0);
+ float padding;
+ padding = HUD_Panel_GetPadding(id);
+ if(padding)
+ {
+ pos += '1 1 0' * padding;
+ mySize -= '2 2 0' * padding;
+ }
+
+ if(cvar("hud_engineinfo_framecounter_exponentialmovingaverage"))
+ {
+ float weight;
+ weight = cvar("hud_engineinfo_framecounter_exponentialmovingaverage_new_weight");
+ if(frametime > 0.0001) // filter out insane values which sometimes seem to occur and throw off the average? If you are getting 10,000 fps or more, then you don't need a framerate counter.
+ {
+ if(fabs(prevfps - (1/frametime)) > prevfps * cvar("hud_engineinfo_framecounter_exponentialmovingaverage_instantupdate_change_threshold")) // if there was a big jump in fps, just force prevfps at current (1/frametime) to make big updates instant
+ prevfps = (1/frametime);
+ prevfps = (1 - weight) * prevfps + weight * (1/frametime);
+ }
+ }
+ else
+ {
+ framecounter += 1;
+ if(time - prevfps_time > cvar("hud_engineinfo_framecounter_time"))
+ {
+ prevfps = framecounter/cvar("hud_engineinfo_framecounter_time");
+ framecounter = 0;
+ prevfps_time = time;
+ }
+ }
+
+ vector color;
+ color = HUD_Get_Num_Color (prevfps, 100);
+ drawstring(pos, strcat("FPS: ", ftos_decimals(prevfps, 2)), '1 1 0' * 0.5 * mySize_y, color, HUD_Panel_GetFgAlpha(id), DRAWFLAG_NORMAL);
+}