New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
authornemo
Tue, 22 Jun 2010 23:08:57 -0400
changeset 3537 8f5b3108f29c
parent 3536 7d99655130ff
child 3539 c3d1fccbe0ed
New approach to the low-res problem. Basically, we already have a 1024 minimum, and the tallest maps are restricting themselves to 2048 maximum. All backgrounds are scaled down 50%, then scaled up on draw. Saves memory, and backgrounds are already deliberately fuzzed for depth of field anyway.
hedgewars/uConsts.pas
hedgewars/uMisc.pas
hedgewars/uStore.pas
hedgewars/uWorld.pas
share/hedgewars/Data/Themes/Art/Sky-lowres.png
share/hedgewars/Data/Themes/Art/Sky.png
share/hedgewars/Data/Themes/Art/horizont-lowres.png
share/hedgewars/Data/Themes/Art/horizont.png
share/hedgewars/Data/Themes/Bamboo/Sky-lowres.png
share/hedgewars/Data/Themes/Bamboo/Sky.png
share/hedgewars/Data/Themes/Bamboo/SkyL.png
share/hedgewars/Data/Themes/Bamboo/SkyR.png
share/hedgewars/Data/Themes/Bamboo/horizont-lowres.png
share/hedgewars/Data/Themes/Bamboo/horizont.png
share/hedgewars/Data/Themes/Bath/Sky-lowres.png
share/hedgewars/Data/Themes/Bath/Sky.png
share/hedgewars/Data/Themes/Bath/horizont-lowres.png
share/hedgewars/Data/Themes/Bath/horizont.png
share/hedgewars/Data/Themes/Bath/horizontL.png
share/hedgewars/Data/Themes/Bath/horizontR.png
share/hedgewars/Data/Themes/Blox/Sky.png
share/hedgewars/Data/Themes/Blox/horizont-lowres.png
share/hedgewars/Data/Themes/Blox/horizont.png
share/hedgewars/Data/Themes/Brick/Sky.png
share/hedgewars/Data/Themes/Brick/horizont.png
share/hedgewars/Data/Themes/Cake/Sky.png
share/hedgewars/Data/Themes/Cake/horizont.png
share/hedgewars/Data/Themes/Castle/Sky-lowres.png
share/hedgewars/Data/Themes/Castle/Sky.png
share/hedgewars/Data/Themes/Castle/SkyL.png
share/hedgewars/Data/Themes/Castle/SkyR.png
share/hedgewars/Data/Themes/Castle/horizont-lowres.png
share/hedgewars/Data/Themes/Castle/horizont.png
share/hedgewars/Data/Themes/Cheese/Sky.png
share/hedgewars/Data/Themes/Cheese/horizont.png
share/hedgewars/Data/Themes/City/Sky-lowres.png
share/hedgewars/Data/Themes/City/Sky.png
share/hedgewars/Data/Themes/City/horizont-lowres.png
share/hedgewars/Data/Themes/City/horizont.png
share/hedgewars/Data/Themes/Compost/Sky-lowres.png
share/hedgewars/Data/Themes/Compost/Sky.png
share/hedgewars/Data/Themes/Compost/horizont-lowres.png
share/hedgewars/Data/Themes/Compost/horizont.png
share/hedgewars/Data/Themes/CrazyMission/Sky-lowres.png
share/hedgewars/Data/Themes/CrazyMission/Sky.png
share/hedgewars/Data/Themes/CrazyMission/SkyL.png
share/hedgewars/Data/Themes/CrazyMission/SkyR.png
share/hedgewars/Data/Themes/CrazyMission/horizont-lowres.png
share/hedgewars/Data/Themes/CrazyMission/horizont.png
share/hedgewars/Data/Themes/Deepspace/Sky.png
share/hedgewars/Data/Themes/Deepspace/horizont.png
share/hedgewars/Data/Themes/Desert/Sky-lowres.png
share/hedgewars/Data/Themes/Desert/Sky.png
share/hedgewars/Data/Themes/Desert/horizont-lowres.png
share/hedgewars/Data/Themes/Desert/horizont.png
share/hedgewars/Data/Themes/EarthRise/Sky-lowres.png
share/hedgewars/Data/Themes/EarthRise/Sky.png
share/hedgewars/Data/Themes/EarthRise/SkyL.png
share/hedgewars/Data/Themes/EarthRise/SkyR.png
share/hedgewars/Data/Themes/EarthRise/horizont-lowres.png
share/hedgewars/Data/Themes/EarthRise/horizont.png
share/hedgewars/Data/Themes/EarthRise/horizontL.png
share/hedgewars/Data/Themes/EarthRise/horizontR.png
share/hedgewars/Data/Themes/Eyes/Sky-lowres.png
share/hedgewars/Data/Themes/Eyes/Sky.png
share/hedgewars/Data/Themes/Eyes/horizont-lowres.png
share/hedgewars/Data/Themes/Eyes/horizont.png
share/hedgewars/Data/Themes/Freeway/Sky-lowres.png
share/hedgewars/Data/Themes/Freeway/Sky.png
share/hedgewars/Data/Themes/Freeway/horizont-lowres.png
share/hedgewars/Data/Themes/Freeway/horizont.png
share/hedgewars/Data/Themes/Halloween/Sky-lowres.png
share/hedgewars/Data/Themes/Halloween/Sky.png
share/hedgewars/Data/Themes/Halloween/SkyL.png
share/hedgewars/Data/Themes/Halloween/SkyR.png
share/hedgewars/Data/Themes/Halloween/horizont.png
share/hedgewars/Data/Themes/Hell/Sky.png
share/hedgewars/Data/Themes/Hell/horizont-lowres.png
share/hedgewars/Data/Themes/Hell/horizont.png
share/hedgewars/Data/Themes/Island/Sky-lowres.png
share/hedgewars/Data/Themes/Island/Sky.png
share/hedgewars/Data/Themes/Island/horizont-lowres.png
share/hedgewars/Data/Themes/Island/horizont.png
share/hedgewars/Data/Themes/Nature/Sky-lowres.png
share/hedgewars/Data/Themes/Nature/Sky.png
share/hedgewars/Data/Themes/Nature/horizont-lowres.png
share/hedgewars/Data/Themes/Nature/horizont.png
share/hedgewars/Data/Themes/Olympics/Sky.png
share/hedgewars/Data/Themes/Olympics/horizont.png
share/hedgewars/Data/Themes/Planes/Sky.png
share/hedgewars/Data/Themes/Planes/horizont-lowres.png
share/hedgewars/Data/Themes/Planes/horizont.png
share/hedgewars/Data/Themes/Sheep/Sky-lowres.png
share/hedgewars/Data/Themes/Sheep/Sky.png
share/hedgewars/Data/Themes/Sheep/horizont-lowres.png
share/hedgewars/Data/Themes/Sheep/horizont.png
share/hedgewars/Data/Themes/Snow/Sky.png
share/hedgewars/Data/Themes/Snow/horizont-lowres.png
share/hedgewars/Data/Themes/Snow/horizont.png
share/hedgewars/Data/Themes/Stage/Sky-lowres.png
share/hedgewars/Data/Themes/Stage/Sky.png
share/hedgewars/Data/Themes/Stage/SkyL.png
share/hedgewars/Data/Themes/Stage/SkyR.png
share/hedgewars/Data/Themes/Stage/horizont-lowres.png
share/hedgewars/Data/Themes/Stage/horizont.png
share/hedgewars/Data/Themes/Underwater/Sky-lowres.png
share/hedgewars/Data/Themes/Underwater/Sky.png
share/hedgewars/Data/Themes/Underwater/horizont-lowres.png
share/hedgewars/Data/Themes/Underwater/horizont.png
--- a/hedgewars/uConsts.pas	Tue Jun 22 22:21:44 2010 +0400
+++ b/hedgewars/uConsts.pas	Tue Jun 22 23:08:57 2010 -0400
@@ -171,7 +171,7 @@
     PTexture = ^TTexture;
     TTexture = record
             id: GLuint;
