X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgx%2Fglgfx.pas;h=d39d2f087bfd1863693c7685aca40a64a243c09f;hb=4cf7f08ed4f5baf7e0161b87fab446b5b3391154;hp=d6f8763b401724947277acb25e5b7c79d28beb8a;hpb=899e0378b0e0bb66f78a5b3786746c2d5a1108eb;p=d2df-sdl.git diff --git a/src/gx/glgfx.pas b/src/gx/glgfx.pas index d6f8763..d39d2f0 100644 --- a/src/gx/glgfx.pas +++ b/src/gx/glgfx.pas @@ -1,4 +1,5 @@ -(* Copyright (C) DooM 2D:Forever Developers +(* coded by Ketmar // Invisible Vector + * Understanding is not required. Only obedience. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -11,7 +12,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . *) {$INCLUDE ../shared/a_modes.inc} unit glgfx; @@ -61,6 +62,10 @@ type type TKind = (Release, Press, Motion); + private + mEaten: Boolean; + mCancelled: Boolean; + public kind: TKind; // motion, press, release x, y: Integer; // current mouse position @@ -70,9 +75,17 @@ type kstate: Word; // keyboard state (see THKeyEvent); public + procedure intrInit (); inline; // init hidden fields + function press (): Boolean; inline; function release (): Boolean; inline; function motion (): Boolean; inline; + procedure eat (); inline; + procedure cancel (); inline; + + public + property eaten: Boolean read mEaten; + property cancelled: Boolean read mCancelled; end; THKeyEvent = record @@ -88,6 +101,10 @@ type type TKind = (Release, Press); + private + mEaten: Boolean; + mCancelled: Boolean; + public kind: TKind; scan: Word; // SDL_SCANCODE_XXX @@ -97,11 +114,20 @@ type kstate: Word; // keyboard state BEFORE event (i.e. press/release modifications aren't done yet) public + procedure intrInit (); inline; // init hidden fields + function press (): Boolean; inline; function release (): Boolean; inline; + procedure eat (); inline; + procedure cancel (); inline; + + public + property eaten: Boolean read mEaten; + property cancelled: Boolean read mCancelled; end; + // ////////////////////////////////////////////////////////////////////////// // // setup 2D OpenGL mode; will be called automatically in `glInit()` procedure oglSetup2D (winWidth, winHeight: Integer; upsideDown: Boolean=false); @@ -119,7 +145,7 @@ type procedure restore (); // set new scissor rect, bounded by the saved scissor rect - procedure setRect (x, y, w, h: Integer); + procedure combineRect (x, y, w, h: Integer); end; @@ -132,35 +158,36 @@ 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; // ////////////////////////////////////////////////////////////////////////// // // event handlers var - evMouseCB: function (var ev: THMouseEvent): Boolean = nil; // `true`: event eaten - evKeyCB: function (var ev: THKeyEvent): Boolean = nil; // `true`: event eaten + evMouseCB: procedure (var ev: THMouseEvent) = nil; + evKeyCB: procedure (var ev: THKeyEvent) = nil; // ////////////////////////////////////////////////////////////////////////// // @@ -231,12 +258,18 @@ function getModState (): Word; inline; begin result := curModState; end; // ////////////////////////////////////////////////////////////////////////// // +procedure THMouseEvent.intrInit (); inline; begin mEaten := false; mCancelled := false; end; function THMouseEvent.press (): Boolean; inline; begin result := (kind = TKind.Press); end; function THMouseEvent.release (): Boolean; inline; begin result := (kind = TKind.Release); end; function THMouseEvent.motion (): Boolean; inline; begin result := (kind = TKind.Motion); end; +procedure THMouseEvent.eat (); inline; begin mEaten := true; end; +procedure THMouseEvent.cancel (); inline; begin mCancelled := true; end; +procedure THKeyEvent.intrInit (); inline; begin mEaten := false; mCancelled := false; end; function THKeyEvent.press (): Boolean; inline; begin result := (kind = TKind.Press); end; function THKeyEvent.release (): Boolean; inline; begin result := (kind = TKind.Release); end; +procedure THKeyEvent.eat (); inline; begin mEaten := true; end; +procedure THKeyEvent.cancel (); inline; begin mCancelled := true; end; // ////////////////////////////////////////////////////////////////////////// // @@ -289,9 +322,9 @@ begin pos := 1; //while (pos <= Length(s)) and (s[pos] <= ' ') do Inc(pos); if (pos < Length(s)) and ((s[pos] = '+') or (s[pos] = '-') or (s[pos] = '*')) then Inc(pos); - while (pos < Length(s)) do + while (pos <= Length(s)) do begin - if (Length(s)-pos >= 2) and (s[pos+1] = '-') then + if (Length(s)-pos >= 1) and (s[pos+1] = '-') then begin case s[pos] of 'C', 'c': begin if (kmods = 255) then kmods := 0; kmods := kmods or THKeyEvent.ModCtrl; Inc(pos, 2); continue; end; @@ -300,7 +333,7 @@ begin end; break; end; - if (Length(s)-pos >= 4) and ((s[pos+1] = 'M') or (s[pos+1] = 'm')) and ((s[pos+2] = 'B') or (s[pos+1] = 'b')) and (s[pos+3] = '-') then + if (Length(s)-pos >= 3) and (s[pos+3] = '-') and ((s[pos+1] = 'M') or (s[pos+1] = 'm')) and ((s[pos+2] = 'B') or (s[pos+2] = 'b')) then begin case s[pos] of 'L', 'l': begin if (mbuts = 255) then mbuts := 0; mbuts := mbuts or THMouseEvent.Left; Inc(pos, 4); continue; end; @@ -362,13 +395,14 @@ var mbuts: Byte = 255; kname: AnsiString; but: Integer = -1; + modch: AnsiChar = ' '; begin result := false; if (Length(s) > 0) then begin - if (s[1] = '+') then begin if (not ev.press) then exit; end - else if (s[1] = '-') then begin if (not ev.release) then exit; end + if (s[1] = '+') then begin if (not ev.press) then exit; modch := '+'; end + else if (s[1] = '-') then begin if (not ev.release) then exit; modch := '-'; end else if (s[1] = '*') then begin if (not ev.motion) then exit; end else if (not ev.press) then exit; end; @@ -385,6 +419,7 @@ begin if (mbuts = 255) then mbuts := 0; if (kmods = 255) then kmods := 0; if (ev.kstate <> kmods) then exit; + if (modch = '-') then mbuts := mbuts or but else if (modch = '+') then mbuts := mbuts and (not but); result := (ev.bstate = mbuts) and (ev.but = but); end; @@ -414,6 +449,8 @@ begin // checked each time, 'cause `evMouseCB` can be changed from the handler if ((curButState and mask) <> 0) and assigned(evMouseCB) then begin + FillChar(mev, sizeof(mev), 0); + mev.intrInit(); mev.kind := mev.TKind.Release; mev.x := curMsX; mev.y := curMsY; @@ -442,6 +479,8 @@ begin // checked each time, 'cause `evMouseCB` can be changed from the handler if ((curModState and mask) <> 0) and assigned(evKeyCB) then begin + FillChar(kev, sizeof(kev), 0); + kev.intrInit(); kev.kind := kev.TKind.Release; case mask of THKeyEvent.ModCtrl: begin kev.scan := SDL_SCANCODE_LCTRL; kev.sym := SDLK_LCTRL;{arbitrary} end; @@ -487,6 +526,8 @@ begin SDL_KEYDOWN, SDL_KEYUP: begin // fix left/right modifiers + FillChar(kev, sizeof(kev), 0); + kev.intrInit(); if (ev.type_ = SDL_KEYDOWN) then kev.kind := THKeyEvent.TKind.Press else kev.kind := THKeyEvent.TKind.Release; kev.scan := ev.key.keysym.scancode; kev.sym := ev.key.keysym.sym; @@ -512,16 +553,22 @@ begin SDL_SCANCODE_LSHIFT: if (kev.press) then curModState := curModState or THKeyEvent.ModShift else curModState := curModState and (not THKeyEvent.ModShift); end; - if assigned(evKeyCB) then result := evKeyCB(kev); + if assigned(evKeyCB) then + begin + evKeyCB(kev); + result := kev.eaten; + end; end; SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP: begin + FillChar(mev, sizeof(mev), 0); + mev.intrInit(); + if (ev.type_ = SDL_MOUSEBUTTONDOWN) then mev.kind := THMouseEvent.TKind.Press else mev.kind := THMouseEvent.TKind.Release; mev.dx := ev.button.x-curMsX; mev.dy := ev.button.y-curMsY; curMsX := ev.button.x; curMsY := ev.button.y; - if (ev.type_ = SDL_MOUSEBUTTONDOWN) then mev.kind := THMouseEvent.TKind.Press else mev.kind := THMouseEvent.TKind.Release; mev.but := buildBut(ev.button.button); mev.x := curMsX; mev.y := curMsY; @@ -531,37 +578,53 @@ begin begin // ev.button.clicks: Byte if (ev.type_ = SDL_MOUSEBUTTONDOWN) then curButState := curButState or mev.but else curButState := curButState and (not mev.but); - if assigned(evMouseCB) then result := evMouseCB(mev); + if assigned(evMouseCB) then + begin + evMouseCB(mev); + result := mev.eaten; + end; end; end; SDL_MOUSEWHEEL: begin if (ev.wheel.y <> 0) then begin + FillChar(mev, sizeof(mev), 0); + mev.intrInit(); + mev.kind := THMouseEvent.TKind.Press; mev.dx := 0; mev.dy := ev.wheel.y; - mev.kind := THMouseEvent.TKind.Press; if (ev.wheel.y < 0) then mev.but := THMouseEvent.WheelUp else mev.but := THMouseEvent.WheelDown; mev.x := curMsX; mev.y := curMsY; mev.bstate := curButState; mev.kstate := curModState; - if assigned(evMouseCB) then result := evMouseCB(mev); + if assigned(evMouseCB) then + begin + evMouseCB(mev); + result := mev.eaten; + end; end; end; SDL_MOUSEMOTION: begin + FillChar(mev, sizeof(mev), 0); + mev.intrInit(); + mev.kind := THMouseEvent.TKind.Motion; mev.dx := ev.button.x-curMsX; mev.dy := ev.button.y-curMsY; curMsX := ev.button.x; curMsY := ev.button.y; - mev.kind := THMouseEvent.TKind.Motion; mev.but := 0; mev.x := curMsX; mev.y := curMsY; mev.bstate := curButState; mev.kstate := curModState; - if assigned(evMouseCB) then result := evMouseCB(mev); + if assigned(evMouseCB) then + begin + evMouseCB(mev); + result := mev.eaten; + end; end; { @@ -1063,7 +1126,7 @@ 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); + if enableScissoring and (not wassc) then glEnable(GL_SCISSOR_TEST); end; procedure TScissorSave.restore (); @@ -1072,30 +1135,44 @@ begin if wassc then glEnable(GL_SCISSOR_TEST) else glDisable(GL_SCISSOR_TEST); end; -procedure TScissorSave.setRect (x, y, w, h: Integer); +procedure TScissorSave.combineRect (x, y, w, h: Integer); +//var ox, oy, ow, oh: Integer; begin if (w < 1) or (h < 1) then begin glScissor(0, 0, 0, 0); exit; end; y := gScrHeight-(y+h); - if not intersectRect(x, y, w, h, scxywh[0], scxywh[1], scxywh[2], scxywh[3]) then glScissor(0, 0, 0, 0) else glScissor(x, y, w, h); + //ox := x; oy := y; ow := w; oh := h; + if not intersectRect(x, y, w, h, scxywh[0], scxywh[1], scxywh[2], scxywh[3]) then + begin + //writeln('oops: COMBINE: old=(', ox, ',', oy, ')-(', ox+ow-1, ',', oy+oh-1, '); sci: (', scxywh[0], ',', scxywh[1], ')-(', scxywh[0]+scxywh[2]-1, ',', scxywh[1]+scxywh[3]-1, ')'); + //writeln('oops: COMBINE: oldx=<', ox, '-', ox+ow-1, '>; oldy=<', oy, ',', oy+oh-1, '> : scix=<', scxywh[0], '-', scxywh[0]+scxywh[2]-1, '>; sciy=<', scxywh[1], '-', scxywh[1]+scxywh[3]-1, '>'); + glScissor(0, 0, 0, 0); + end + else + begin + glScissor(x, y, w, h); + end; end; //TODO: overflow checks function intersectRect (var x0, y0, w0, h0: Integer; const x1, y1, w1, h1: Integer): Boolean; var ex0, ey0: Integer; + ex1, ey1: Integer; begin result := false; - if (w0 < 1) or (h0 < 1) or (w1 < 1) or (h1 < 1) then exit; + if (w0 < 1) or (h0 < 1) or (w1 < 1) or (h1 < 1) then exit; // at least one rect is null // check for intersection - if (x0+w0 <= x1) or (y0+h0 <= y1) or (x1+w1 <= x0) or (y1+h1 <= y0) then exit; - if (x0 >= x1+w1) or (y0 >= y1+h1) or (x1 >= x0+h0) or (y1 >= y0+h0) then exit; - // ok, intersects ex0 := x0+w0; ey0 := y0+h0; + ex1 := x1+w1; + ey1 := y1+h1; + if (ex0 <= x1) or (ey0 <= y1) or (ex1 <= x0) or (ey1 <= y0) then exit; + if (x0 >= ex1) or (y0 >= ey1) or (x1 >= ex0) or (y1 >= ey0) then exit; + // ok, intersects if (x0 < x1) then x0 := x1; if (y0 < y1) then y0 := y1; - if (ex0 > x1+w1) then ex0 := x1+w1; - if (ey0 > y1+h1) then ey0 := y1+h1; + if (ex0 > ex1) then ex0 := ex1; + if (ey0 > ey1) then ey0 := ey1; w0 := ex0-x0; h0 := ey0-y0; result := (w0 > 0) and (h0 > 0); @@ -1129,6 +1206,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; @@ -1160,14 +1254,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); @@ -1206,13 +1300,14 @@ 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 + glLineWidth(1); glBegin(GL_LINES); glVertex2f(x+0.375, y+0.375); glVertex2f(x+len+0.375, y+0.375); @@ -1230,13 +1325,14 @@ 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 + glLineWidth(1); glBegin(GL_LINES); glVertex2f(x+0.375, y+0.375); glVertex2f(x+0.375, y+len+0.375); @@ -1254,9 +1350,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); @@ -1265,6 +1361,7 @@ begin if (not isScaled) then begin + glLineWidth(1); glBegin(GL_LINES); glVertex2f(x1+0.375, y1+0.375); glVertex2f(x2+0.375, y2+0.375); @@ -1279,6 +1376,7 @@ begin end else begin + glLineWidth(1); glBegin(GL_LINES); glVertex2i(x1, y1); glVertex2i(x2, y2); @@ -1293,10 +1391,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); @@ -1309,6 +1407,7 @@ begin end else begin + glLineWidth(1); glBegin(GL_LINES); glVertex2i(x, y); glVertex2i(x+w, y); // top glVertex2i(x, y+h-1); glVertex2i(x+w, y+h-1); // bottom @@ -1322,7 +1421,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; @@ -1349,7 +1448,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); @@ -1365,6 +1464,7 @@ begin begin if not scaled then begin + glLineWidth(1); glBegin(GL_LINES); glVertex2i(x, y); glVertex2i(x+w, y); // top glVertex2i(x, y+h-1); glVertex2i(x+w, y+h-1); // bottom @@ -1410,10 +1510,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); @@ -1429,63 +1529,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;