summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: caff92f)
raw | patch | inline | side by side (parent: caff92f)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Mon, 25 Sep 2017 22:00:09 +0000 (01:00 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Tue, 26 Sep 2017 06:01:34 +0000 (09:01 +0300) |
src/game/g_holmes.pas | patch | blob | history | |
src/gx/gh_ui.pas | patch | blob | history | |
src/gx/glgfx.pas | patch | blob | history |
diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 94e61712c56dbd741a4cdb13a7626dbf2054cfcc..53b7c7343e62d83c48356e5f88cc634d35a94521 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
end;
if g_ol_fill_walls then
begin
- fillRect(pan.X, pan.Y, pan.Width, pan.Height, r, g, b);
+ fillRect(pan.X, pan.Y, pan.Width, pan.Height, TGxRGBA.Create(r, g, b));
end
else if not g_ol_nice then
begin
- drawRect(pan.X, pan.Y, pan.Width, pan.Height, r, g, b);
+ drawRect(pan.X, pan.Y, pan.Width, pan.Height, TGxRGBA.Create(r, g, b));
end;
end;
if g_ol_nice then
begin
for y := 0 to (mapGrid.gridHeight div mapGrid.tileSize) do
begin
- drawLine(mapGrid.gridX0, mapGrid.gridY0+y*mapGrid.tileSize, mapGrid.gridX0+mapGrid.gridWidth, mapGrid.gridY0+y*mapGrid.tileSize, 96, 96, 96, 255);
+ drawLine(mapGrid.gridX0, mapGrid.gridY0+y*mapGrid.tileSize, mapGrid.gridX0+mapGrid.gridWidth, mapGrid.gridY0+y*mapGrid.tileSize, TGxRGBA.Create(96, 96, 96));
end;
for x := 0 to (mapGrid.gridWidth div mapGrid.tileSize) do
begin
- drawLine(mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0, mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0+y*mapGrid.gridHeight, 96, 96, 96, 255);
+ drawLine(mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0, mapGrid.gridX0+x*mapGrid.tileSize, mapGrid.gridY0+y*mapGrid.gridHeight, TGxRGBA.Create(96, 96, 96));
end;
end;
begin
if awmIsSetHolmes(x*mapGrid.tileSize+mapGrid.gridX0+1, y*mapGrid.tileSize++mapGrid.gridY0+1) then
begin
- fillRect(x*mapGrid.tileSize++mapGrid.gridX0, y*mapGrid.tileSize++mapGrid.gridY0, monsGrid.tileSize, monsGrid.tileSize, 128, 0, 128, 64);
+ fillRect(x*mapGrid.tileSize++mapGrid.gridX0, y*mapGrid.tileSize++mapGrid.gridY0, monsGrid.tileSize, monsGrid.tileSize, TGxRGBA.Create(128, 0, 128, 64));
end;
end;
end;
plr := gPlayers[0];
if (plr = nil) then exit;
plr.getMapBox(px, py, pw, ph);
- drawRect(px, py, pw, ph, 255, 0, 255, 200);
+ drawRect(px, py, pw, ph, TGxRGBA.Create(255, 0, 255, 200));
pdx := pmsCurMapX-(px+pw div 2);
pdy := pmsCurMapY-(py+ph div 2);
- drawLine(px+pw div 2, py+ph div 2, px+pw div 2+pdx, py+ph div 2+pdy, 255, 0, 255, 200);
+ drawLine(px+pw div 2, py+ph div 2, px+pw div 2+pdx, py+ph div 2+pdy, TGxRGBA.Create(255, 0, 255, 200));
pan := mapGrid.traceBox(ex, ey, px, py, pw, ph, pdx, pdy, nil, GridTagObstacle);
if (pan = nil) then
begin
- drawRect(px+pdx, py+pdy, pw, ph, 255, 255, 255, 180);
+ drawRect(px+pdx, py+pdy, pw, ph, TGxRGBA.Create(255, 255, 255, 180));
end
else
begin
- drawRect(px+pdx, py+pdy, pw, ph, 255, 255, 0, 180);
+ drawRect(px+pdx, py+pdy, pw, ph, TGxRGBA.Create(255, 255, 0, 180));
end;
- drawRect(ex, ey, pw, ph, 255, 127, 0, 180);
+ drawRect(ex, ey, pw, ph, TGxRGBA.Create(255, 127, 0, 180));
end;
procedure hilightCell (cx, cy: Integer);
begin
- fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize, 0, 128, 0, 64);
+ fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize, TGxRGBA.Create(0, 128, 0, 64));
end;
procedure hilightCell1 (cx, cy: Integer);
//e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
cx := cx and (not (monsGrid.tileSize-1));
cy := cy and (not (monsGrid.tileSize-1));
- fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize, 255, 255, 0, 92);
+ fillRect(cx, cy, monsGrid.tileSize, monsGrid.tileSize, TGxRGBA.Create(255, 255, 0, 92));
end;
function hilightWallTrc (pan: TPanel; tag: Integer; x, y, prevx, prevy: Integer): Boolean;
result := false; // don't stop
if (pan = nil) then exit; // cell completion, ignore
//e_WriteLog(Format('h1: (%d,%d)', [cx, cy]), MSG_NOTIFY);
- fillRect(pan.X, pan.Y, pan.Width, pan.Height, 0, 128, 128, 64);
+ fillRect(pan.X, pan.Y, pan.Width, pan.Height, TGxRGBA.Create(0, 128, 128, 64));
end;
function monsCollector (mon: TMonster; tag: Integer): Boolean;
exit;
end;
mon.getMapBox(mx, my, mw, mh);
- drawLine(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, 255, 0, 0, 255);
+ drawLine(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, TGxRGBA.Create(255, 0, 0));
if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
begin
- drawLine(mx+mw div 2, my+mh div 2, ex, ey, 0, 255, 0, 255);
+ drawLine(mx+mw div 2, my+mh div 2, ex, ey, TGxRGBA.Create(0, 255, 0));
end;
end;
if (eplr = nil) then exit;
eplr.getMapBox(emx, emy, emw, emh);
mon.getMapBox(mx, my, mw, mh);
- drawLine(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, 255, 0, 0, 255);
+ drawLine(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, TGxRGBA.Create(255, 0, 0));
{$IF DEFINED(D2F_DEBUG)}
mapGrid.dbgRayTraceTileHitCB := hilightCell1;
{$ENDIF}
if (g_Map_traceToNearestWall(mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, @ex, @ey) <> nil) then
//if (mapGrid.traceRay(ex, ey, mx+mw div 2, my+mh div 2, emx+emw div 2, emy+emh div 2, hilightWallTrc, (GridTagWall or GridTagDoor)) <> nil) then
begin
- drawLine(mx+mw div 2, my+mh div 2, ex, ey, 0, 255, 0, 255);
+ drawLine(mx+mw div 2, my+mh div 2, ex, ey, TGxRGBA.Create(0, 255, 0));
end;
{$IF DEFINED(D2F_DEBUG)}
mapGrid.dbgRayTraceTileHitCB := nil;
my -= 2;
// type
- drawText6(mx, my, Format('%s(U:%u)', [monsTypeToString(mon.MonsterType), mon.UID]), 255, 127, 0); my -= 8;
+ drawText6(mx, my, Format('%s(U:%u)', [monsTypeToString(mon.MonsterType), mon.UID]), TGxRGBA.Create(255, 127, 0)); my -= 8;
// beh
- drawText6(mx, my, Format('Beh: %s', [monsBehToString(mon.MonsterBehaviour)]), 255, 127, 0); my -= 8;
+ drawText6(mx, my, Format('Beh: %s', [monsBehToString(mon.MonsterBehaviour)]), TGxRGBA.Create(255, 127, 0)); my -= 8;
// state
- drawText6(mx, my, Format('State:%s (%d)', [monsStateToString(mon.MonsterState), mon.MonsterSleep]), 255, 127, 0); my -= 8;
+ drawText6(mx, my, Format('State:%s (%d)', [monsStateToString(mon.MonsterState), mon.MonsterSleep]), TGxRGBA.Create(255, 127, 0)); my -= 8;
// health
- drawText6(mx, my, Format('Health:%d', [mon.MonsterHealth]), 255, 127, 0); my -= 8;
+ drawText6(mx, my, Format('Health:%d', [mon.MonsterHealth]), TGxRGBA.Create(255, 127, 0)); my -= 8;
// ammo
- drawText6(mx, my, Format('Ammo:%d', [mon.MonsterAmmo]), 255, 127, 0); my -= 8;
+ drawText6(mx, my, Format('Ammo:%d', [mon.MonsterAmmo]), TGxRGBA.Create(255, 127, 0)); my -= 8;
// target
- drawText6(mx, my, Format('TgtUID:%u', [mon.MonsterTargetUID]), 255, 127, 0); my -= 8;
- drawText6(mx, my, Format('TgtTime:%d', [mon.MonsterTargetTime]), 255, 127, 0); my -= 8;
+ drawText6(mx, my, Format('TgtUID:%u', [mon.MonsterTargetUID]), TGxRGBA.Create(255, 127, 0)); my -= 8;
+ drawText6(mx, my, Format('TgtTime:%d', [mon.MonsterTargetTime]), TGxRGBA.Create(255, 127, 0)); my -= 8;
end;
drawMonsterTargetLine();
pan := g_Map_PanelByGUID(platMarkedGUID);
if (pan = nil) then exit;
mapGrid.forEachBodyCell(pan.proxyId, hilightCell);
- drawRect(pan.x, pan.y, pan.width, pan.height, 0, 200, 0, 200);
+ drawRect(pan.x, pan.y, pan.width, pan.height, TGxRGBA.Create(0, 200, 0, 200));
end;
procedure drawTrigger (var trig: TTrigger);
drawLine(
trig.trigCenter.x, trig.trigCenter.y,
pan.x+pan.width div 2, pan.y+pan.height div 2,
- 255, 0, 255, 220);
+ TGxRGBA.Create(255, 0, 255, 220));
end;
var
tts: AnsiString;
tx: Integer;
begin
- fillRect(trig.x, trig.y, trig.width, trig.height, 255, 0, 255, 96);
+ fillRect(trig.x, trig.y, trig.width, trig.height, TGxRGBA.Create(255, 0, 255, 96));
tts := trigType2Str(trig.TriggerType);
tx := trig.x+(trig.width-Length(tts)*6) div 2;
darkenRect(tx-2, trig.y-10, Length(tts)*6+4, 10, 64);
- drawText6(tx, trig.y-9, tts, 255, 127, 0);
+ drawText6(tx, trig.y-9, tts, TGxRGBA.Create(255, 127, 0));
tx := trig.x+(trig.width-Length(trig.mapId)*6) div 2;
darkenRect(tx-2, trig.y-20, Length(trig.mapId)*6+4, 10, 64);
- drawText6(tx, trig.y-19, trig.mapId, 255, 255, 0);
+ drawText6(tx, trig.y-19, trig.mapId, TGxRGBA.Create(255, 255, 0));
drawPanelDest(trig.trigPanelGUID);
case trig.TriggerType of
TRIGGER_NONE: begin end;
fillRect(
trig.trigDataRec.trigTX, trig.trigDataRec.trigTY,
trig.trigDataRec.trigTWidth, trig.trigDataRec.trigTHeight,
- 0, 255, 255, 42);
+ TGxRGBA.Create(0, 255, 255, 42));
drawLine(
trig.trigCenter.x, trig.trigCenter.y,
trig.trigDataRec.trigTX+trig.trigDataRec.trigTWidth div 2,
trig.trigDataRec.trigTY+trig.trigDataRec.trigTHeight div 2,
- 255, 0, 255, 220);
+ TGxRGBA.Create(255, 0, 255, 220));
end;
end;
TRIGGER_SOUND: begin end;
if gib.alive then
begin
gib.getMapBox(px, py, pw, ph);
- drawRect(px, py, pw, ph, 255, 0, 255);
+ drawRect(px, py, pw, ph, TGxRGBA.Create(255, 0, 255));
end;
end;
end;
scisave.restore();
end;
- if showMapCurPos then drawText8(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]), 255, 255, 0);
+ if showMapCurPos then drawText8(4, gWinSizeY-10, Format('mappos:(%d,%d)', [pmsCurMapX, pmsCurMapY]), TGxRGBA.Create(255, 255, 0));
end;
diff --git a/src/gx/gh_ui.pas b/src/gx/gh_ui.pas
index 8875f7dd1c82e2102055260da504faf3fd6e4530..85a4a5ff67af8b0dfc792556119c218d9fbbb749 100644 (file)
--- a/src/gx/gh_ui.pas
+++ b/src/gx/gh_ui.pas
procedure THTopWindow.drawControl (gx, gy: Integer);
begin
- fillRect(gx, gy, mWidth, mHeight, 0, 0, 128);
+ fillRect(gx, gy, mWidth, mHeight, TGxRGBA.Create(0, 0, 128));
end;
begin
if mDragging then
begin
- drawRectUI(mX+4, mY+4, mWidth-8, mHeight-8, r, g, b);
+ drawRectUI(mX+4, mY+4, mWidth-8, mHeight-8, TGxRGBA.Create(r, g, b));
end
else
begin
- drawRectUI(mX+3, mY+3, mWidth-6, mHeight-6, r, g, b);
- drawRectUI(mX+5, mY+5, mWidth-10, mHeight-10, r, g, b);
+ drawRectUI(mX+3, mY+3, mWidth-6, mHeight-6, TGxRGBA.Create(r, g, b));
+ drawRectUI(mX+5, mY+5, mWidth-10, mHeight-10, TGxRGBA.Create(r, g, b));
setScissor(mFrameWidth, 0, 3*8, 8);
- fillRect(mX+mFrameWidth, mY, 3*8, 8, 0, 0, 128);
- drawText8(mX+mFrameWidth, mY, '[ ]', r, g, b);
- if mInClose then drawText8(mX+mFrameWidth+7, mY, '#', 0, 255, 0)
- else drawText8(mX+mFrameWidth+7, mY, '*', 0, 255, 0);
+ fillRect(mX+mFrameWidth, mY, 3*8, 8, TGxRGBA.Create(0, 0, 128));
+ drawText8(mX+mFrameWidth, mY, '[ ]', TGxRGBA.Create(r, g, b));
+ if mInClose then drawText8(mX+mFrameWidth+7, mY, '#', TGxRGBA.Create(0, 255, 0))
+ else drawText8(mX+mFrameWidth+7, mY, '*', TGxRGBA.Create(0, 255, 0));
end;
if (Length(mTitle) > 0) then
begin
setScissor(mFrameWidth+3*8, 0, mWidth-mFrameWidth*2-3*8, 8);
tx := (mX+3*8)+((mWidth-3*8)-Length(mTitle)*8) div 2;
- fillRect(tx-3, mY, Length(mTitle)*8+3+2, 8, 0, 0, 128);
- drawText8(tx, mY, mTitle, r, g, b);
+ fillRect(tx-3, mY, Length(mTitle)*8+3+2, 8, TGxRGBA.Create(0, 0, 128));
+ drawText8(tx, mY, mTitle, TGxRGBA.Create(r, g, b));
end;
inherited drawControlPost(gx, gy);
end;
b := 255;
if (Length(it.title) = 0) then
begin
- drawHLine(gx+4, gy+3, mWidth-8, r, g, b);
+ drawHLine(gx+4, gy+3, mWidth-8, TGxRGBA.Create(r, g, b));
end
else if (tx-3 > gx+4) then
begin
- drawHLine(gx+4, gy+3, tx-3-(gx+3), r, g, b);
- drawHLine(tx+Length(it.title)*8, gy+3, mWidth-4, r, g, b);
+ drawHLine(gx+4, gy+3, tx-3-(gx+3), TGxRGBA.Create(r, g, b));
+ drawHLine(tx+Length(it.title)*8, gy+3, mWidth-4, TGxRGBA.Create(r, g, b));
end;
end;
- drawText8(tx, gy, it.title, r, g, b);
+ drawText8(tx, gy, it.title, TGxRGBA.Create(r, g, b));
Inc(gy, 8);
end;
end;
for f := 0 to High(mItems) do
begin
it := @mItems[f];
- if (mCurIndex = f) then fillRect(gx, gy, mWidth, 8, 0, 128, 0);
+ if (mCurIndex = f) then fillRect(gx, gy, mWidth, 8, TGxRGBA.Create(0, 128, 0));
if (it.varp <> nil) then
begin
- if it.varp^ then drawText8(gx, gy, '[x]', 255, 255, 255) else drawText8(gx, gy, '[ ]', 255, 255, 255);
- drawText8(gx+3*8+2, gy, it.title, 255, 255, 0);
+ if it.varp^ then drawText8(gx, gy, '[x]', TGxRGBA.Create(255, 255, 255)) else drawText8(gx, gy, '[ ]', TGxRGBA.Create(255, 255, 255));
+ drawText8(gx+3*8+2, gy, it.title, TGxRGBA.Create(255, 255, 0));
end
else if (Length(it.title) > 0) then
begin
tx := gx+(mWidth-Length(it.title)*8) div 2;
if (tx-3 > gx+4) then
begin
- drawHLine(gx+4, gy+3, tx-3-(gx+3), 255, 255, 255);
- drawHLine(tx+Length(it.title)*8, gy+3, mWidth-4, 255, 255, 255);
+ drawHLine(gx+4, gy+3, tx-3-(gx+3), TGxRGBA.Create(255, 255, 255));
+ drawHLine(tx+Length(it.title)*8, gy+3, mWidth-4, TGxRGBA.Create(255, 255, 255));
end;
- drawText8(tx, gy, it.title, 255, 255, 255);
+ drawText8(tx, gy, it.title, TGxRGBA.Create(255, 255, 255));
end
else
begin
- drawHLine(gx+4, gy+3, mWidth-8, 255, 255, 255);
+ drawHLine(gx+4, gy+3, mWidth-8, TGxRGBA.Create(255, 255, 255));
end;
Inc(gy, 8);
end;
if mHasFrame then
begin
// draw frame
- drawRectUI(gx+3, gy+3, mWidth-6, mHeight-6, r, g, b);
+ drawRectUI(gx+3, gy+3, mWidth-6, mHeight-6, TGxRGBA.Create(r, g, b));
end;
// draw caption
if (Length(mCaption) > 0) then
begin
setScissor(mFrameWidth+1, 0, mWidth-mFrameWidth-2, 8);
tx := gx+((mWidth-Length(mCaption)*8) div 2);
- if mHasFrame then fillRect(tx-2, gy, Length(mCaption)*8+3, 8, 0, 0, 128);
- drawText8(tx, gy, mCaption, r, g, b);
+ if mHasFrame then fillRect(tx-2, gy, Length(mCaption)*8+3, 8, TGxRGBA.Create(0, 0, 128));
+ drawText8(tx, gy, mCaption, TGxRGBA.Create(r, g, b));
end;
end;
begin
if mHoriz then
begin
- drawHLine(gx, gy+(mHeight div 2), mWidth, 255, 255, 255);
+ drawHLine(gx, gy+(mHeight div 2), mWidth, TGxRGBA.Create(255, 255, 255));
end
else
begin
- drawVLine(gx+(mWidth div 2), gy, mHeight, 255, 255, 255);
+ drawVLine(gx+(mWidth div 2), gy, mHeight, TGxRGBA.Create(255, 255, 255));
end;
- //fillRect(gx, gy, mWidth, mHeight, 255, 0, 0);
end;
xpos, ypos: Integer;
begin
// debug
- fillRect(gx, gy, mWidth, mHeight, 96, 96, 0);
- drawRectUI(gx, gy, mWidth, mHeight, 96, 96, 96);
+ fillRect(gx, gy, mWidth, mHeight, TGxRGBA.Create(96, 96, 0));
+ drawRectUI(gx, gy, mWidth, mHeight, TGxRGBA.Create(96, 96, 96));
if (Length(mText) > 0) then
begin
else if (mVAlign > 0) then ypos := mHeight-8
else ypos := (mHeight-8) div 2;
- drawText8(gx+xpos, gy+ypos, mText, 255, 255, 255);
+ drawText8(gx+xpos, gy+ypos, mText, TGxRGBA.Create(255, 255, 255));
end;
end;
diff --git a/src/gx/glgfx.pas b/src/gx/glgfx.pas
index 5fa57e737cd43880e78b30966723f54301b9acbc..84bbe534e6109242155034c68c8be8cd46123569 100644 (file)
--- a/src/gx/glgfx.pas
+++ b/src/gx/glgfx.pas
@@ -132,28 +132,29 @@ function intersectRect (var x0, y0, w0, h0: Integer; const x1, y1, w1, h1: Integ
procedure normRGBA (var r, g, b, a: Integer); inline;
function setupGLColor (r, g, b, a: Integer): Boolean;
+function setupGLColor (constref clr: TGxRGBA): Boolean;
function isScaled (): Boolean;
function textWidth6 (const s: AnsiString): Integer;
function textWidth8 (const s: AnsiString): Integer;
// return width (including last empty pixel)
-function drawTextInternal (wdt, x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer; tid: GLuint; constref fontwdt: array of Byte; prop: Boolean): Integer;
-procedure drawLine (x1, y1, x2, y2: Integer; r, g, b: Integer; a: Integer=255);
-procedure drawVLine (x, y, len: Integer; r, g, b: Integer; a: Integer=255);
-procedure drawHLine (x, y, len: Integer; r, g, b: Integer; a: Integer=255);
-procedure drawRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
-procedure drawRectUI (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
+function drawTextInternal (wdt, x, y: Integer; const s: AnsiString; constref clr: TGxRGBA; tid: GLuint; constref fontwdt: array of Byte; prop: Boolean): Integer;
+procedure drawLine (x1, y1, x2, y2: Integer; constref clr: TGxRGBA);
+procedure drawVLine (x, y, len: Integer; constref clr: TGxRGBA);
+procedure drawHLine (x, y, len: Integer; constref clr: TGxRGBA);
+procedure drawRect (x, y, w, h: Integer; constref clr: TGxRGBA);
+procedure drawRectUI (x, y, w, h: Integer; constref clr: TGxRGBA);
procedure darkenRect (x, y, w, h: Integer; a: Integer);
-procedure fillRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
-function drawText6 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
-function drawText8 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
-function drawText6Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
-function drawText8Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+procedure fillRect (x, y, w, h: Integer; constref clr: TGxRGBA);
+function drawText6 (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
+function drawText8 (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
+function drawText6Prop (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
+function drawText8Prop (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
// x-centered at `x`
-function drawText6XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
-function drawText8XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
-function drawText6PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
-function drawText8PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText6XC (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
+function drawText8XC (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
+function drawText6PropXC (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
+function drawText8PropXC (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
// ////////////////////////////////////////////////////////////////////////// //
result := true;
end;
+// returns `false` if the color is transparent
+function setupGLColor (constref clr: TGxRGBA): Boolean;
+begin
+ if (clr.a < 255) then
+ begin
+ if (clr.a = 0) then begin result := false; exit; end;
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ end
+ else
+ begin
+ glDisable(GL_BLEND);
+ end;
+ glColor4ub(clr.r, clr.g, clr.b, clr.a);
+ result := true;
+end;
+
function isScaled (): Boolean;
var
mt: packed array [0..15] of Double;
// return width (including last empty pixel)
-function drawTextInternal (wdt, x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer; tid: GLuint; constref fontwdt: array of Byte; prop: Boolean): Integer;
+function drawTextInternal (wdt, x, y: Integer; const s: AnsiString; constref clr: TGxRGBA; tid: GLuint; constref fontwdt: array of Byte; prop: Boolean): Integer;
var
f, c: Integer;
tx, ty: Integer;
begin
result := 0;
if (Length(s) = 0) then exit;
- if not setupGLColor(r, g, b, a) then exit;
+ if not setupGLColor(clr) then exit;
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_NOTEQUAL, 0.0);
// ////////////////////////////////////////////////////////////////////////// //
-procedure drawHLine (x, y, len: Integer; r, g, b: Integer; a: Integer=255);
+procedure drawHLine (x, y, len: Integer; constref clr: TGxRGBA);
begin
if (len < 1) then exit;
- if not setupGLColor(r, g, b, a) then exit;
+ if not setupGLColor(clr) then exit;
glDisable(GL_TEXTURE_2D);
if (not isScaled) then
begin
end;
-procedure drawVLine (x, y, len: Integer; r, g, b: Integer; a: Integer=255);
+procedure drawVLine (x, y, len: Integer; constref clr: TGxRGBA);
begin
if (len < 1) then exit;
- if not setupGLColor(r, g, b, a) then exit;
+ if not setupGLColor(clr) then exit;
glDisable(GL_TEXTURE_2D);
if (not isScaled) then
begin
end;
-procedure drawLine (x1, y1, x2, y2: Integer; r, g, b: Integer; a: Integer=255);
+procedure drawLine (x1, y1, x2, y2: Integer; constref clr: TGxRGBA);
begin
- if not setupGLColor(r, g, b, a) then exit;
+ if not setupGLColor(clr) then exit;
glDisable(GL_TEXTURE_2D);
end;
-procedure drawRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
+procedure drawRect (x, y, w, h: Integer; constref clr: TGxRGBA);
begin
if (w < 0) or (h < 0) then exit;
- if not setupGLColor(r, g, b, a) then exit;
+ if not setupGLColor(clr) then exit;
glDisable(GL_TEXTURE_2D);
glLineWidth(1);
glDisable(GL_LINE_SMOOTH);
end;
-procedure drawRectUI (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
+procedure drawRectUI (x, y, w, h: Integer; constref clr: TGxRGBA);
procedure hline (x, y, len: Integer);
begin
if (len < 1) then exit;
scaled: Boolean;
begin
if (w < 0) or (h < 0) then exit;
- if not setupGLColor(r, g, b, a) then exit;
+ if not setupGLColor(clr) then exit;
glDisable(GL_TEXTURE_2D);
glLineWidth(1);
glDisable(GL_LINE_SMOOTH);
end;
-procedure fillRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
+procedure fillRect (x, y, w, h: Integer; constref clr: TGxRGBA);
begin
if (w < 0) or (h < 0) then exit;
- if not setupGLColor(r, g, b, a) then exit;
+ if not setupGLColor(clr) then exit;
glDisable(GL_LINE_SMOOTH);
glDisable(GL_POLYGON_SMOOTH);
glDisable(GL_TEXTURE_2D);
// ////////////////////////////////////////////////////////////////////////// //
-function drawText6 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText6 (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
begin
if (font6texid = 0) then createFonts();
- drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, false);
+ drawTextInternal(6, x, y, s, clr, font6texid, kgiFont6PropWidth, false);
result := Length(s)*6;
end;
-function drawText8 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText8 (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
begin
if (font8texid = 0) then createFonts();
- drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, false);
+ drawTextInternal(8, x, y, s, clr, font8texid, kgiFont8PropWidth, false);
result := Length(s)*8;
end;
-function drawText6Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText6Prop (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
begin
if (prfont6texid = 0) then createFonts();
- result := drawTextInternal(6, x, y, s, r, g, b, a, prfont6texid, kgiFont6PropWidth, true);
+ result := drawTextInternal(6, x, y, s, clr, prfont6texid, kgiFont6PropWidth, true);
end;
-function drawText8Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText8Prop (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
begin
if (prfont8texid = 0) then createFonts();
- result := drawTextInternal(8, x, y, s, r, g, b, a, prfont8texid, kgiFont8PropWidth, true);
+ result := drawTextInternal(8, x, y, s, clr, prfont8texid, kgiFont8PropWidth, true);
end;
// ////////////////////////////////////////////////////////////////////////// //
// x-centered at `x`
-function drawText6XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText6XC (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
begin
if (font6texid = 0) then createFonts();
x -= Length(s)*6 div 2;
- drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, false);
+ drawTextInternal(6, x, y, s, clr, font6texid, kgiFont6PropWidth, false);
result := Length(s)*6;
end;
-function drawText8XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText8XC (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
begin
if (font8texid = 0) then createFonts();
x -= Length(s)*8 div 2;
- drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, false);
+ drawTextInternal(8, x, y, s, clr, font8texid, kgiFont8PropWidth, false);
result := Length(s)*8;
end;
-function drawText6PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText6PropXC (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
begin
if (prfont6texid = 0) then createFonts();
x -= textWidth6(s) div 2;
- result := drawTextInternal(6, x, y, s, r, g, b, a, prfont6texid, kgiFont6PropWidth, true);
+ result := drawTextInternal(6, x, y, s, clr, prfont6texid, kgiFont6PropWidth, true);
end;
-function drawText8PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
+function drawText8PropXC (x, y: Integer; const s: AnsiString; constref clr: TGxRGBA): Integer;
begin
if (prfont8texid = 0) then createFonts();
x -= textWidth8(s) div 2;
- result := drawTextInternal(8, x, y, s, r, g, b, a, prfont8texid, kgiFont8PropWidth, true);
+ result := drawTextInternal(8, x, y, s, clr, prfont8texid, kgiFont8PropWidth, true);
end;