-            w, h: LongInt;
+            w, h, scale: LongInt;
             rx, ry: GLfloat;
             priority: GLfloat;
             vb, tb: array [0..3] of TVertex2f;
@@ -220,7 +220,6 @@
     ifCritical    = $00000002;  // image is critical for gameplay (exit game if unable to load)
     ifTransparent = $00000004;  // image uses transparent pixels (color keying)
     ifIgnoreCaps  = $00000008;  // ignore hardware capabilities when loading (i.e. image will not be drawn using OpenGL)
-    ifLowRes      = $00000010;  // try loading a low resolution image when it is critical
 
     // texture priority (allows OpenGL to keep frequently used textures in video memory more easily)
     tpLowest     = 0.00;
--- a/hedgewars/uMisc.pas	Tue Jun 22 22:21:44 2010 +0400
+++ b/hedgewars/uMisc.pas	Tue Jun 22 23:08:57 2010 -0400
@@ -403,6 +403,7 @@
 new(NewTexture);
 NewTexture^.PrevTexture:= nil;
 NewTexture^.NextTexture:= nil;
+NewTexture^.Scale:= 1;
 if TextureList <> nil then
     begin
     TextureList^.PrevTexture:= NewTexture;
--- a/hedgewars/uStore.pas	Tue Jun 22 22:21:44 2010 +0400
+++ b/hedgewars/uStore.pas	Tue Jun 22 23:08:57 2010 -0400
@@ -395,9 +395,9 @@
         begin
             if AltPath = ptNone then
                 if ii in [sprHorizontL, sprHorizontR, sprSkyL, sprSkyR] then // FIXME: hack
