Enable back fps counter
authorunc0rr
Sat, 26 Jan 2008 10:55:34 +0000
changeset 759 8da05b316d81
parent 758 bebfae2063b3
child 760 23aaafa40b4e
Enable back fps counter
QTfrontend/game.cpp
hedgewars/uConsts.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
--- a/QTfrontend/game.cpp	Sat Jan 26 10:21:43 2008 +0000
+++ b/QTfrontend/game.cpp	Sat Jan 26 10:55:34 2008 +0000
@@ -251,7 +251,7 @@
 	arguments << cfgdir->absolutePath();
 	arguments << QString::number(resolution.width());
 	arguments << QString::number(resolution.height());
-	arguments << "16";//QString::number(config->bitDepth()); // bpp
+	arguments << QString::number(config->bitDepth()); // bpp
 	arguments << QString("%1").arg(ipc_port);
 	arguments << (config->vid_Fullscreen() ? "1" : "0");
 	arguments << (config->isSoundEnabled() ? "1" : "0");
--- a/hedgewars/uConsts.pas	Sat Jan 26 10:21:43 2008 +0000
+++ b/hedgewars/uConsts.pas	Sat Jan 26 10:55:34 2008 +0000
@@ -111,7 +111,7 @@
 
       MAXNAMELEN = 32;
 
-      COLOR_LAND = $7FFFFFF;
+      COLOR_LAND = $FFFFFFF;
 
       cifRandomize = $00000001;
       cifTheme     = $00000002;
--- a/hedgewars/uMisc.pas	Sat Jan 26 10:21:43 2008 +0000
+++ b/hedgewars/uMisc.pas	Sat Jan 26 10:55:34 2008 +0000
@@ -117,6 +117,7 @@
 procedure SendStat(sit: TStatInfoType; s: shortstring);
 function  Str2PChar(const s: shortstring): PChar;
 function  Surface2Tex(surf: PSDL_Surface): PTexture;
+procedure FreeTexture(tex: PTexture);
 
 var CursorPoint: TPoint;
     TargetPoint: TPoint = (X: NoPointX; Y: 0);
@@ -286,6 +287,11 @@
 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR)
 end;
 
+procedure FreeTexture(tex: PTexture);
+begin
+glDeleteTextures(1, @tex^.id);
+dispose(tex)
+end;
 
 var i: LongInt;
 {$ENDIF}
--- a/hedgewars/uStore.pas	Sat Jan 26 10:21:43 2008 +0000
+++ b/hedgewars/uStore.pas	Sat Jan 26 10:55:34 2008 +0000
@@ -300,6 +300,7 @@
 var rr: TSDL_Rect;
     t, b: real;
 begin
+if SourceTexture^.h = 0 then exit;
 rr.x:= X;
 rr.y:= Y;
 rr.w:= r^.w;
@@ -434,7 +435,7 @@
 var ii: TSprite;
 begin
 for ii:= Low(TSprite) to High(TSprite) do
-    glDeleteTextures(1, @SpritesData[ii].Texture);
+    FreeTexture(SpritesData[ii].Texture);
 SDL_FreeSurface(  HHSurface  );
 SDL_FreeSurface(LandSurface  )
 end;
--- a/hedgewars/uWorld.pas	Sat Jan 26 10:21:43 2008 +0000
+++ b/hedgewars/uWorld.pas	Sat Jan 26 10:55:34 2008 +0000
@@ -52,7 +52,8 @@
 var cWaterSprCount: LongInt;
     Captions: array[TCapGroup] of TCaptionStr;
     AMxLeft, AMxCurr, SlotsNum: LongInt;
-    fpsSurface: PSDL_Surface;
+    tmpSurface: PSDL_Surface;
+    fpsTexture: PTexture = nil;
 
 procedure InitWorld;
 begin
@@ -361,12 +362,20 @@
       Frames:= 0;
       CountTicks:= 0;
       s:= inttostr(FPS) + ' fps';
-      if fpsSurface <> nil then SDL_FreeSurface(fpsSurface);
-      fpsSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
+      if fpsTexture <> nil then FreeTexture(fpsTexture);
+      tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
+      fpsTexture:= Surface2Tex(tmpSurface);
+      SDL_FreeSurface(tmpSurface)
       end;
-   r.x:= cScreenWidth - 50;
-   r.y:= 10;
-//   SDL_UpperBlit(fpsSurface, nil, Surface, @r)
+   if fpsTexture <> nil then
+      begin
+      r.x:= 0;
+      r.y:= 0;
+      r.w:= fpsTexture^.w;
+      r.h:= fpsTexture^.h;
+      DrawFromRect(cScreenWidth - 50, 10, @r, fpsTexture, Surface);
+      end
+//  SDL_UpperBlit(fpsSurface, nil, Surface, @r)
    end;
 
 inc(SoundTimerTicks, Lag);