DEADSOFTWARE

gl: draw screen flashes
[d2df-sdl.git] / src / game / renders / opengl / r_draw.pas
index e836b30d1190e7923f536587de66c616106fd3e0..c2bfc245726f040e249c9455835317666c7726a3 100644 (file)
@@ -30,6 +30,8 @@ interface
   procedure r_Draw_MultiTextureRepeatRotate (m: TGLMultiTexture; const anim: TAnimState; x, y, w, h: Integer; flip: Boolean; r, g, b, a: Byte; blend: Boolean; rx, ry, angle: Integer);
 
   procedure r_Draw_Filter (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
+  procedure r_Draw_FillRect (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
+  procedure r_Draw_InvertRect (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
 
 implementation
 
@@ -116,8 +118,6 @@ implementation
       DrawTile(nil, x, y, w, h, flip, NTR, NTB, NTG, NTA, blend)
     else
     begin
-      glPushMatrix;
-      glScalef(w / img.width, h / img.height, 1);
       offx := 0;
       offy := 0;
       for j := 0 to img.lines - 1 do
@@ -126,13 +126,16 @@ implementation
         begin
           n := img.GetTile(i, j);
           ASSERT(n <> nil);
-          DrawTile(n, x + offx, y + offy, n.width, n.height, flip, r, g, b, a, blend);
+          glPushMatrix;
+          glTranslatef(x + offx, y + offy, 0);
+          glScalef(w / img.width, h / img.height, 1);
+          DrawTile(n, 0, 0, n.width, n.height, flip, r, g, b, a, blend);
+          glPopMatrix;
           offx := offx + n.width;
         end;
         offx := 0;
         offy := offy + n.height;
       end;
-      glPopMatrix;
     end
   end;
 
@@ -220,4 +223,36 @@ implementation
     glEnd;
   end;
 
+  procedure r_Draw_FillRect (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
+  begin
+    ASSERT(r >= l);
+    ASSERT(b >= t);
+    glEnable(GL_BLEND);
+    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+    glDisable(GL_TEXTURE_2D);
+    glColor4ub(rr, gg, bb, aa);
+    glBegin(GL_QUADS);
+      glVertex2i(l, t);
+      glVertex2i(r, t);
+      glVertex2i(r, b);
+      glVertex2i(l, b);
+    glEnd;
+  end;
+
+  procedure r_Draw_InvertRect (l, t, r, b: Integer; rr, gg, bb, aa: Byte);
+  begin
+    ASSERT(r >= l);
+    ASSERT(b >= t);
+    glEnable(GL_BLEND);
+    glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
+    glDisable(GL_TEXTURE_2D);
+    glColor4ub(rr, gg, bb, aa);
+    glBegin(GL_QUADS);
+      glVertex2i(l, t);
+      glVertex2i(r, t);
+      glVertex2i(r, b);
+      glVertex2i(l, b);
+    glEnd;
+  end;
+
 end.