]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/fps_display_fix' into 'master'
authorMario <mario.mario@y7mail.com>
Mon, 5 Oct 2020 09:52:46 +0000 (09:52 +0000)
committerMario <mario.mario@y7mail.com>
Mon, 5 Oct 2020 09:52:46 +0000 (09:52 +0000)
fps display fix

See merge request xonotic/xonotic-data.pk3dir!852

1  2 
qcsrc/client/hud/panel/engineinfo.qc
qcsrc/client/view.qc

index 7760c56f7c6a3865bc8fab19e66ef6f44b1f544f,4d7fe5c77b7846077d96166d5d3104fdbb5d208c..41fdb3a5bbf3985c0a8401287d3dc3fe2a5d6fec
@@@ -1,7 -1,7 +1,7 @@@
  #include "engineinfo.qh"
  
  #include <client/autocvars.qh>
 -#include <client/miscfunctions.qh>
 +#include <client/draw.qh>
  
  // Engine info (#13)
  
@@@ -43,7 -43,7 +43,7 @@@ void HUD_EngineInfo(
                mySize -= '2 2 0' * panel_bg_padding;
        }
  
-       float currentTime = gettime(GETTIME_REALTIME);
+       float currentTime = gettime(GETTIME_FRAMESTART);
        if(autocvar_hud_panel_engineinfo_framecounter_exponentialmovingaverage)
        {
                float currentframetime = currentTime - prevfps_time;
diff --combined qcsrc/client/view.qc
index c7b7a37c7eeb42cf32d685de43011e3af8ec96d2,6eb3c851563a70b67bd09d9ec061d7f80f120ef7..2b4081aba8a477e379105df27480434754d77082
@@@ -1,7 -1,7 +1,7 @@@
  #include "view.qh"
  
  #include "autocvars.qh"
 -#include "miscfunctions.qh"
 +#include <client/draw.qh>
  #include "announcer.qh"
  #include "hud/_mod.qh"
  #include "main.qh"
@@@ -363,33 -363,6 +363,33 @@@ STATIC_INIT(viewmodel) 
        viewmodels[slot] = new(viewmodel);
  }
  
 +vector project_3d_to_2d(vector vec)
 +{
 +      vec = cs_project(vec);
 +      if(cs_project_is_b0rked > 0)
 +      {
 +              vec.x *= vid_conwidth / vid_width;
 +              vec.y *= vid_conheight / vid_height;
 +      }
 +      return vec;
 +}
 +
 +bool projected_on_screen(vector screen_pos)
 +{
 +      return screen_pos.z >= 0
 +              && screen_pos.x >= 0
 +              && screen_pos.y >= 0
 +              && screen_pos.x < vid_conwidth
 +              && screen_pos.y < vid_conheight;
 +}
 +
 +void update_mousepos()
 +{
 +      mousepos += getmousepos() * autocvar_menu_mouse_speed;
 +      mousepos.x = bound(0, mousepos.x, vid_conwidth);
 +      mousepos.y = bound(0, mousepos.y, vid_conheight);
 +}
 +
  float showfps_prevfps;
  float showfps_prevfps_time;
  int showfps_framecounter;
@@@ -399,7 -372,8 +399,8 @@@ void fpscounter_update(
        if(!STAT(SHOWFPS))
                return;
  
-       float currentTime = gettime(GETTIME_REALTIME);
+       float currentTime = gettime(GETTIME_FRAMESTART);
        showfps_framecounter += 1;
        if(currentTime - showfps_prevfps_time > STAT(SHOWFPS))
        {
  
  STATIC_INIT(fpscounter_init)
  {
-       float currentTime = gettime(GETTIME_REALTIME);
+       float currentTime = gettime(GETTIME_FRAMESTART);
        showfps_prevfps_time = currentTime; // we must initialize it to avoid an instant low frame sending
  }