-                    tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifLowRes)
+                    tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent)
                 else
-                    tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical or ifLowRes)
+                    tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent or ifCritical)
             else begin
                 tmpsurf:= LoadImage(Pathz[Path] + '/' + FileName, ifAlpha or ifTransparent);
                 if tmpsurf = nil then
@@ -411,7 +411,10 @@
                 if Width = 0 then Width:= tmpsurf^.w;
                 if Height = 0 then Height:= tmpsurf^.h;
                 if (ii in [sprSky, sprSkyL, sprSkyR, sprHorizont, sprHorizontL, sprHorizontR]) then
-                    Texture:= Surface2Tex(tmpsurf, true)
+                    begin
+                    Texture:= Surface2Tex(tmpsurf, true);
+                    Texture^.Scale:= 2
+                    end
                 else
                     begin
                     Texture:= Surface2Tex(tmpsurf, false);
@@ -1089,7 +1092,6 @@
         if (imageFlags and ifCritical) <> 0 then WriteToConsole(' Critical');
         if (imageFlags and ifTransparent) <> 0 then WriteToConsole(' Transparent');
         if (imageFlags and ifIgnoreCaps) <> 0 then WriteToConsole(' IgnoreCaps');
-        if (imageFlags and ifLowRes) <> 0 then WriteToConsole(' LowRes');
         end;
     WriteToConsole('] ');
 {$ENDIF}
@@ -1097,29 +1099,6 @@
     s:= filename + '.png';
     tmpsurf:= IMG_Load(Str2PChar(s));
 
-    if (imageFlags and ifLowRes) <> 0 then
-    begin
-        s:= filename + '-lowres.png';
-        if (tmpsurf <> nil) then
-        begin
-            if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then
-            begin
-                SDL_FreeSurface(tmpsurf);
-                {$IFDEF DEBUGFILE}
-                AddFileLog('...image too big, trying to load lowres version: ' + s + '...');
-                {$ENDIF}
-                tmpsurf:= IMG_Load(Str2PChar(s))
-            end;
-        end
-        else
-        begin
-            {$IFDEF DEBUGFILE}
-            AddFileLog('...image not found, trying to load lowres version: ' + s + '...');
-            {$ENDIF}
-            tmpsurf:= IMG_Load(Str2PChar(s))
-        end;
-    end;
-
     if tmpsurf = nil then
     begin
         OutError(msgFailed, (imageFlags and ifCritical) <> 0);
--- a/hedgewars/uWorld.pas	Tue Jun 22 22:21:44 2010 +0400
+++ b/hedgewars/uWorld.pas	Tue Jun 22 23:08:57 2010 -0400
@@ -486,38 +486,44 @@
 end;
 
 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt);
-var i, w, sw: LongInt;
+var i, w, h, lw, lh, rw, rh, sw: LongInt;
 begin
     sw:= round(cScreenWidth / cScaleFactor);
     if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then
     begin
-        w:= SpritesData[spr].Width;
+        w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale;
+        h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale;
         i:= Shift mod w;
         if i > 0 then dec(i, w);
         dec(i, w * (sw div w + 1));
         repeat
-            DrawSprite(spr, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[spr].Height, 0);
+            DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale);
             inc(i, w)
         until i > sw
     end
     else
     begin
-        w:= SpritesData[spr].Width;
+        w:= SpritesData[spr].Width * SpritesData[spr].Texture^.Scale;
+        h:= SpritesData[spr].Height * SpritesData[spr].Texture^.Scale;
+        lw:= SpritesData[sprL].Width * SpritesData[spr].Texture^.Scale;
+        lh:= SpritesData[sprL].Height * SpritesData[spr].Texture^.Scale;
+        rw:= SpritesData[sprR].Width * SpritesData[spr].Texture^.Scale;
+        rh:= SpritesData[sprR].Height * SpritesData[spr].Texture^.Scale;
         dec(Shift, w div 2);
