diff --git a/src/game/g_holmes.inc b/src/game/g_holmes.inc
index d103cdb76d184a31e6764433164feee4d1fbcd4b..c053b4c73e8eb7b246bf9470fc055a808b0b6434 100644 (file)
--- a/src/game/g_holmes.inc
+++ b/src/game/g_holmes.inc
end;
+// ////////////////////////////////////////////////////////////////////////// //
+type
+ TScissorSave = record
+ public
+ wassc: Boolean;
+ scxywh: packed array[0..3] of GLint;
+
+ public
+ procedure save (enableScissoring: Boolean);
+ procedure restore ();
+ end;
+
+procedure TScissorSave.save (enableScissoring: Boolean);
+begin
+ wassc := (glIsEnabled(GL_SCISSOR_TEST) <> 0);
+ if wassc then glGetIntegerv(GL_SCISSOR_BOX, @scxywh[0]) else glGetIntegerv(GL_VIEWPORT, @scxywh[0]);
+ //conwritefln('(%d,%d)-(%d,%d)', [scxywh[0], scxywh[1], scxywh[2], scxywh[3]]);
+ if enableScissoring then glEnable(GL_SCISSOR_TEST);
+end;
+
+
+procedure TScissorSave.restore ();
+begin
+ glScissor(scxywh[0], scxywh[1], scxywh[2], scxywh[3]);
+ if wassc then glEnable(GL_SCISSOR_TEST) else glDisable(GL_SCISSOR_TEST);
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
// fonts
const kgiFont6: array[0..256*8-1] of Byte = (
end;
+// ////////////////////////////////////////////////////////////////////////// //
+procedure normRGBA (var r, g, b, a: Integer); inline;
+begin
+ if (a < 0) then a := 0 else if (a > 255) then a := 255;
+ if (r < 0) then r := 0 else if (r > 255) then r := 255;
+ if (g < 0) then g := 0 else if (g > 255) then g := 255;
+ if (b < 0) then b := 0 else if (b > 255) then b := 255;
+end;
+
+
+// ////////////////////////////////////////////////////////////////////////// //
function textWidth6 (const s: AnsiString): Integer;
var
f: Integer;
begin
result := 0;
if (Length(s) = 0) then exit;
- if (a < 0) then a := 0 else if (a > 255) then a := 255;
- if (r < 0) then r := 0 else if (r > 255) then r := 255;
- if (g < 0) then g := 0 else if (g > 255) then g := 255;
- if (b < 0) then b := 0 else if (b > 255) then b := 255;
+ normRGBA(r, g, b, a);
if (a < 255) then
begin
// ////////////////////////////////////////////////////////////////////////// //
procedure drawLine (x1, y1, x2, y2: Integer; r, g, b: Integer; a: Integer=255);
begin
- if (a < 0) then a := 0 else if (a > 255) then a := 255;
- if (r < 0) then r := 0 else if (r > 255) then r := 255;
- if (g < 0) then g := 0 else if (g > 255) then g := 255;
- if (b < 0) then b := 0 else if (b > 255) then b := 255;
+ normRGBA(r, g, b, a);
if (a < 255) then
begin
procedure drawRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
begin
if (w < 0) or (h < 0) then exit;
- if (a < 0) then a := 0 else if (a > 255) then a := 255;
- if (r < 0) then r := 0 else if (r > 255) then r := 255;
- if (g < 0) then g := 0 else if (g > 255) then g := 255;
- if (b < 0) then b := 0 else if (b > 255) then b := 255;
+ normRGBA(r, g, b, a);
if (a < 255) then
begin
glEnable(GL_BLEND);
end;
+procedure drawRectUI (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
+begin
+ drawRect(x, y, w, h, r, g, b, a);
+end;
+
+
procedure darkenRect (x, y, w, h: Integer; a: Integer);
begin
if (w < 0) or (h < 0) then exit;
procedure fillRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
begin
if (w < 0) or (h < 0) then exit;
- if (a < 0) then a := 0 else if (a > 255) then a := 255;
- if (r < 0) then r := 0 else if (r > 255) then r := 255;
- if (g < 0) then g := 0 else if (g > 255) then g := 255;
- if (b < 0) then b := 0 else if (b > 255) then b := 255;
+ normRGBA(r, g, b, a);
if (a < 255) then
begin
glEnable(GL_BLEND);