DEADSOFTWARE

put "{$MODE ...}" directive in each source file; removed trailing spaces, and convert...
[d2df-sdl.git] / src / engine / e_textures.pas
index e7bcbcf99e89db1f8cd72da1bb77423ea1bde9fd..e53a3ef263fdd9033c454fe49b70b929c0f74685 100644 (file)
@@ -1,3 +1,4 @@
+{$MODE DELPHI}
 unit e_textures;
 
 { This unit provides interface to load 24-bit and 32-bit uncompressed images
@@ -18,6 +19,7 @@ type
   end;
 
 var
+  e_DummyTextures: Boolean = False;
   TEXTUREFILTER: Integer = GL_NEAREST;
 
 function CreateTexture(var tex: GLTexture; Width, Height, aFormat: Word; pData: Pointer ): Boolean;
@@ -94,6 +96,13 @@ begin
     e_WriteLog(Format('NPOT: orig is %ux%u; gl is %ux%u; u=%f; v=%f', [Width, Height, tex.glwidth, tex.glheight, tex.u, tex.v]), MSG_NOTIFY);
   end;
 
+  if e_DummyTextures then
+  begin
+    tex.id := GLuint(-1);
+    Result := True;
+    Exit;
+  end;
+
   glGenTextures(1, @Texture);
   tex.id := Texture;
   glBindTexture(GL_TEXTURE_2D, Texture);
@@ -192,6 +201,12 @@ begin
     Exit;
   end;
 
+  if (TGAHeader.ImageInfo and $c0) <> 0 then
+  begin
+    e_WriteLog('Error loading texture: interleaved TGA', MSG_WARNING);
+    Exit;
+  end;
+
   Width  := TGAHeader.Width[0]  + TGAHeader.Width[1]  * 256;
   Height := TGAHeader.Height[0] + TGAHeader.Height[1] * 256;
   BPP := TGAHeader.BPP;
@@ -210,6 +225,8 @@ begin
     Back^  := Temp;
   end;
 
+  //if (TGAHeader.ImageInfo and $20) <> 0 then UpsideDown(Image, Width, Height);
+
   if ( BPP = 24 ) then
     TFmt := GL_RGB
   else
@@ -265,6 +282,12 @@ begin
     Exit;
   end;
 
+  if (TGAHeader.ImageInfo and $c0) <> 0 then
+  begin
+    e_WriteLog('Error loading texture: interleaved TGA', MSG_WARNING);
+    Exit;
+  end;
+
   Width  := TGAHeader.Width[0]  + TGAHeader.Width[1]  * 256;
   Height := TGAHeader.Height[0] + TGAHeader.Height[1] * 256;
   BPP := TGAHeader.BPP;
@@ -301,6 +324,8 @@ begin
   for i := 0 to fHeight-1 do
     CopyMemory( PByte(image) + a*i, Base + b*i, a );
 
+  //if (TGAHeader.ImageInfo and $20) <> 0 then UpsideDown(Image, Width, Height);
+
   if ( BPP = 24 ) then
     TFmt := GL_RGB
   else