From: Ketmar Dark Date: Mon, 25 Sep 2017 22:00:09 +0000 (+0300) Subject: Holmes: gxlib API change X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=cd4267cdb40a9994eec9b093c45f711b2fa6d259;p=d2df-sdl.git Holmes: gxlib API change --- diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas index 94e6171..53b7c73 100644 --- a/src/game/g_holmes.pas +++ b/src/game/g_holmes.pas @@ -702,11 +702,11 @@ var 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 @@ -737,12 +737,12 @@ procedure plrDebugDraw (); 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; @@ -756,7 +756,7 @@ procedure plrDebugDraw (); 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; @@ -774,25 +774,25 @@ procedure plrDebugDraw (); 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); @@ -800,7 +800,7 @@ procedure plrDebugDraw (); //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; @@ -808,7 +808,7 @@ procedure plrDebugDraw (); 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; @@ -851,10 +851,10 @@ procedure plrDebugDraw (); 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; @@ -868,14 +868,14 @@ procedure plrDebugDraw (); 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; @@ -897,18 +897,18 @@ procedure plrDebugDraw (); 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(); @@ -934,7 +934,7 @@ procedure plrDebugDraw (); 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); @@ -948,21 +948,21 @@ procedure plrDebugDraw (); 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; @@ -986,12 +986,12 @@ procedure plrDebugDraw (); 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; @@ -1030,7 +1030,7 @@ procedure plrDebugDraw (); 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; @@ -1100,7 +1100,7 @@ begin 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 8875f7d..85a4a5f 100644 --- a/src/gx/gh_ui.pas +++ b/src/gx/gh_ui.pas @@ -1436,7 +1436,7 @@ end; 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; @@ -1449,24 +1449,24 @@ var 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; @@ -1624,15 +1624,15 @@ begin 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; @@ -1695,25 +1695,25 @@ begin 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; @@ -1858,15 +1858,15 @@ begin 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; @@ -1940,13 +1940,12 @@ procedure THCtlLine.drawControl (gx, gy: Integer); 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; @@ -2012,8 +2011,8 @@ var 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 @@ -2025,7 +2024,7 @@ 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 5fa57e7..84bbe53 100644 --- 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; // ////////////////////////////////////////////////////////////////////////// // @@ -1143,6 +1144,23 @@ begin 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; @@ -1174,14 +1192,14 @@ end; // 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); @@ -1220,10 +1238,10 @@ end; // ////////////////////////////////////////////////////////////////////////// // -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 @@ -1244,10 +1262,10 @@ 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 @@ -1268,9 +1286,9 @@ 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); @@ -1307,10 +1325,10 @@ begin 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); @@ -1336,7 +1354,7 @@ begin 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; @@ -1363,7 +1381,7 @@ var 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); @@ -1424,10 +1442,10 @@ begin 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); @@ -1443,63 +1461,63 @@ end; // ////////////////////////////////////////////////////////////////////////// // -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;