Selectively enable clamping - seeing if this helps avoid weird flake problems while still fixing vertical lines in waves and sky
authornemo
Thu, 30 Jul 2009 22:36:57 +0000
changeset 2290 bf87ca44782e
parent 2289 cb850ba733bd
child 2291 353fb9621da0
Selectively enable clamping - seeing if this helps avoid weird flake problems while still fixing vertical lines in waves and sky
hedgewars/uChat.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
--- a/hedgewars/uChat.pas	Thu Jul 30 17:32:46 2009 +0000
+++ b/hedgewars/uChat.pas	Thu Jul 30 22:36:57 2009 +0000
@@ -71,7 +71,7 @@
 SDL_FreeSurface(strSurface);
 
 cl.Time:= RealTicks + 12500;
-cl.Tex:= Surface2Tex(resSurface);
+cl.Tex:= Surface2Tex(resSurface, false);
 
 SDL_FreeSurface(resSurface)
 end;
--- a/hedgewars/uMisc.pas	Thu Jul 30 17:32:46 2009 +0000
+++ b/hedgewars/uMisc.pas	Thu Jul 30 22:36:57 2009 +0000
@@ -148,7 +148,7 @@
 procedure SendStat(sit: TStatInfoType; s: shortstring);
 function  Str2PChar(const s: shortstring): PChar;
 function NewTexture(width, height: Longword; buf: Pointer): PTexture;
-function  Surface2Tex(surf: PSDL_Surface): PTexture;
+function  Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture;
 procedure FreeTexture(tex: PTexture);
 function  toPowerOf2(i: Longword): Longword;
 function DecodeBase64(s: shortstring): shortstring;
@@ -347,7 +347,7 @@
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
 end;
 
-function Surface2Tex(surf: PSDL_Surface): PTexture;
+function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture;
 var modeIntFormat: LongInt;
     modeFormat: LongInt;
 	tw, th, x, y: Longword;
@@ -469,8 +469,11 @@
 if SDL_MustLock(surf) then
 	SDL_UnlockSurface(surf);
 
-//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+if enableClamp and not cReducedQuality then
+    begin
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
+    end;
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
 end;
--- a/hedgewars/uStore.pas	Thu Jul 30 17:32:46 2009 +0000
+++ b/hedgewars/uStore.pas	Thu Jul 30 22:36:57 2009 +0000
@@ -162,7 +162,7 @@
 		rr:= r;
 		inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4);
 		DrawRoundRect(@rr, Clan^.Color, Clan^.Color, texsurf, false);
-		HealthTex:= Surface2Tex(texsurf);
+		HealthTex:= Surface2Tex(texsurf, false);
 		SDL_FreeSurface(texsurf);
 
 		dec(drY, r.h + 2);
@@ -177,7 +177,7 @@
 						texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone);
 						if texsurf <> nil then
 							begin
-							HatTex:= Surface2Tex(texsurf);
+							HatTex:= Surface2Tex(texsurf, false);
 							SDL_FreeSurface(texsurf)
 							end
 						end
@@ -217,7 +217,7 @@
 		if SDL_MustLock(texsurf) then
 			SDL_UnlockSurface(texsurf);
 
-		CrosshairTex:= Surface2Tex(texsurf);
+		CrosshairTex:= Surface2Tex(texsurf, false);
 		SDL_FreeSurface(texsurf)
 		end;
 
@@ -247,7 +247,7 @@
 			begin
 			if GraveName = '' then GraveName:= 'Simple';
 			texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, ifCritical or ifTransparent);
-			GraveTex:= Surface2Tex(texsurf);
+			GraveTex:= Surface2Tex(texsurf, false);
 			SDL_FreeSurface(texsurf)
 			end
 	end;
@@ -291,14 +291,17 @@
 			if imageHeight = 0 then imageHeight := tmpsurf^.h;
 			if Width = 0 then Width:= tmpsurf^.w;
 			if Height = 0 then Height:= tmpsurf^.h;
-			Texture:= Surface2Tex(tmpsurf);
+            if (ii = sprSky) or (ii = sprWater) then
+			    Texture:= Surface2Tex(tmpsurf, true)
+            else
+			    Texture:= Surface2Tex(tmpsurf, false);
 			if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf)
 		end;
 
 AddProgress;
 
 tmpsurf:= LoadImage(Pathz[ptGraphics] + '/' + cHHFileName, ifAlpha or ifCritical or ifTransparent);
-HHTexture:= Surface2Tex(tmpsurf);
+HHTexture:= Surface2Tex(tmpsurf, false);
 SDL_FreeSurface(tmpsurf);
 
 InitHealth;
@@ -310,14 +313,14 @@
 	with Ammoz[ai] do
 		begin
 		tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(trAmmo[NameId]), $FFFFFF);
-		NameTex:= Surface2Tex(tmpsurf);
+		NameTex:= Surface2Tex(tmpsurf, false);
 		SDL_FreeSurface(tmpsurf)
 		end;
 		
 for i:= Low(CountTexz) to High(CountTexz) do
 	begin
 	tmpsurf:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(IntToStr(i) + 'x'), $FFFFFF);
-	CountTexz[i]:= Surface2Tex(tmpsurf);
+	CountTexz[i]:= Surface2Tex(tmpsurf, false);
 	SDL_FreeSurface(tmpsurf)
 	end;
 
@@ -681,7 +684,7 @@
 
 TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
 
-RenderStringTex:= Surface2Tex(Result);
+RenderStringTex:= Surface2Tex(Result, false);
 
 SDL_FreeSurface(Result)
 end;
@@ -861,7 +864,7 @@
     end;
 
 //TryDo(SDL_SetColorKey(Result, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
-RenderSpeechBubbleTex:= Surface2Tex(Result);
+RenderSpeechBubbleTex:= Surface2Tex(Result, false);
 
 SDL_FreeSurface(rotatedEdge);
 SDL_FreeSurface(Result)
@@ -1000,7 +1003,7 @@
    begin
    WriteToConsole(msgLoading + 'progress sprite: ');
    texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', ifCritical or ifTransparent);
-   ProgrTex:= Surface2Tex(texsurf);
+   ProgrTex:= Surface2Tex(texsurf, false);
    SDL_FreeSurface(texsurf);
    squaresize:= ProgrTex^.w shr 1;
    numsquares:= ProgrTex^.h div squaresize;
--- a/hedgewars/uWorld.pas	Thu Jul 30 17:32:46 2009 +0000
+++ b/hedgewars/uWorld.pas	Thu Jul 30 22:36:57 2009 +0000
@@ -430,7 +430,7 @@
       s:= inttostr(FPS) + ' fps';
       if fpsTexture <> nil then FreeTexture(fpsTexture);
       tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
-      fpsTexture:= Surface2Tex(tmpSurface);
+      fpsTexture:= Surface2Tex(tmpSurface, false);
       SDL_FreeSurface(tmpSurface)
       end;
    if fpsTexture <> nil then