DEADSOFTWARE

gl: draw fps
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Tue, 26 Jul 2022 21:42:43 +0000 (00:42 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 9 Jun 2023 09:03:26 +0000 (12:03 +0300)
src/game/renders/opengl/r_common.pas
src/game/renders/opengl/r_render.pas

index eb81170038204432031f8e08e89d60c0982a7cda..448458903b26b9061ac04e097d32f2e764fa2fb9 100644 (file)
@@ -117,6 +117,7 @@ implementation
 {$ENDIF}
     if p <> nil then
     begin
+      // TODO look up/down
       r_Common_GetPlayerPos(p, x, y);
       if center then
       begin
index 0b67e2d0b1561f92ed89ef24fb9b63ac7cca6944..f9c0024381a16880c14abfc6562dacba33435386 100644 (file)
@@ -101,6 +101,8 @@ implementation
     hudrflag, hudrflags, hudrflagd: TGLTexture;
     hudbflag, hudbflags, hudbflagd: TGLTexture;
 
+    FPS, FPSCounter, FPSTime: LongWord;
+
   procedure r_Render_LoadTextures;
   begin
     r_Map_LoadTextures;
@@ -1039,11 +1041,20 @@ implementation
   end;
 
   procedure r_Render_Draw;
-    var p1, p2: TPlayer;
+    var p1, p2: TPlayer; time: LongWord;
   begin
     if gExit = EXIT_QUIT then
       exit;
 
+    INC(FPSCounter);
+    time := GetTickCount64();
+    if time - FPSTime >= 1000 then
+    begin
+      FPS := FPSCounter;
+      FPSCounter := 0;
+      FPSTime := time;
+    end;
+
     r_Draw_Setup(gScreenWidth, gScreenHeight);
 
     glClearColor(0.0, 0.0, 0.0, 0.0);
@@ -1096,8 +1107,6 @@ implementation
 
     if gGameOn or ((gState in [STATE_FOLD]) and (EndingGameCounter < 255)) then
     begin
-      // TODO setup player hear point
-
       if gSpectMode = SPECT_MAPVIEW then
       begin
         r_Render_DrawMapView(0, 0, gScreenWidth, gScreenHeight, gSpectX + gScreenWidth div 2, gSpectY + gScreenHeight div 2);
@@ -1139,6 +1148,7 @@ implementation
 
     if not gGameOn then
     begin
+      // TODO F key handle
       case gState of
         STATE_NONE: (* do nothing *) ;
         STATE_MENU: r_Render_DrawBackground(GameWad + ':TEXTURES/TITLE');
@@ -1211,8 +1221,21 @@ implementation
 
     r_Console_Draw(false);
 
+    // TODO g_debug_Sounds
+
+    if gShowFPS then
+    begin
+      r_Common_DrawText('FPS: ' + IntToStr(FPS), 0, 0, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
+      r_Common_DrawText('UPS: ' + IntToStr(UPS), 0, 16, 255, 255, 255, 255, stdfont, TBasePoint.BP_LEFTUP);
+    end;
+
+    // TODO gShowTime
+    // TODO draw profilers
+
     // TODO draw holmes interface
 
+    // TODO draw touch screen controls
+
     glFlush();
     glFinish();
     sys_Repaint;
@@ -1241,6 +1264,7 @@ implementation
 
   function r_Render_WriteScreenShot (filename: String): Boolean;
   begin
+    // TODO write screenshot file
     Result := False;
   end;
 
@@ -1261,6 +1285,7 @@ implementation
 {$IFDEF ENABLE_TOUCH}
   procedure r_Render_GetKeyRect (key: Integer; out x, y, w, h: Integer; out founded: Boolean);
   begin
+    // TODO implement touchscreen
     founded := False;
   end;
 {$ENDIF}