-        DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[spr].Height, 0);
+        DrawTexture(Shift, WorldDy + LAND_HEIGHT + OffsetY - h, SpritesData[spr].Texture, SpritesData[spr].Texture^.Scale);
     
-        i:= Shift - SpritesData[sprL].Width;
-        while i >= -sw - SpritesData[sprL].Width do
+        i:= Shift - lw;
+        while i >= -sw - lw do
         begin
-            DrawSprite(sprL, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[sprL].Height, 0);
-            dec(i, SpritesData[sprL].Width);
+            DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - lh, SpritesData[sprL].Texture, SpritesData[sprL].Texture^.Scale);
+            dec(i, lw);
         end;
         
         i:= Shift + w;
         while i <= sw do
         begin
-            DrawSprite(sprR, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[sprR].Height, 0);
-            inc(i, SpritesData[sprR].Width)
+            DrawTexture(i, WorldDy + LAND_HEIGHT + OffsetY - rh, SpritesData[sprR].Texture, SpritesData[sprR].Texture^.Scale);
+            inc(i, rw)
         end
     end
 end;
Binary file share/hedgewars/Data/Themes/Art/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Art/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Art/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Art/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Bamboo/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Bamboo/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Bamboo/SkyL.png has changed
Binary file share/hedgewars/Data/Themes/Bamboo/SkyR.png has changed
Binary file share/hedgewars/Data/Themes/Bamboo/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Bamboo/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Bath/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Bath/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Bath/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Bath/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Bath/horizontL.png has changed
Binary file share/hedgewars/Data/Themes/Bath/horizontR.png has changed
Binary file share/hedgewars/Data/Themes/Blox/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Blox/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Blox/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Brick/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Brick/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Cake/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Cake/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Castle/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Castle/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Castle/SkyL.png has changed
Binary file share/hedgewars/Data/Themes/Castle/SkyR.png has changed
Binary file share/hedgewars/Data/Themes/Castle/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Castle/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Cheese/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Cheese/horizont.png has changed
Binary file share/hedgewars/Data/Themes/City/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/City/Sky.png has changed
Binary file share/hedgewars/Data/Themes/City/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/City/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Compost/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Compost/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Compost/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Compost/horizont.png has changed
Binary file share/hedgewars/Data/Themes/CrazyMission/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/CrazyMission/Sky.png has changed
Binary file share/hedgewars/Data/Themes/CrazyMission/SkyL.png has changed
Binary file share/hedgewars/Data/Themes/CrazyMission/SkyR.png has changed
Binary file share/hedgewars/Data/Themes/CrazyMission/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/CrazyMission/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Deepspace/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Deepspace/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Desert/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Desert/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Desert/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Desert/horizont.png has changed
Binary file share/hedgewars/Data/Themes/EarthRise/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/EarthRise/Sky.png has changed
Binary file share/hedgewars/Data/Themes/EarthRise/SkyL.png has changed
Binary file share/hedgewars/Data/Themes/EarthRise/SkyR.png has changed
Binary file share/hedgewars/Data/Themes/EarthRise/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/EarthRise/horizont.png has changed
Binary file share/hedgewars/Data/Themes/EarthRise/horizontL.png has changed
Binary file share/hedgewars/Data/Themes/EarthRise/horizontR.png has changed
Binary file share/hedgewars/Data/Themes/Eyes/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Eyes/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Eyes/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Eyes/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Freeway/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Freeway/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Freeway/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Freeway/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Halloween/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Halloween/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Halloween/SkyL.png has changed
Binary file share/hedgewars/Data/Themes/Halloween/SkyR.png has changed
Binary file share/hedgewars/Data/Themes/Halloween/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Hell/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Hell/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Hell/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Island/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Island/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Island/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Island/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Nature/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Nature/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Nature/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Nature/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Olympics/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Olympics/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Planes/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Planes/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Planes/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Sheep/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Sheep/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Sheep/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Sheep/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Snow/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Snow/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Snow/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Stage/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Stage/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Stage/SkyL.png has changed
Binary file share/hedgewars/Data/Themes/Stage/SkyR.png has changed
Binary file share/hedgewars/Data/Themes/Stage/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Stage/horizont.png has changed
Binary file share/hedgewars/Data/Themes/Underwater/Sky-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Underwater/Sky.png has changed
Binary file share/hedgewars/Data/Themes/Underwater/horizont-lowres.png has changed
Binary file share/hedgewars/Data/Themes/Underwater/horizont.png has changed