X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_holmes.inc;h=c053b4c73e8eb7b246bf9470fc055a808b0b6434;hb=ae58c60b09a12df74e69717546235c3e5bf3c992;hp=d103cdb76d184a31e6764433164feee4d1fbcd4b;hpb=b4a2614636a9cc12ce9766ec1e2bf04cd5bec0ea;p=d2df-sdl.git diff --git a/src/game/g_holmes.inc b/src/game/g_holmes.inc index d103cdb..c053b4c 100644 --- a/src/game/g_holmes.inc +++ b/src/game/g_holmes.inc @@ -153,6 +153,34 @@ begin 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 = ( @@ -434,6 +462,17 @@ begin 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; @@ -462,10 +501,7 @@ var 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 @@ -517,10 +553,7 @@ end; // ////////////////////////////////////////////////////////////////////////// // 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 @@ -558,10 +591,7 @@ end; 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); @@ -597,6 +627,12 @@ begin 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; @@ -624,10 +660,7 @@ end; 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);