DEADSOFTWARE

simple UI subsystem for Holmes (yay, now we have two!)
[d2df-sdl.git] / src / game / g_holmes.inc
1 (* Copyright (C) DooM 2D:Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 // ////////////////////////////////////////////////////////////////////////// //
17 // cursor (hi, Death Track!)
18 const curWidth = 17;
19 const curHeight = 23;
21 const cursorImg: array[0..curWidth*curHeight-1] of Byte = (
22 0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
23 0,0,3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,
24 1,0,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,
25 1,1,3,3,2,2,0,0,0,0,0,0,0,0,0,0,0,
26 1,1,3,3,4,2,2,0,0,0,0,0,0,0,0,0,0,
27 1,1,3,3,4,4,2,2,0,0,0,0,0,0,0,0,0,
28 1,1,3,3,4,4,4,2,2,0,0,0,0,0,0,0,0,
29 1,1,3,3,4,4,4,4,2,2,0,0,0,0,0,0,0,
30 1,1,3,3,4,4,4,5,6,2,2,0,0,0,0,0,0,
31 1,1,3,3,4,4,5,6,7,5,2,2,0,0,0,0,0,
32 1,1,3,3,4,5,6,7,5,4,5,2,2,0,0,0,0,
33 1,1,3,3,5,6,7,5,4,5,6,7,2,2,0,0,0,
34 1,1,3,3,6,7,5,4,5,6,7,7,7,2,2,0,0,
35 1,1,3,3,7,5,4,5,6,7,7,7,7,7,2,2,0,
36 1,1,3,3,5,4,5,6,8,8,8,8,8,8,8,8,2,
37 1,1,3,3,4,5,6,3,8,8,8,8,8,8,8,8,8,
38 1,1,3,3,5,6,3,3,1,1,1,1,1,1,1,0,0,
39 1,1,3,3,6,3,3,1,1,1,1,1,1,1,1,0,0,
40 1,1,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,
41 1,1,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,
42 1,1,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,
43 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
44 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
45 );
46 const cursorPal: array[0..9*4-1] of Byte = (
47 0, 0, 0, 0,
48 0, 0, 0,163,
49 85,255,255,255,
50 85, 85,255,255,
51 255, 85, 85,255,
52 170, 0,170,255,
53 85, 85, 85,255,
54 0, 0, 0,255,
55 0, 0,170,255
56 );
59 var
60 curtexid: GLuint = 0;
62 procedure createCursorTexture ();
63 var
64 tex, tpp: PByte;
65 c: Integer;
66 x, y: Integer;
67 begin
68 if (curtexid <> 0) then exit; //begin glDeleteTextures(1, @curtexid); curtexid := 0; end;
70 GetMem(tex, curWidth*curHeight*4);
72 tpp := tex;
73 for y := 0 to curHeight-1 do
74 begin
75 for x := 0 to curWidth-1 do
76 begin
77 c := cursorImg[y*curWidth+x]*4;
78 tpp^ := cursorPal[c+0]; Inc(tpp);
79 tpp^ := cursorPal[c+1]; Inc(tpp);
80 tpp^ := cursorPal[c+2]; Inc(tpp);
81 tpp^ := cursorPal[c+3]; Inc(tpp);
82 end;
83 end;
85 glGenTextures(1, @curtexid);
86 if (curtexid = 0) then raise Exception.Create('can''t create Holmes texture');
88 glBindTexture(GL_TEXTURE_2D, curtexid);
89 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
90 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
91 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
92 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
94 //GLfloat[4] bclr = 0.0;
95 //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
97 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, curWidth, curHeight, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex);
98 glFlush();
100 //FreeMem(tex);
101 end;
104 procedure drawCursor ();
105 begin
106 if (curtexid = 0) then createCursorTexture() else glBindTexture(GL_TEXTURE_2D, curtexid);
107 // blend it
108 glEnable(GL_BLEND);
109 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
110 glEnable(GL_TEXTURE_2D);
111 // color and opacity
112 glColor4f(1, 1, 1, 0.9);
113 Dec(msX, 2);
114 glBegin(GL_QUADS);
115 glTexCoord2f(0.0, 0.0); glVertex2i(msX, msY); // top-left
116 glTexCoord2f(1.0, 0.0); glVertex2i(msX+curWidth, msY); // top-right
117 glTexCoord2f(1.0, 1.0); glVertex2i(msX+curWidth, msY+curHeight); // bottom-right
118 glTexCoord2f(0.0, 1.0); glVertex2i(msX, msY+curHeight); // bottom-left
119 glEnd();
120 Inc(msX, 2);
121 glDisable(GL_BLEND);
122 glDisable(GL_TEXTURE_2D);
123 glColor4f(1, 1, 1, 1);
124 glBindTexture(GL_TEXTURE_2D, 0);
125 end;
128 // ////////////////////////////////////////////////////////////////////////// //
129 // fonts
130 const kgiFont6: array[0..256*8-1] of Byte = (
131 $00,$00,$00,$00,$00,$00,$00,$00,$3c,$42,$a5,$81,$a5,$99,$42,$3c,$3c,$7e,$db,$ff,$ff,$db,$66,$3c,$6c,$fe,
132 $fe,$fe,$7c,$38,$10,$00,$10,$38,$7c,$fe,$7c,$38,$10,$00,$10,$38,$54,$fe,$54,$10,$38,$00,$10,$38,$7c,$fe,
133 $fe,$10,$38,$00,$00,$00,$00,$30,$30,$00,$00,$00,$ff,$ff,$ff,$e7,$e7,$ff,$ff,$ff,$38,$44,$82,$82,$82,$44,
134 $38,$00,$c7,$bb,$7d,$7d,$7d,$bb,$c7,$ff,$0f,$03,$05,$79,$88,$88,$88,$70,$38,$44,$44,$44,$38,$10,$7c,$10,
135 $30,$28,$24,$24,$28,$20,$e0,$c0,$3c,$24,$3c,$24,$24,$e4,$dc,$18,$10,$54,$38,$ee,$38,$54,$10,$00,$10,$10,
136 $10,$7c,$10,$10,$10,$10,$10,$10,$10,$ff,$00,$00,$00,$00,$00,$00,$00,$ff,$10,$10,$10,$10,$10,$10,$10,$f0,
137 $10,$10,$10,$10,$10,$10,$10,$1f,$10,$10,$10,$10,$10,$10,$10,$ff,$10,$10,$10,$10,$10,$10,$10,$10,$10,$10,
138 $10,$10,$00,$00,$00,$ff,$00,$00,$00,$00,$00,$00,$00,$1f,$10,$10,$10,$10,$00,$00,$00,$f0,$10,$10,$10,$10,
139 $10,$10,$10,$1f,$00,$00,$00,$00,$10,$10,$10,$f0,$00,$00,$00,$00,$81,$42,$24,$18,$18,$24,$42,$81,$01,$02,
140 $04,$08,$10,$20,$40,$80,$80,$40,$20,$10,$08,$04,$02,$01,$00,$10,$10,$ff,$10,$10,$00,$00,$00,$00,$00,$00,
141 $00,$00,$00,$00,$20,$20,$20,$20,$00,$00,$20,$00,$50,$50,$50,$00,$00,$00,$00,$00,$50,$50,$f8,$50,$f8,$50,
142 $50,$00,$20,$78,$a0,$70,$28,$f0,$20,$00,$c0,$c8,$10,$20,$40,$98,$18,$00,$40,$a0,$40,$a8,$90,$98,$60,$00,
143 $10,$20,$40,$00,$00,$00,$00,$00,$10,$20,$40,$40,$40,$20,$10,$00,$40,$20,$10,$10,$10,$20,$40,$00,$88,$50,
144 $20,$f8,$20,$50,$88,$00,$00,$20,$20,$f8,$20,$20,$00,$00,$00,$00,$00,$00,$00,$20,$20,$40,$00,$00,$00,$78,
145 $00,$00,$00,$00,$00,$00,$00,$00,$00,$60,$60,$00,$00,$00,$08,$10,$20,$40,$80,$00,$70,$88,$98,$a8,$c8,$88,
146 $70,$00,$20,$60,$a0,$20,$20,$20,$f8,$00,$70,$88,$08,$10,$60,$80,$f8,$00,$70,$88,$08,$30,$08,$88,$70,$00,
147 $10,$30,$50,$90,$f8,$10,$10,$00,$f8,$80,$e0,$10,$08,$10,$e0,$00,$30,$40,$80,$f0,$88,$88,$70,$00,$f8,$88,
148 $10,$20,$20,$20,$20,$00,$70,$88,$88,$70,$88,$88,$70,$00,$70,$88,$88,$78,$08,$10,$60,$00,$00,$00,$20,$00,
149 $00,$20,$00,$00,$00,$00,$20,$00,$00,$20,$20,$40,$18,$30,$60,$c0,$60,$30,$18,$00,$00,$00,$f8,$00,$f8,$00,
150 $00,$00,$c0,$60,$30,$18,$30,$60,$c0,$00,$70,$88,$08,$10,$20,$00,$20,$00,$70,$88,$08,$68,$a8,$a8,$70,$00,
151 $20,$50,$88,$88,$f8,$88,$88,$00,$f0,$48,$48,$70,$48,$48,$f0,$00,$30,$48,$80,$80,$80,$48,$30,$00,$e0,$50,
152 $48,$48,$48,$50,$e0,$00,$f8,$80,$80,$f0,$80,$80,$f8,$00,$f8,$80,$80,$f0,$80,$80,$80,$00,$70,$88,$80,$b8,
153 $88,$88,$70,$00,$88,$88,$88,$f8,$88,$88,$88,$00,$70,$20,$20,$20,$20,$20,$70,$00,$38,$10,$10,$10,$90,$90,
154 $60,$00,$88,$90,$a0,$c0,$a0,$90,$88,$00,$80,$80,$80,$80,$80,$80,$f8,$00,$88,$d8,$a8,$a8,$88,$88,$88,$00,
155 $88,$c8,$c8,$a8,$98,$98,$88,$00,$70,$88,$88,$88,$88,$88,$70,$00,$f0,$88,$88,$f0,$80,$80,$80,$00,$70,$88,
156 $88,$88,$a8,$90,$68,$00,$f0,$88,$88,$f0,$a0,$90,$88,$00,$70,$88,$80,$70,$08,$88,$70,$00,$f8,$20,$20,$20,
157 $20,$20,$20,$00,$88,$88,$88,$88,$88,$88,$70,$00,$88,$88,$88,$88,$50,$50,$20,$00,$88,$88,$88,$a8,$a8,$d8,
158 $88,$00,$88,$88,$50,$20,$50,$88,$88,$00,$88,$88,$88,$70,$20,$20,$20,$00,$f8,$08,$10,$20,$40,$80,$f8,$00,
159 $70,$40,$40,$40,$40,$40,$70,$00,$00,$00,$80,$40,$20,$10,$08,$00,$70,$10,$10,$10,$10,$10,$70,$00,$20,$50,
160 $88,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$f8,$00,$40,$20,$10,$00,$00,$00,$00,$00,$00,$00,$70,$08,
161 $78,$88,$78,$00,$80,$80,$b0,$c8,$88,$c8,$b0,$00,$00,$00,$70,$88,$80,$88,$70,$00,$08,$08,$68,$98,$88,$98,
162 $68,$00,$00,$00,$70,$88,$f8,$80,$70,$00,$10,$28,$20,$f8,$20,$20,$20,$00,$00,$00,$68,$98,$98,$68,$08,$70,
163 $80,$80,$f0,$88,$88,$88,$88,$00,$20,$00,$60,$20,$20,$20,$70,$00,$10,$00,$30,$10,$10,$10,$90,$60,$40,$40,
164 $48,$50,$60,$50,$48,$00,$60,$20,$20,$20,$20,$20,$70,$00,$00,$00,$d0,$a8,$a8,$a8,$a8,$00,$00,$00,$b0,$c8,
165 $88,$88,$88,$00,$00,$00,$70,$88,$88,$88,$70,$00,$00,$00,$b0,$c8,$c8,$b0,$80,$80,$00,$00,$68,$98,$98,$68,
166 $08,$08,$00,$00,$b0,$c8,$80,$80,$80,$00,$00,$00,$78,$80,$f0,$08,$f0,$00,$40,$40,$f0,$40,$40,$48,$30,$00,
167 $00,$00,$90,$90,$90,$90,$68,$00,$00,$00,$88,$88,$88,$50,$20,$00,$00,$00,$88,$a8,$a8,$a8,$50,$00,$00,$00,
168 $88,$50,$20,$50,$88,$00,$00,$00,$88,$88,$98,$68,$08,$70,$00,$00,$f8,$10,$20,$40,$f8,$00,$18,$20,$20,$40,
169 $20,$20,$18,$00,$20,$20,$20,$00,$20,$20,$20,$00,$c0,$20,$20,$10,$20,$20,$c0,$00,$40,$a8,$10,$00,$00,$00,
170 $00,$00,$00,$00,$20,$50,$f8,$00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$ff,$f0,$f0,$f0,$f0,$0f,$0f,$0f,$0f,
171 $00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00,$00,$00,$00,$00,$00,$00,$00,$3c,$3c,$00,$00,$00,$ff,$ff,
172 $ff,$ff,$ff,$ff,$00,$00,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$c0,$0f,$0f,$0f,$0f,$f0,$f0,$f0,$f0,$fc,$fc,$fc,$fc,
173 $fc,$fc,$fc,$fc,$03,$03,$03,$03,$03,$03,$03,$03,$3f,$3f,$3f,$3f,$3f,$3f,$3f,$3f,$11,$22,$44,$88,$11,$22,
174 $44,$88,$88,$44,$22,$11,$88,$44,$22,$11,$fe,$7c,$38,$10,$00,$00,$00,$00,$00,$00,$00,$00,$10,$38,$7c,$fe,
175 $80,$c0,$e0,$f0,$e0,$c0,$80,$00,$01,$03,$07,$0f,$07,$03,$01,$00,$ff,$7e,$3c,$18,$18,$3c,$7e,$ff,$81,$c3,
176 $e7,$ff,$ff,$e7,$c3,$81,$f0,$f0,$f0,$f0,$00,$00,$00,$00,$00,$00,$00,$00,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,
177 $00,$00,$00,$00,$00,$00,$00,$00,$f0,$f0,$f0,$f0,$33,$33,$cc,$cc,$33,$33,$cc,$cc,$00,$20,$20,$50,$50,$88,
178 $f8,$00,$20,$20,$70,$20,$70,$20,$20,$00,$00,$00,$00,$50,$88,$a8,$50,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,
179 $00,$00,$00,$00,$ff,$ff,$ff,$ff,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$ff,$ff,
180 $ff,$ff,$00,$00,$00,$00,$00,$00,$68,$90,$90,$90,$68,$00,$30,$48,$48,$70,$48,$48,$70,$c0,$f8,$88,$80,$80,
181 $80,$80,$80,$00,$00,$50,$70,$88,$f8,$80,$70,$00,$00,$00,$78,$80,$f0,$80,$78,$00,$00,$00,$78,$90,$90,$90,
182 $60,$00,$20,$00,$60,$20,$20,$20,$70,$00,$50,$00,$70,$20,$20,$20,$70,$00,$f8,$20,$70,$a8,$a8,$70,$20,$f8,
183 $20,$50,$88,$f8,$88,$50,$20,$00,$70,$88,$88,$88,$50,$50,$d8,$00,$30,$40,$40,$20,$50,$50,$50,$20,$00,$00,
184 $00,$50,$a8,$a8,$50,$00,$08,$70,$a8,$a8,$a8,$70,$80,$00,$38,$40,$80,$f8,$80,$40,$38,$00,$70,$88,$88,$88,
185 $88,$88,$88,$00,$00,$f8,$00,$f8,$00,$f8,$00,$00,$20,$20,$f8,$20,$20,$00,$f8,$00,$c0,$30,$08,$30,$c0,$00,
186 $f8,$00,$50,$f8,$80,$f0,$80,$80,$f8,$00,$78,$80,$80,$f0,$80,$80,$78,$00,$20,$20,$20,$20,$20,$20,$a0,$40,
187 $70,$20,$20,$20,$20,$20,$70,$00,$50,$70,$20,$20,$20,$20,$70,$00,$00,$18,$24,$24,$18,$00,$00,$00,$00,$30,
188 $78,$78,$30,$00,$00,$00,$00,$00,$00,$00,$30,$00,$00,$00,$3e,$20,$20,$20,$a0,$60,$20,$00,$a0,$50,$50,$50,
189 $00,$00,$00,$00,$40,$a0,$20,$40,$e0,$00,$00,$00,$00,$38,$38,$38,$38,$38,$38,$00,$3c,$42,$99,$a1,$a1,$99,
190 $42,$3c,$00,$00,$90,$a8,$e8,$a8,$90,$00,$00,$00,$60,$10,$70,$90,$68,$00,$00,$00,$f0,$80,$f0,$88,$f0,$00,
191 $00,$00,$90,$90,$90,$f8,$08,$00,$00,$00,$30,$50,$50,$70,$88,$00,$00,$00,$70,$88,$f8,$80,$70,$00,$00,$20,
192 $70,$a8,$a8,$70,$20,$00,$00,$00,$78,$48,$40,$40,$40,$00,$00,$00,$88,$50,$20,$50,$88,$00,$00,$00,$88,$98,
193 $a8,$c8,$88,$00,$00,$50,$20,$00,$98,$a8,$c8,$00,$00,$00,$90,$a0,$c0,$a0,$90,$00,$00,$00,$38,$28,$28,$48,
194 $88,$00,$00,$00,$88,$d8,$a8,$88,$88,$00,$00,$00,$88,$88,$f8,$88,$88,$00,$00,$00,$70,$88,$88,$88,$70,$00,
195 $00,$00,$78,$48,$48,$48,$48,$00,$00,$00,$78,$88,$78,$28,$48,$00,$00,$00,$f0,$88,$f0,$80,$80,$00,$00,$00,
196 $78,$80,$80,$80,$78,$00,$00,$00,$f8,$20,$20,$20,$20,$00,$00,$00,$88,$50,$20,$40,$80,$00,$00,$00,$a8,$70,
197 $20,$70,$a8,$00,$00,$00,$f0,$48,$70,$48,$f0,$00,$00,$00,$40,$40,$70,$48,$70,$00,$00,$00,$88,$88,$c8,$a8,
198 $c8,$00,$00,$00,$f0,$08,$70,$08,$f0,$00,$00,$00,$a8,$a8,$a8,$a8,$f8,$00,$00,$00,$70,$88,$38,$88,$70,$00,
199 $00,$00,$a8,$a8,$a8,$f8,$08,$00,$00,$00,$48,$48,$78,$08,$08,$00,$00,$00,$c0,$40,$70,$48,$70,$00,$90,$a8,
200 $a8,$e8,$a8,$a8,$90,$00,$20,$50,$88,$88,$f8,$88,$88,$00,$f8,$88,$80,$f0,$88,$88,$f0,$00,$90,$90,$90,$90,
201 $90,$f8,$08,$00,$38,$28,$28,$48,$48,$f8,$88,$00,$f8,$80,$80,$f0,$80,$80,$f8,$00,$20,$70,$a8,$a8,$a8,$70,
202 $20,$00,$f8,$88,$88,$80,$80,$80,$80,$00,$88,$88,$50,$20,$50,$88,$88,$00,$88,$88,$98,$a8,$c8,$88,$88,$00,
203 $50,$20,$88,$98,$a8,$c8,$88,$00,$88,$90,$a0,$c0,$a0,$90,$88,$00,$18,$28,$48,$48,$48,$48,$88,$00,$88,$d8,
204 $a8,$a8,$88,$88,$88,$00,$88,$88,$88,$f8,$88,$88,$88,$00,$70,$88,$88,$88,$88,$88,$70,$00,$f8,$88,$88,$88,
205 $88,$88,$88,$00,$78,$88,$88,$78,$28,$48,$88,$00,$f0,$88,$88,$f0,$80,$80,$80,$00,$70,$88,$80,$80,$80,$88,
206 $70,$00,$f8,$20,$20,$20,$20,$20,$20,$00,$88,$88,$88,$50,$20,$40,$80,$00,$a8,$a8,$70,$20,$70,$a8,$a8,$00,
207 $f0,$48,$48,$70,$48,$48,$f0,$00,$80,$80,$80,$f0,$88,$88,$f0,$00,$88,$88,$88,$c8,$a8,$a8,$c8,$00,$f0,$08,
208 $08,$30,$08,$08,$f0,$00,$a8,$a8,$a8,$a8,$a8,$a8,$f8,$00,$70,$88,$08,$78,$08,$88,$70,$00,$a8,$a8,$a8,$a8,
209 $a8,$f8,$08,$00,$88,$88,$88,$88,$78,$08,$08,$00,$c0,$40,$40,$70,$48,$48,$70,$00
210 );
212 const kgiFont8: array[0..256*8-1] of Byte = (
213 $00,$00,$00,$00,$00,$00,$00,$00,$7e,$81,$a5,$81,$bd,$99,$81,$7e,$7e,$ff,$db,$ff,$c3,$e7,$ff,$7e,$6c,$fe,
214 $fe,$fe,$7c,$38,$10,$00,$10,$38,$7c,$fe,$7c,$38,$10,$00,$38,$7c,$38,$fe,$fe,$d6,$10,$38,$10,$10,$38,$7c,
215 $fe,$7c,$10,$38,$00,$00,$18,$3c,$3c,$18,$00,$00,$ff,$ff,$e7,$c3,$c3,$e7,$ff,$ff,$00,$3c,$66,$42,$42,$66,
216 $3c,$00,$ff,$c3,$99,$bd,$bd,$99,$c3,$ff,$0f,$07,$0f,$7d,$cc,$cc,$cc,$78,$3c,$66,$66,$66,$3c,$18,$7e,$18,
217 $3f,$33,$3f,$30,$30,$70,$f0,$e0,$7f,$63,$7f,$63,$63,$67,$e6,$c0,$99,$5a,$3c,$e7,$e7,$3c,$5a,$99,$80,$e0,
218 $f8,$fe,$f8,$e0,$80,$00,$02,$0e,$3e,$fe,$3e,$0e,$02,$00,$18,$3c,$7e,$18,$18,$7e,$3c,$18,$66,$66,$66,$66,
219 $66,$00,$66,$00,$7f,$db,$db,$7b,$1b,$1b,$1b,$00,$7e,$c3,$78,$cc,$cc,$78,$8c,$f8,$00,$00,$00,$00,$7e,$7e,
220 $7e,$00,$18,$3c,$7e,$18,$7e,$3c,$18,$ff,$18,$3c,$7e,$18,$18,$18,$18,$00,$18,$18,$18,$18,$7e,$3c,$18,$00,
221 $00,$18,$0c,$fe,$0c,$18,$00,$00,$00,$30,$60,$fe,$60,$30,$00,$00,$00,$00,$c0,$c0,$c0,$fe,$00,$00,$00,$24,
222 $66,$ff,$66,$24,$00,$00,$00,$18,$3c,$7e,$ff,$ff,$00,$00,$00,$ff,$ff,$7e,$3c,$18,$00,$00,$00,$00,$00,$00,
223 $00,$00,$00,$00,$30,$78,$78,$30,$30,$00,$30,$00,$6c,$6c,$6c,$00,$00,$00,$00,$00,$6c,$6c,$fe,$6c,$fe,$6c,
224 $6c,$00,$30,$7c,$c0,$78,$0c,$f8,$30,$00,$00,$c6,$cc,$18,$30,$66,$c6,$00,$38,$6c,$38,$76,$dc,$cc,$76,$00,
225 $60,$60,$c0,$00,$00,$00,$00,$00,$18,$30,$60,$60,$60,$30,$18,$00,$60,$30,$18,$18,$18,$30,$60,$00,$00,$66,
226 $3c,$ff,$3c,$66,$00,$00,$00,$30,$30,$fc,$30,$30,$00,$00,$00,$00,$00,$00,$00,$70,$30,$60,$00,$00,$00,$fc,
227 $00,$00,$00,$00,$00,$00,$00,$00,$00,$30,$30,$00,$06,$0c,$18,$30,$60,$c0,$80,$00,$78,$cc,$dc,$fc,$ec,$cc,
228 $78,$00,$30,$f0,$30,$30,$30,$30,$fc,$00,$78,$cc,$0c,$38,$60,$cc,$fc,$00,$78,$cc,$0c,$38,$0c,$cc,$78,$00,
229 $1c,$3c,$6c,$cc,$fe,$0c,$0c,$00,$fc,$c0,$f8,$0c,$0c,$cc,$78,$00,$38,$60,$c0,$f8,$cc,$cc,$78,$00,$fc,$cc,
230 $0c,$18,$30,$60,$60,$00,$78,$cc,$cc,$78,$cc,$cc,$78,$00,$78,$cc,$cc,$7c,$0c,$18,$70,$00,$00,$00,$30,$30,
231 $00,$30,$30,$00,$00,$00,$30,$30,$00,$70,$30,$60,$18,$30,$60,$c0,$60,$30,$18,$00,$00,$00,$fc,$00,$fc,$00,
232 $00,$00,$60,$30,$18,$0c,$18,$30,$60,$00,$78,$cc,$0c,$18,$30,$00,$30,$00,$7c,$c6,$de,$de,$de,$c0,$78,$00,
233 $30,$78,$cc,$cc,$fc,$cc,$cc,$00,$fc,$66,$66,$7c,$66,$66,$fc,$00,$3c,$66,$c0,$c0,$c0,$66,$3c,$00,$fc,$6c,
234 $66,$66,$66,$6c,$fc,$00,$fe,$62,$68,$78,$68,$62,$fe,$00,$fe,$62,$68,$78,$68,$60,$f0,$00,$3c,$66,$c0,$c0,
235 $ce,$66,$3e,$00,$cc,$cc,$cc,$fc,$cc,$cc,$cc,$00,$78,$30,$30,$30,$30,$30,$78,$00,$1e,$0c,$0c,$0c,$cc,$cc,
236 $78,$00,$e6,$66,$6c,$78,$6c,$66,$e6,$00,$f0,$60,$60,$60,$62,$66,$fe,$00,$c6,$ee,$fe,$d6,$c6,$c6,$c6,$00,
237 $c6,$e6,$f6,$de,$ce,$c6,$c6,$00,$38,$6c,$c6,$c6,$c6,$6c,$38,$00,$fc,$66,$66,$7c,$60,$60,$f0,$00,$78,$cc,
238 $cc,$cc,$dc,$78,$1c,$00,$fc,$66,$66,$7c,$78,$6c,$e6,$00,$78,$cc,$e0,$38,$1c,$cc,$78,$00,$fc,$b4,$30,$30,
239 $30,$30,$78,$00,$cc,$cc,$cc,$cc,$cc,$cc,$fc,$00,$cc,$cc,$cc,$cc,$cc,$78,$30,$00,$c6,$c6,$c6,$d6,$fe,$ee,
240 $c6,$00,$c6,$c6,$6c,$38,$6c,$c6,$c6,$00,$cc,$cc,$cc,$78,$30,$30,$78,$00,$fe,$cc,$98,$30,$62,$c6,$fe,$00,
241 $78,$60,$60,$60,$60,$60,$78,$00,$c0,$60,$30,$18,$0c,$06,$02,$00,$78,$18,$18,$18,$18,$18,$78,$00,$10,$38,
242 $6c,$c6,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$ff,$30,$30,$18,$00,$00,$00,$00,$00,$00,$00,$78,$0c,
243 $7c,$cc,$76,$00,$e0,$60,$7c,$66,$66,$66,$bc,$00,$00,$00,$78,$cc,$c0,$cc,$78,$00,$1c,$0c,$0c,$7c,$cc,$cc,
244 $76,$00,$00,$00,$78,$cc,$fc,$c0,$78,$00,$38,$6c,$60,$f0,$60,$60,$f0,$00,$00,$00,$76,$cc,$cc,$7c,$0c,$f8,
245 $e0,$60,$6c,$76,$66,$66,$e6,$00,$30,$00,$70,$30,$30,$30,$78,$00,$18,$00,$78,$18,$18,$18,$d8,$70,$e0,$60,
246 $66,$6c,$78,$6c,$e6,$00,$70,$30,$30,$30,$30,$30,$78,$00,$00,$00,$ec,$fe,$d6,$c6,$c6,$00,$00,$00,$f8,$cc,
247 $cc,$cc,$cc,$00,$00,$00,$78,$cc,$cc,$cc,$78,$00,$00,$00,$dc,$66,$66,$7c,$60,$f0,$00,$00,$76,$cc,$cc,$7c,
248 $0c,$1e,$00,$00,$d8,$6c,$6c,$60,$f0,$00,$00,$00,$7c,$c0,$78,$0c,$f8,$00,$10,$30,$7c,$30,$30,$34,$18,$00,
249 $00,$00,$cc,$cc,$cc,$cc,$76,$00,$00,$00,$cc,$cc,$cc,$78,$30,$00,$00,$00,$c6,$c6,$d6,$fe,$6c,$00,$00,$00,
250 $c6,$6c,$38,$6c,$c6,$00,$00,$00,$cc,$cc,$cc,$7c,$0c,$f8,$00,$00,$fc,$98,$30,$64,$fc,$00,$1c,$30,$30,$e0,
251 $30,$30,$1c,$00,$18,$18,$18,$00,$18,$18,$18,$00,$e0,$30,$30,$1c,$30,$30,$e0,$00,$76,$dc,$00,$00,$00,$00,
252 $00,$00,$10,$38,$6c,$c6,$c6,$c6,$fe,$00,$78,$cc,$c0,$cc,$78,$18,$0c,$78,$00,$cc,$00,$cc,$cc,$cc,$7e,$00,
253 $1c,$00,$78,$cc,$fc,$c0,$78,$00,$7e,$c3,$3c,$06,$3e,$66,$3f,$00,$cc,$00,$78,$0c,$7c,$cc,$7e,$00,$e0,$00,
254 $78,$0c,$7c,$cc,$7e,$00,$30,$30,$78,$0c,$7c,$cc,$7e,$00,$00,$00,$7c,$c0,$c0,$7c,$06,$3c,$7e,$c3,$3c,$66,
255 $7e,$60,$3c,$00,$cc,$00,$78,$cc,$fc,$c0,$78,$00,$e0,$00,$78,$cc,$fc,$c0,$78,$00,$cc,$00,$70,$30,$30,$30,
256 $78,$00,$7c,$c6,$38,$18,$18,$18,$3c,$00,$e0,$00,$70,$30,$30,$30,$78,$00,$cc,$30,$78,$cc,$cc,$fc,$cc,$00,
257 $30,$30,$00,$78,$cc,$fc,$cc,$00,$1c,$00,$fc,$60,$78,$60,$fc,$00,$00,$00,$7f,$0c,$7f,$cc,$7f,$00,$3e,$6c,
258 $cc,$fe,$cc,$cc,$ce,$00,$78,$cc,$00,$78,$cc,$cc,$78,$00,$00,$cc,$00,$78,$cc,$cc,$78,$00,$00,$e0,$00,$78,
259 $cc,$cc,$78,$00,$78,$cc,$00,$cc,$cc,$cc,$7e,$00,$00,$e0,$00,$cc,$cc,$cc,$7e,$00,$00,$cc,$00,$cc,$cc,$fc,
260 $0c,$f8,$c6,$38,$7c,$c6,$c6,$7c,$38,$00,$cc,$00,$cc,$cc,$cc,$cc,$78,$00,$18,$18,$7e,$c0,$c0,$7e,$18,$18,
261 $38,$6c,$64,$f0,$60,$e6,$fc,$00,$cc,$cc,$78,$fc,$30,$fc,$30,$00,$f0,$d8,$d8,$f4,$cc,$de,$cc,$0e,$0e,$1b,
262 $18,$7e,$18,$18,$d8,$70,$1c,$00,$78,$0c,$7c,$cc,$7e,$00,$38,$00,$70,$30,$30,$30,$78,$00,$00,$1c,$00,$78,
263 $cc,$cc,$78,$00,$00,$1c,$00,$cc,$cc,$cc,$7e,$00,$00,$f8,$00,$f8,$cc,$cc,$cc,$00,$fc,$00,$cc,$ec,$fc,$dc,
264 $cc,$00,$3c,$6c,$6c,$3e,$00,$7e,$00,$00,$3c,$66,$66,$3c,$00,$7e,$00,$00,$30,$00,$30,$60,$c0,$cc,$78,$00,
265 $00,$00,$00,$fc,$c0,$c0,$00,$00,$00,$00,$00,$fc,$0c,$0c,$00,$00,$c6,$cc,$d8,$3e,$63,$ce,$98,$1f,$c6,$cc,
266 $d8,$f3,$67,$cf,$9f,$03,$00,$18,$00,$18,$18,$3c,$3c,$18,$00,$33,$66,$cc,$66,$33,$00,$00,$00,$cc,$66,$33,
267 $66,$cc,$00,$00,$22,$88,$22,$88,$22,$88,$22,$88,$55,$aa,$55,$aa,$55,$aa,$55,$aa,$dc,$76,$dc,$76,$dc,$76,
268 $dc,$76,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$f8,$18,$18,$18,$18,$18,$f8,$18,$f8,$18,$18,$18,
269 $36,$36,$36,$36,$f6,$36,$36,$36,$00,$00,$00,$00,$fe,$36,$36,$36,$00,$00,$f8,$18,$f8,$18,$18,$18,$36,$36,
270 $f6,$06,$f6,$36,$36,$36,$36,$36,$36,$36,$36,$36,$36,$36,$00,$00,$fe,$06,$f6,$36,$36,$36,$36,$36,$f6,$06,
271 $fe,$00,$00,$00,$36,$36,$36,$36,$fe,$00,$00,$00,$18,$18,$f8,$18,$f8,$00,$00,$00,$00,$00,$00,$00,$f8,$18,
272 $18,$18,$18,$18,$18,$18,$1f,$00,$00,$00,$18,$18,$18,$18,$ff,$00,$00,$00,$00,$00,$00,$00,$ff,$18,$18,$18,
273 $18,$18,$18,$18,$1f,$18,$18,$18,$00,$00,$00,$00,$ff,$00,$00,$00,$18,$18,$18,$18,$ff,$18,$18,$18,$18,$18,
274 $1f,$18,$1f,$18,$18,$18,$36,$36,$36,$36,$37,$36,$36,$36,$36,$36,$37,$30,$3f,$00,$00,$00,$00,$00,$3f,$30,
275 $37,$36,$36,$36,$36,$36,$f7,$00,$ff,$00,$00,$00,$00,$00,$ff,$00,$f7,$36,$36,$36,$36,$36,$37,$30,$37,$36,
276 $36,$36,$00,$00,$ff,$00,$ff,$00,$00,$00,$36,$36,$f7,$00,$f7,$36,$36,$36,$18,$18,$ff,$00,$ff,$00,$00,$00,
277 $36,$36,$36,$36,$ff,$00,$00,$00,$00,$00,$ff,$00,$ff,$18,$18,$18,$00,$00,$00,$00,$ff,$36,$36,$36,$36,$36,
278 $36,$36,$3f,$00,$00,$00,$18,$18,$1f,$18,$1f,$00,$00,$00,$00,$00,$1f,$18,$1f,$18,$18,$18,$00,$00,$00,$00,
279 $3f,$36,$36,$36,$36,$36,$36,$36,$f7,$36,$36,$36,$18,$18,$ff,$00,$ff,$18,$18,$18,$18,$18,$18,$18,$f8,$00,
280 $00,$00,$00,$00,$00,$00,$1f,$18,$18,$18,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$00,$00,$00,$00,$ff,$ff,$ff,$ff,
281 $f0,$f0,$f0,$f0,$f0,$f0,$f0,$f0,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$0f,$ff,$ff,$ff,$ff,$00,$00,$00,$00,$00,$00,
282 $76,$dc,$c8,$dc,$76,$00,$00,$78,$cc,$f8,$cc,$f8,$c0,$c0,$00,$fe,$c6,$c0,$c0,$c0,$c0,$00,$00,$fe,$6c,$6c,
283 $6c,$6c,$6c,$00,$fe,$66,$30,$18,$30,$66,$fe,$00,$00,$00,$7e,$cc,$cc,$cc,$78,$00,$00,$66,$66,$66,$66,$7c,
284 $60,$c0,$00,$76,$dc,$18,$18,$18,$18,$00,$fc,$30,$78,$cc,$cc,$78,$30,$fc,$38,$6c,$c6,$fe,$c6,$6c,$38,$00,
285 $38,$6c,$c6,$c6,$6c,$6c,$ee,$00,$1c,$30,$18,$7c,$cc,$cc,$78,$00,$00,$00,$7e,$db,$db,$7e,$00,$00,$06,$0c,
286 $7e,$db,$db,$7e,$60,$c0,$3c,$60,$c0,$fc,$c0,$60,$3c,$00,$78,$cc,$cc,$cc,$cc,$cc,$cc,$00,$00,$fc,$00,$fc,
287 $00,$fc,$00,$00,$30,$30,$fc,$30,$30,$00,$fc,$00,$60,$30,$18,$30,$60,$00,$fc,$00,$18,$30,$60,$30,$18,$00,
288 $fc,$00,$0e,$1b,$1b,$18,$18,$18,$18,$18,$18,$18,$18,$18,$18,$d8,$d8,$70,$30,$30,$00,$fc,$00,$30,$30,$00,
289 $00,$72,$9c,$00,$72,$9c,$00,$00,$38,$6c,$6c,$38,$00,$00,$00,$00,$00,$00,$00,$18,$18,$00,$00,$00,$00,$00,
290 $00,$00,$18,$00,$00,$00,$0f,$0c,$0c,$0c,$ec,$6c,$3c,$1c,$78,$6c,$6c,$6c,$6c,$00,$00,$00,$78,$0c,$38,$60,
291 $7c,$00,$00,$00,$00,$00,$3c,$3c,$3c,$3c,$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
292 );
294 const kgiFont6PropWidth: array[0..256-1] of Byte = (
295 $08,$08,$08,$07,$07,$07,$07,$04,$08,$07,$08,$08,$06,$06,$06,$07,
296 $06,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,
297 $85,$21,$13,$05,$05,$05,$05,$13,$13,$13,$05,$05,$12,$14,$12,$05,
298 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$21,$12,$05,$05,$05,$05,
299 $05,$05,$05,$05,$05,$05,$05,$05,$05,$13,$05,$05,$05,$05,$05,$05,
300 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$13,$05,$13,$05,$05,
301 $13,$05,$05,$05,$05,$05,$05,$05,$05,$13,$04,$14,$13,$05,$05,$05,
302 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$14,$21,$04,$05,$08,
303 $08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$04,
304 $44,$08,$08,$08,$08,$08,$08,$08,$05,$04,$05,$08,$08,$08,$08,$08,
305 $05,$05,$05,$05,$05,$05,$13,$13,$05,$05,$05,$04,$05,$05,$05,$05,
306 $05,$05,$05,$05,$05,$03,$04,$04,$06,$05,$04,$07,$04,$03,$05,$08,
307 $05,$05,$05,$05,$05,$05,$05,$14,$05,$05,$05,$04,$05,$05,$05,$05,
308 $14,$05,$05,$05,$05,$05,$05,$05,$14,$05,$05,$05,$05,$05,$14,$05,
309 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,
310 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05
311 );
313 const kgiFont8PropWidth: array[0..256-1] of Byte = (
314 $08,$08,$08,$07,$07,$07,$07,$06,$08,$07,$08,$08,$07,$08,$08,$08,
315 $07,$07,$07,$07,$08,$08,$07,$08,$07,$07,$07,$07,$07,$08,$08,$08,
316 $85,$14,$15,$07,$06,$07,$07,$03,$14,$14,$08,$06,$13,$06,$22,$07,
317 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$22,$13,$05,$06,$15,$06,
318 $07,$06,$07,$07,$07,$07,$07,$07,$06,$14,$07,$07,$07,$07,$07,$07,
319 $07,$06,$07,$06,$06,$06,$06,$07,$07,$06,$07,$14,$07,$14,$07,$08,
320 $23,$07,$07,$06,$07,$06,$06,$07,$07,$14,$05,$07,$14,$07,$06,$06,
321 $07,$07,$06,$06,$15,$07,$06,$07,$07,$06,$06,$06,$32,$06,$07,$07,
322 $06,$07,$06,$08,$07,$07,$07,$07,$08,$06,$06,$06,$07,$05,$06,$06,
323 $06,$08,$07,$06,$06,$06,$07,$07,$06,$07,$06,$07,$07,$06,$07,$08,
324 $07,$05,$06,$07,$06,$06,$16,$16,$06,$06,$06,$08,$08,$06,$08,$08,
325 $08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,
326 $38,$08,$08,$38,$08,$08,$38,$28,$28,$28,$08,$08,$28,$08,$08,$08,
327 $08,$08,$08,$28,$38,$38,$28,$08,$08,$08,$38,$08,$08,$08,$48,$08,
328 $07,$06,$07,$07,$07,$07,$07,$07,$06,$07,$07,$06,$08,$08,$06,$06,
329 $06,$06,$06,$06,$35,$05,$06,$07,$15,$32,$32,$08,$15,$15,$24,$08
330 );
333 function createFontTexture (constref font: array of Byte; constref fontwdt: array of Byte; prop: Boolean): GLuint;
334 const
335 Width = 16*8;
336 Height = 16*8;
337 var
338 tex, tpp: PByte;
339 b: Byte;
340 cc: Integer;
341 x, y, dx, dy: Integer;
342 begin
343 GetMem(tex, Width*Height*4);
345 for cc := 0 to 255 do
346 begin
347 x := (cc mod 16)*8;
348 y := (cc div 16)*8;
349 for dy := 0 to 7 do
350 begin
351 b := font[cc*8+dy];
352 if prop then b := b shl (fontwdt[cc] shr 4);
353 tpp := tex+((y+dy)*(Width*4))+x*4;
354 for dx := 0 to 7 do
355 begin
356 if ((b and $80) <> 0) then
357 begin
358 tpp^ := 255; Inc(tpp);
359 tpp^ := 255; Inc(tpp);
360 tpp^ := 255; Inc(tpp);
361 tpp^ := 255; Inc(tpp);
362 end
363 else
364 begin
365 tpp^ := 0; Inc(tpp);
366 tpp^ := 0; Inc(tpp);
367 tpp^ := 0; Inc(tpp);
368 tpp^ := 0; Inc(tpp);
369 end;
370 b := (b and $7f) shl 1;
371 end;
372 end;
373 end;
375 glGenTextures(1, @result);
376 if (result = 0) then raise Exception.Create('can''t create Holmes font texture');
378 glBindTexture(GL_TEXTURE_2D, result);
379 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
380 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
381 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
382 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
384 //GLfloat[4] bclr = 0.0;
385 //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
387 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex);
388 glFlush();
390 //FreeMem(tex);
391 end;
394 var
395 font6texid: GLuint = 0;
396 font8texid: GLuint = 0;
397 prfont6texid: GLuint = 0;
398 prfont8texid: GLuint = 0;
400 procedure createFonts ();
401 begin
402 if (font6texid = 0) then font6texid := createFontTexture(kgiFont6, kgiFont6PropWidth, false);
403 if (font8texid = 0) then font8texid := createFontTexture(kgiFont8, kgiFont8PropWidth, true);
404 if (prfont6texid = 0) then prfont6texid := createFontTexture(kgiFont6, kgiFont6PropWidth, false);
405 if (prfont8texid = 0) then prfont8texid := createFontTexture(kgiFont8, kgiFont8PropWidth, true);
406 end;
409 function textWidth6 (const s: AnsiString): Integer;
410 var
411 f: Integer;
412 begin
413 result := 0;
414 for f := 1 to Length(s) do Inc(result, Integer(kgiFont6PropWidth[Integer(s[f])] and $0f)+1);
415 if (result > 0) then Dec(result); // don't count last empty pixel
416 end;
419 function textWidth8 (const s: AnsiString): Integer;
420 var
421 f: Integer;
422 begin
423 result := 0;
424 for f := 1 to Length(s) do Inc(result, Integer(kgiFont8PropWidth[Integer(s[f])] and $0f)+1);
425 if (result > 0) then Dec(result); // don't count last empty pixel
426 end;
429 // return width (including last empty pixel)
430 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;
431 var
432 f, c: Integer;
433 tx, ty: Integer;
434 begin
435 result := 0;
436 if (Length(s) = 0) then exit;
437 if (a < 0) then a := 0 else if (a > 255) then a := 255;
438 if (r < 0) then r := 0 else if (r > 255) then r := 255;
439 if (g < 0) then g := 0 else if (g > 255) then g := 255;
440 if (b < 0) then b := 0 else if (b > 255) then b := 255;
442 if (a < 255) then
443 begin
444 glEnable(GL_BLEND);
445 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
446 end
447 else
448 begin
449 glDisable(GL_BLEND);
450 end;
451 glEnable(GL_ALPHA_TEST);
452 glAlphaFunc(GL_NOTEQUAL, 0.0);
453 glEnable(GL_TEXTURE_2D);
454 // color and opacity
455 glColor4f(r/255.0, g/255.0, b/255.0, a/255.0);
456 glBindTexture(GL_TEXTURE_2D, tid);
458 for f := 1 to Length(s) do
459 begin
460 c := Integer(s[f]) and $ff;
461 tx := (c mod 16)*8;
462 ty := (c div 16)*8;
463 glBegin(GL_QUADS);
464 glTexCoord2f((tx+0)/128.0, (ty+0)/128.0); glVertex2i(x+0, y+0); // top-left
465 glTexCoord2f((tx+8)/128.0, (ty+0)/128.0); glVertex2i(x+8, y+0); // top-right
466 glTexCoord2f((tx+8)/128.0, (ty+8)/128.0); glVertex2i(x+8, y+8); // bottom-right
467 glTexCoord2f((tx+0)/128.0, (ty+8)/128.0); glVertex2i(x+0, y+8); // bottom-left
468 glEnd();
469 if prop then
470 begin
471 x += Integer(fontwdt[c] and $0f)+1;
472 result += Integer(fontwdt[c] and $0f)+1;
473 end
474 else
475 begin
476 x += wdt;
477 result += wdt;
478 end;
479 end;
481 glDisable(GL_ALPHA_TEST);
482 glDisable(GL_BLEND);
483 glDisable(GL_TEXTURE_2D);
484 glColor4f(1, 1, 1, 1);
485 glBindTexture(GL_TEXTURE_2D, 0);
486 end;
489 // ////////////////////////////////////////////////////////////////////////// //
490 procedure drawLine (x1, y1, x2, y2: Integer; r, g, b: Integer; a: Integer=255);
492 procedure lcor (var x1, y1, x2, y2: Integer);
493 begin
494 if (y2 < y1) then
495 begin
496 x1 := x1 xor x2;
497 x2 := x1 xor x2;
498 x1 := x1 xor x2;
500 y1 := y1 xor y2;
501 y2 := y1 xor y2;
502 y1 := y1 xor y2;
503 end;
505 if (x1 < x2) then Inc(X2) else Inc(x1);
506 Inc(y2);
507 end;
509 begin
510 lcor(x1, y1, x2, y2);
512 if (a < 0) then a := 0 else if (a > 255) then a := 255;
513 if (r < 0) then r := 0 else if (r > 255) then r := 255;
514 if (g < 0) then g := 0 else if (g > 255) then g := 255;
515 if (b < 0) then b := 0 else if (b > 255) then b := 255;
517 if (a < 255) then
518 begin
519 glEnable(GL_BLEND);
520 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
521 end
522 else
523 begin
524 glDisable(GL_BLEND);
525 end;
527 glDisable(GL_TEXTURE_2D);
528 glColor4f(r/255.0, g/255.0, b/255.0, a/255.0);
530 glLineWidth(1);
531 glPointSize(1);
533 glBegin(GL_LINES);
534 glVertex2i(x1, y1);
535 glVertex2i(x2, y2);
536 glEnd();
538 glColor4f(1, 1, 1, 1);
539 glDisable(GL_BLEND);
540 end;
543 procedure drawRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
544 begin
545 if (w < 0) or (h < 0) then exit;
546 //if (w = 1) and (h = 1) then begin drawLine(x, y, x, y, r, g, b, a); exit; end;
547 if (a < 0) then a := 0 else if (a > 255) then a := 255;
548 if (r < 0) then r := 0 else if (r > 255) then r := 255;
549 if (g < 0) then g := 0 else if (g > 255) then g := 255;
550 if (b < 0) then b := 0 else if (b > 255) then b := 255;
552 Inc(w);
553 Inc(h);
554 drawLine(x, y, x+w-1, y, r, g, b, a);
555 drawLine(x+w-1, y+1, x+w-1, y+h-1, r, g, b, a);
556 drawLine(x+w-2, y+h-1, x, y+h-1, r, g, b, a);
557 drawLine(x, y+h-2, x, y+1, r, g, b, a);
559 if (a < 255) then
560 begin
561 glEnable(GL_BLEND);
562 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
563 end
564 else
565 begin
566 glDisable(GL_BLEND);
567 end;
568 glDisable(GL_TEXTURE_2D);
569 glLineWidth(1);
570 glDisable(GL_LINE_SMOOTH);
571 glDisable(GL_POLYGON_SMOOTH);
572 glColor4f(r/255.0, g/255.0, b/255.0, a/255.0);
574 glBegin(GL_LINE_LOOP);
575 glVertex2f(x+0.37, y+0.37);
576 glVertex2f(x+w-1+0.37, y+0.37);
577 glVertex2f(x+w-1+0.37, y+h-1);
578 glVertex2f(x+0.37, y+h-1+0.37);
579 glEnd();
581 glBegin(GL_LINES);
582 glVertex2i(x, y); glVertex2i(x+w, y); // top
583 glVertex2i(x, y+h-1); glVertex2i(x+w, y+h-1); // bottom
584 glVertex2f(x+0.37, y+1); glVertex2f(x+0.37, y+h-1); // left
585 glVertex2f(x+w-1+0.37, y+1); glVertex2f(x+w-1+0.37, y+h-1); // right
586 glEnd();
587 //glRect(x, y, x+w, y+h);
588 glColor4f(1, 1, 1, 1);
589 glDisable(GL_BLEND);
590 end;
593 procedure darkenRect (x, y, w, h: Integer; a: Integer);
594 begin
595 if (w < 0) or (h < 0) then exit;
596 if (a < 0) then a := 0;
597 if (a > 255) then a := 255;
598 glEnable(GL_BLEND);
599 glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
600 glDisable(GL_LINE_SMOOTH);
601 glDisable(GL_POLYGON_SMOOTH);
602 glDisable(GL_TEXTURE_2D);
603 glColor4f(0.0, 0.0, 0.0, a/255.0);
604 glBegin(GL_QUADS);
605 glVertex2i(x, y);
606 glVertex2i(x+w, y);
607 glVertex2i(x+w, y+h);
608 glVertex2i(x, y+h);
609 glEnd();
610 //glRect(x, y, x+w, y+h);
611 glColor4f(1, 1, 1, 1);
612 glDisable(GL_BLEND);
613 //glBlendEquation(GL_FUNC_ADD);
614 end;
617 procedure fillRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
618 begin
619 if (w < 0) or (h < 0) then exit;
620 if (a < 0) then a := 0 else if (a > 255) then a := 255;
621 if (r < 0) then r := 0 else if (r > 255) then r := 255;
622 if (g < 0) then g := 0 else if (g > 255) then g := 255;
623 if (b < 0) then b := 0 else if (b > 255) then b := 255;
624 if (a < 255) then
625 begin
626 glEnable(GL_BLEND);
627 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
628 end
629 else
630 begin
631 glDisable(GL_BLEND);
632 end;
633 glDisable(GL_LINE_SMOOTH);
634 glDisable(GL_POLYGON_SMOOTH);
635 glDisable(GL_TEXTURE_2D);
636 glColor4f(r/255.0, g/255.0, b/255.0, a/255.0);
637 glBegin(GL_QUADS);
638 glVertex2f(x, y);
639 glVertex2f(x+w, y);
640 glVertex2f(x+w, y+h);
641 glVertex2f(x, y+h);
642 glEnd();
643 glColor4f(1, 1, 1, 1);
644 glDisable(GL_BLEND);
645 end;
648 // ////////////////////////////////////////////////////////////////////////// //
649 function drawText6 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
650 begin
651 if (font6texid = 0) then createFonts();
652 drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, false);
653 result := Length(s)*6;
654 end;
656 function drawText8 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
657 begin
658 if (font8texid = 0) then createFonts();
659 drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, false);
660 result := Length(s)*8;
661 end;
663 function drawText6Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
664 begin
665 if (font6texid = 0) then createFonts();
666 result := drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, true);
667 end;
669 function drawText8Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
670 begin
671 if (font8texid = 0) then createFonts();
672 result := drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, true);
673 end;
676 // ////////////////////////////////////////////////////////////////////////// //
677 // x-centered at `x`
678 function drawText6XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
679 begin
680 if (font6texid = 0) then createFonts();
681 x -= Length(s)*6 div 2;
682 drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, false);
683 result := Length(s)*6;
684 end;
686 function drawText8XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
687 begin
688 if (font8texid = 0) then createFonts();
689 x -= Length(s)*8 div 2;
690 drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, false);
691 result := Length(s)*8;
692 end;
694 function drawText6PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
695 begin
696 if (font6texid = 0) then createFonts();
697 x -= textWidth6(s) div 2;
698 result := drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, true);
699 end;
701 function drawText8PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
702 begin
703 if (font8texid = 0) then createFonts();
704 x -= textWidth8(s) div 2;
705 result := drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, true);
706 end;
709 // ////////////////////////////////////////////////////////////////////////// //
710 function monsTypeToString (mt: Byte): AnsiString;
711 begin
712 case mt of
713 MONSTER_NONE: begin result := 'none'; exit; end;
714 MONSTER_DEMON: begin result := 'demon'; exit; end;
715 MONSTER_IMP: begin result := 'imp'; exit; end;
716 MONSTER_ZOMBY: begin result := 'zombie'; exit; end;
717 MONSTER_SERG: begin result := 'serg'; exit; end;
718 MONSTER_CYBER: begin result := 'cyber'; exit; end;
719 MONSTER_CGUN: begin result := 'cgun'; exit; end;
720 MONSTER_BARON: begin result := 'baron'; exit; end;
721 MONSTER_KNIGHT: begin result := 'knight'; exit; end;
722 MONSTER_CACO: begin result := 'caco'; exit; end;
723 MONSTER_SOUL: begin result := 'soul'; exit; end;
724 MONSTER_PAIN: begin result := 'pain'; exit; end;
725 MONSTER_SPIDER: begin result := 'spider'; exit; end;
726 MONSTER_BSP: begin result := 'bsp'; exit; end;
727 MONSTER_MANCUB: begin result := 'mancubus'; exit; end;
728 MONSTER_SKEL: begin result := 'skel'; exit; end;
729 MONSTER_VILE: begin result := 'vile'; exit; end;
730 MONSTER_FISH: begin result := 'fish'; exit; end;
731 MONSTER_BARREL: begin result := 'barrel'; exit; end;
732 MONSTER_ROBO: begin result := 'robo'; exit; end;
733 MONSTER_MAN: begin result := 'man'; exit; end;
734 end;
735 result := 'unknown';
736 end;
739 function monsBehToString (bt: Byte): AnsiString;
740 begin
741 case bt of
742 BH_NORMAL: begin result := 'normal'; exit; end;
743 BH_KILLER: begin result := 'killer'; exit; end;
744 BH_MANIAC: begin result := 'maniac'; exit; end;
745 BH_INSANE: begin result := 'insane'; exit; end;
746 BH_CANNIBAL: begin result := 'cannibal'; exit; end;
747 BH_GOOD: begin result := 'good'; exit; end;
748 end;
749 result := 'unknown';
750 end;
753 function monsStateToString (st: Byte): AnsiString;
754 begin
755 case st of
756 MONSTATE_SLEEP: begin result := 'sleep'; exit; end;
757 MONSTATE_GO: begin result := 'go'; exit; end;
758 MONSTATE_RUN: begin result := 'run'; exit; end;
759 MONSTATE_CLIMB: begin result := 'climb'; exit; end;
760 MONSTATE_DIE: begin result := 'die'; exit; end;
761 MONSTATE_DEAD: begin result := 'dead'; exit; end;
762 MONSTATE_ATTACK: begin result := 'attack'; exit; end;
763 MONSTATE_SHOOT: begin result := 'shoot'; exit; end;
764 MONSTATE_PAIN: begin result := 'pain'; exit; end;
765 MONSTATE_WAIT: begin result := 'wait'; exit; end;
766 MONSTATE_REVIVE: begin result := 'revive'; exit; end;
767 MONSTATE_RUNOUT: begin result := 'runout'; exit; end;
768 end;
769 result := 'unknown';
770 end;