DEADSOFTWARE

slightly better mplat rendering (no support for NPOT yet)
authorKetmar Dark <ketmar@ketmar.no-ip.org>
Tue, 5 Sep 2017 03:44:06 +0000 (06:44 +0300)
committerKetmar Dark <ketmar@ketmar.no-ip.org>
Tue, 5 Sep 2017 03:44:25 +0000 (06:44 +0300)
src/engine/e_graphics.pas
src/game/g_panel.pas
src/shared/xdynrec.pas

index b88dfb603b61262459c5d260469b0ad013ecf198..3fdc66c51d10d4f5801dd385df81646fc065c607 100644 (file)
@@ -67,8 +67,12 @@ procedure e_DrawSize(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolea
                      Blending: Boolean; Width, Height: Word; Mirror: TMirrorType = M_NONE);
 procedure e_DrawSizeMirror(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
                            Blending: Boolean; Width, Height: Word; Mirror: TMirrorType = M_NONE);
+
 procedure e_DrawFill(ID: DWORD; X, Y: Integer; XCount, YCount: Word; Alpha: Integer;
                      AlphaChannel: Boolean; Blending: Boolean);
+
+procedure e_DrawFillX (id: DWORD; x, y, wdt, hgt: Integer; alpha: Integer; alphachannel: Boolean; blending: Boolean);
+
 procedure e_DrawPoint(Size: Byte; X, Y: Integer; Red, Green, Blue: Byte);
 procedure e_DrawLine(Width: Byte; X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
 procedure e_DrawQuad(X1, Y1, X2, Y2: Integer; Red, Green, Blue: Byte; Alpha: Byte = 0);
@@ -679,6 +683,85 @@ begin
   glDisable(GL_BLEND);
 end;
 
+procedure e_DrawFillX (id: DWORD; x, y, wdt, hgt: Integer; alpha: Integer; alphachannel: Boolean; blending: Boolean);
+var
+  x2, y2: Integer;
+  //dx, w, h: Integer;
+  //u, v: Single;
+begin
+  if e_NoGraphics then exit;
+
+  if (wdt < 1) or (hgt < 1) then exit;
+
+  if (wdt mod e_Textures[ID].tx.width = 0) and (hgt mod e_Textures[ID].tx.height = 0) then
+  begin
+    e_DrawFill(id, x, y, wdt div e_Textures[ID].tx.width, hgt div e_Textures[ID].tx.height, alpha, alphachannel, blending);
+    exit;
+  end;
+
+  glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255);
+
+  if (Alpha > 0) or AlphaChannel or Blending then
+    glEnable(GL_BLEND)
+  else
+    glDisable(GL_BLEND);
+
+  if AlphaChannel or (Alpha > 0) then glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+  if (Alpha > 0) then glColor4ub(e_Colors.R, e_Colors.G, e_Colors.B, 255-Alpha);
+
+  if Blending then glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+
+  glEnable(GL_TEXTURE_2D);
+  glBindTexture(GL_TEXTURE_2D, e_Textures[ID].tx.id);
+
+  x2 := x+wdt;
+  y2 := y+hgt;
+
+  //k8: this SHOULD work... i hope
+  if (e_Textures[ID].tx.width = e_Textures[ID].tx.glwidth) and (e_Textures[ID].tx.height = e_Textures[ID].tx.glheight) then
+  begin
+    glBegin(GL_QUADS);
+      glTexCoord2f(0, hgt/e_Textures[ID].tx.height); glVertex2i(x,  y);
+      glTexCoord2f(wdt/e_Textures[ID].tx.width, hgt/e_Textures[ID].tx.height); glVertex2i(x2, y);
+      glTexCoord2f(wdt/e_Textures[ID].tx.width, 0); glVertex2i(x2, y2);
+      glTexCoord2f(0, 0); glVertex2i(x, y2);
+    glEnd();
+  end
+  else
+  begin
+    {
+    glBegin(GL_QUADS);
+    // hard day's night
+    u := e_Textures[ID].tx.u;
+    v := e_Textures[ID].tx.v;
+    w := e_Textures[ID].tx.width;
+    h := e_Textures[ID].tx.height;
+    while YCount > 0 do
+    begin
+      dx := XCount;
+      x2 := X;
+      while dx > 0 do
+      begin
+        glTexCoord2f(0, v); glVertex2i(X,  Y);
+        glTexCoord2f(u, v); glVertex2i(X+w, Y);
+        glTexCoord2f(u, 0); glVertex2i(X+w, Y+h);
+        glTexCoord2f(0, 0); glVertex2i(X,  Y+h);
+        Inc(X, w);
+        Dec(dx);
+      end;
+      X := x2;
+      Inc(Y, h);
+      Dec(YCount);
+    end;
+    glEnd();
+    }
+  end;
+
+  glDisable(GL_BLEND);
+end;
+
+
 procedure e_DrawAdv(ID: DWORD; X, Y: Integer; Alpha: Byte; AlphaChannel: Boolean;
                     Blending: Boolean; Angle: Single; RC: PDFPoint; Mirror: TMirrorType = M_NONE);
 begin
index 2f54116f98da1fcf96782ba70d2035e2e335553d..1ae4b9e89556b650af90931c02c4749f5b74651d 100644 (file)
@@ -450,10 +450,10 @@ begin
             end;
 
           else
-            e_DrawFill(FTextureIDs[FCurTexture].Tex, X, Y,
-                       Width div FTextureWidth,
-                       Height div FTextureHeight,
-                       FAlpha, True, FBlending);
+            if not mMovingActive then
+              e_DrawFill(FTextureIDs[FCurTexture].Tex, X, Y, Width div FTextureWidth, Height div FTextureHeight, FAlpha, True, FBlending)
+            else
+              e_DrawFillX(FTextureIDs[FCurTexture].Tex, X, Y, Width, Height, FAlpha, True, FBlending);
         end;
       end;
   end;
index 1c5b2e6f232c1f35f447917ad13e7aad2149dc52..fe9c5616f346c30fe79c9ba24b19193763a9e9c2 100644 (file)
@@ -3147,7 +3147,7 @@ end;
 function TDynMapDef.parseMap (pr: TTextParser): TDynRecord;
 var
   res: TDynRecord = nil;
-  fo: TextFile;
+  //fo: TextFile;
 begin
   result := nil;
   try