DEADSOFTWARE

gl: free old map textures before load new textures
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Thu, 16 Feb 2023 18:17:57 +0000 (21:17 +0300)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Fri, 9 Jun 2023 09:14:23 +0000 (12:14 +0300)
src/game/renders/opengl/r_map.pas

index 26a15dc4881d3e97f1a621ae2dbd4a518794cd05..c008f432def97874c3cce8089a30e1ce109847d5 100644 (file)
@@ -525,10 +525,22 @@ implementation
       r_Common_FreeAndNil(Items[i].tex);
   end;
 
+  procedure r_Map_FreeTextures;
+    var i: Integer;
+  begin
+    plist.Clear;
+    r_Common_FreeAndNil(SkyTexture);
+    if RenTextures <> nil then
+      for i := 0 to High(RenTextures) do
+        r_Common_FreeAndNil(RenTextures[i].tex);
+    SetLength(RenTextures, 0);
+  end;
+
   procedure r_Map_LoadTextures;
     const DefaultAnimInfo: TAnimInfo = (loop: true; delay: 1; frames: 1; back: false);
     var i, n: Integer; txt: TAnimTextInfo;
   begin
+    r_Map_FreeTextures;
     if Textures <> nil then
     begin
       n := Length(Textures);
@@ -567,17 +579,6 @@ implementation
     plist.Clear;
   end;
 
-  procedure r_Map_FreeTextures;
-    var i: Integer;
-  begin
-    plist.Clear;
-    r_Common_FreeAndNil(SkyTexture);
-    if RenTextures <> nil then
-      for i := 0 to High(RenTextures) do
-        r_Common_FreeAndNil(RenTextures[i].tex);
-    SetLength(RenTextures, 0);
-  end;
-
   procedure r_Map_DrawPanel (p: TPanel);
     var Texture: Integer; t: TGLMultiTexture; tex: TGLTexture; count, frame: LongInt; a: TAnimInfo;
   begin