DEADSOFTWARE

typo in mapcvt: microseconds -> milliseconds
[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 curTexWidth = 32;
19 const curTexHeight = 32;
20 const curWidth = 17;
21 const curHeight = 23;
23 const cursorImg: array[0..curWidth*curHeight-1] of Byte = (
24 2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
25 3,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
26 3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
27 3,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,
28 3,3,4,2,2,0,0,0,0,0,0,0,0,0,0,0,0,
29 3,3,4,4,2,2,0,0,0,0,0,0,0,0,0,0,0,
30 3,3,4,4,4,2,2,0,0,0,0,0,0,0,0,0,0,
31 3,3,4,4,4,4,2,2,0,0,0,0,0,0,0,0,0,
32 3,3,4,4,4,5,6,2,2,0,0,0,0,0,0,0,0,
33 3,3,4,4,5,6,7,5,2,2,0,0,0,0,0,0,0,
34 3,3,4,5,6,7,5,4,5,2,2,0,0,0,0,0,0,
35 3,3,5,6,7,5,4,5,6,7,2,2,0,0,0,0,0,
36 3,3,6,7,5,4,5,6,7,7,7,2,2,0,0,0,0,
37 3,3,7,5,4,5,6,7,7,7,7,7,2,2,0,0,0,
38 3,3,5,4,5,6,8,8,8,8,8,8,8,8,2,0,0,
39 3,3,4,5,6,3,8,8,8,8,8,8,8,8,8,0,0,
40 3,3,5,6,3,3,0,0,0,0,0,0,0,0,0,0,0,
41 3,3,6,3,3,0,0,0,0,0,0,0,0,0,0,0,0,
42 3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,
43 3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
44 3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
45 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
46 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
47 );
48 const cursorPal: array[0..9*4-1] of Byte = (
49 0, 0, 0, 0,
50 0, 0, 0,163,
51 85,255,255,255,
52 85, 85,255,255,
53 255, 85, 85,255,
54 170, 0,170,255,
55 85, 85, 85,255,
56 0, 0, 0,255,
57 0, 0,170,255
58 );
61 var
62 curtexid: GLuint = 0;
64 procedure createCursorTexture ();
65 var
66 tex, tpp: PByte;
67 c: Integer;
68 x, y: Integer;
69 begin
70 if (curtexid <> 0) then exit; //begin glDeleteTextures(1, @curtexid); curtexid := 0; end;
72 GetMem(tex, curTexWidth*curTexHeight*4);
73 FillChar(tex^, curTexWidth*curTexHeight*4, 0);
75 // draw shadow
76 for y := 0 to curHeight-1 do
77 begin
78 for x := 0 to curWidth-1 do
79 begin
80 if (cursorImg[y*curWidth+x] <> 0) then
81 begin
82 c := 1*4;
83 tpp := tex+((y+1)*(curTexWidth*4)+(x+3)*4);
84 tpp^ := cursorPal[c+0]; Inc(tpp);
85 tpp^ := cursorPal[c+1]; Inc(tpp);
86 tpp^ := cursorPal[c+2]; Inc(tpp);
87 tpp^ := cursorPal[c+3]; Inc(tpp);
88 tpp^ := cursorPal[c+0]; Inc(tpp);
89 tpp^ := cursorPal[c+1]; Inc(tpp);
90 tpp^ := cursorPal[c+2]; Inc(tpp);
91 tpp^ := cursorPal[c+3]; Inc(tpp);
92 end;
93 end;
94 end;
96 // draw cursor
97 for y := 0 to curHeight-1 do
98 begin
99 for x := 0 to curWidth-1 do
100 begin
101 c := cursorImg[y*curWidth+x]*4;
102 if (c <> 0) then
103 begin
104 tpp := tex+(y*(curTexWidth*4)+x*4);
105 tpp^ := cursorPal[c+0]; Inc(tpp);
106 tpp^ := cursorPal[c+1]; Inc(tpp);
107 tpp^ := cursorPal[c+2]; Inc(tpp);
108 tpp^ := cursorPal[c+3]; Inc(tpp);
109 end;
110 end;
111 end;
113 glGenTextures(1, @curtexid);
114 if (curtexid = 0) then raise Exception.Create('can''t create Holmes texture');
116 glBindTexture(GL_TEXTURE_2D, curtexid);
117 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
118 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
119 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
120 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
122 //GLfloat[4] bclr = 0.0;
123 //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
125 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, curTexWidth, curTexHeight, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex);
126 glFlush();
128 //FreeMem(tex);
129 end;
132 procedure drawCursor ();
133 begin
134 if (curtexid = 0) then createCursorTexture() else glBindTexture(GL_TEXTURE_2D, curtexid);
135 // blend it
136 glEnable(GL_BLEND);
137 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
138 glEnable(GL_TEXTURE_2D);
139 // color and opacity
140 glColor4f(1, 1, 1, 0.9);
141 //Dec(msX, 2);
142 glBegin(GL_QUADS);
143 glTexCoord2f(0.0, 0.0); glVertex2i(msX, msY); // top-left
144 glTexCoord2f(1.0, 0.0); glVertex2i(msX+curTexWidth, msY); // top-right
145 glTexCoord2f(1.0, 1.0); glVertex2i(msX+curTexWidth, msY+curTexHeight); // bottom-right
146 glTexCoord2f(0.0, 1.0); glVertex2i(msX, msY+curTexHeight); // bottom-left
147 glEnd();
148 //Inc(msX, 2);
149 glDisable(GL_BLEND);
150 glDisable(GL_TEXTURE_2D);
151 glColor4f(1, 1, 1, 1);
152 glBindTexture(GL_TEXTURE_2D, 0);
153 end;
156 // ////////////////////////////////////////////////////////////////////////// //
157 // fonts
158 const kgiFont6: array[0..256*8-1] of Byte = (
159 $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,
160 $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,
161 $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,
162 $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,
163 $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,
164 $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,
165 $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,
166 $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,
167 $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,
168 $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,
169 $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,
170 $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,
171 $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,
172 $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,
173 $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,
174 $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,
175 $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,
176 $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,
177 $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,
178 $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,
179 $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,
180 $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,
181 $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,
182 $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,
183 $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,
184 $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,
185 $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,
186 $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,
187 $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,
188 $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,
189 $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,
190 $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,
191 $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,
192 $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,
193 $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,
194 $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,
195 $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,
196 $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,
197 $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,
198 $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,
199 $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,
200 $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,
201 $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,
202 $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,
203 $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,
204 $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,
205 $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,
206 $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,
207 $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,
208 $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,
209 $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,
210 $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,
211 $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,
212 $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,
213 $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,
214 $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,
215 $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,
216 $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,
217 $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,
218 $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,
219 $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,
220 $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,
221 $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,
222 $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,
223 $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,
224 $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,
225 $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,
226 $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,
227 $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,
228 $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,
229 $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,
230 $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,
231 $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,
232 $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,
233 $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,
234 $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,
235 $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,
236 $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,
237 $a8,$f8,$08,$00,$88,$88,$88,$88,$78,$08,$08,$00,$c0,$40,$40,$70,$48,$48,$70,$00
238 );
240 const kgiFont8: array[0..256*8-1] of Byte = (
241 $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,
242 $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,
243 $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,
244 $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,
245 $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,
246 $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,
247 $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,
248 $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,
249 $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,
250 $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,
251 $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,
252 $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,
253 $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,
254 $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,
255 $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,
256 $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,
257 $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,
258 $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,
259 $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,
260 $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,
261 $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,
262 $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,
263 $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,
264 $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,
265 $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,
266 $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,
267 $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,
268 $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,
269 $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,
270 $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,
271 $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,
272 $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,
273 $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,
274 $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,
275 $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,
276 $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,
277 $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,
278 $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,
279 $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,
280 $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,
281 $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,
282 $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,
283 $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,
284 $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,
285 $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,
286 $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,
287 $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,
288 $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,
289 $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,
290 $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,
291 $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,
292 $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,
293 $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,
294 $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,
295 $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,
296 $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,
297 $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,
298 $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,
299 $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,
300 $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,
301 $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,
302 $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,
303 $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,
304 $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,
305 $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,
306 $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,
307 $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,
308 $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,
309 $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,
310 $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,
311 $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,
312 $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,
313 $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,
314 $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,
315 $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,
316 $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,
317 $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,
318 $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,
319 $7c,$00,$00,$00,$00,$00,$3c,$3c,$3c,$3c,$00,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
320 );
322 const kgiFont6PropWidth: array[0..256-1] of Byte = (
323 $08,$08,$08,$07,$07,$07,$07,$04,$08,$07,$08,$08,$06,$06,$06,$07,
324 $06,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,
325 $85,$21,$13,$05,$05,$05,$05,$13,$13,$13,$05,$05,$12,$14,$12,$05,
326 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$21,$12,$05,$05,$05,$05,
327 $05,$05,$05,$05,$05,$05,$05,$05,$05,$13,$05,$05,$05,$05,$05,$05,
328 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$13,$05,$13,$05,$05,
329 $13,$05,$05,$05,$05,$05,$05,$05,$05,$13,$04,$14,$13,$05,$05,$05,
330 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$14,$21,$04,$05,$08,
331 $08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$04,
332 $44,$08,$08,$08,$08,$08,$08,$08,$05,$04,$05,$08,$08,$08,$08,$08,
333 $05,$05,$05,$05,$05,$05,$13,$13,$05,$05,$05,$04,$05,$05,$05,$05,
334 $05,$05,$05,$05,$05,$03,$04,$04,$06,$05,$04,$07,$04,$03,$05,$08,
335 $05,$05,$05,$05,$05,$05,$05,$14,$05,$05,$05,$04,$05,$05,$05,$05,
336 $14,$05,$05,$05,$05,$05,$05,$05,$14,$05,$05,$05,$05,$05,$14,$05,
337 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,
338 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$05
339 );
341 const kgiFont8PropWidth: array[0..256-1] of Byte = (
342 $08,$08,$08,$07,$07,$07,$07,$06,$08,$07,$08,$08,$07,$08,$08,$08,
343 $07,$07,$07,$07,$08,$08,$07,$08,$07,$07,$07,$07,$07,$08,$08,$08,
344 $85,$14,$15,$07,$06,$07,$07,$03,$14,$14,$08,$06,$13,$06,$22,$07,
345 $05,$05,$05,$05,$05,$05,$05,$05,$05,$05,$22,$13,$05,$06,$15,$06,
346 $07,$06,$07,$07,$07,$07,$07,$07,$06,$14,$07,$07,$07,$07,$07,$07,
347 $07,$06,$07,$06,$06,$06,$06,$07,$07,$06,$07,$14,$07,$14,$07,$08,
348 $23,$07,$07,$06,$07,$06,$06,$07,$07,$14,$05,$07,$14,$07,$06,$06,
349 $07,$07,$06,$06,$15,$07,$06,$07,$07,$06,$06,$06,$32,$06,$07,$07,
350 $06,$07,$06,$08,$07,$07,$07,$07,$08,$06,$06,$06,$07,$05,$06,$06,
351 $06,$08,$07,$06,$06,$06,$07,$07,$06,$07,$06,$07,$07,$06,$07,$08,
352 $07,$05,$06,$07,$06,$06,$16,$16,$06,$06,$06,$08,$08,$06,$08,$08,
353 $08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,$08,
354 $38,$08,$08,$38,$08,$08,$38,$28,$28,$28,$08,$08,$28,$08,$08,$08,
355 $08,$08,$08,$28,$38,$38,$28,$08,$08,$08,$38,$08,$08,$08,$48,$08,
356 $07,$06,$07,$07,$07,$07,$07,$07,$06,$07,$07,$06,$08,$08,$06,$06,
357 $06,$06,$06,$06,$35,$05,$06,$07,$15,$32,$32,$08,$15,$15,$24,$08
358 );
361 function createFontTexture (constref font: array of Byte; constref fontwdt: array of Byte; prop: Boolean): GLuint;
362 const
363 Width = 16*8;
364 Height = 16*8;
365 var
366 tex, tpp: PByte;
367 b: Byte;
368 cc: Integer;
369 x, y, dx, dy: Integer;
370 begin
371 GetMem(tex, Width*Height*4);
373 for cc := 0 to 255 do
374 begin
375 x := (cc mod 16)*8;
376 y := (cc div 16)*8;
377 for dy := 0 to 7 do
378 begin
379 b := font[cc*8+dy];
380 if prop then b := b shl (fontwdt[cc] shr 4);
381 tpp := tex+((y+dy)*(Width*4))+x*4;
382 for dx := 0 to 7 do
383 begin
384 if ((b and $80) <> 0) then
385 begin
386 tpp^ := 255; Inc(tpp);
387 tpp^ := 255; Inc(tpp);
388 tpp^ := 255; Inc(tpp);
389 tpp^ := 255; Inc(tpp);
390 end
391 else
392 begin
393 tpp^ := 0; Inc(tpp);
394 tpp^ := 0; Inc(tpp);
395 tpp^ := 0; Inc(tpp);
396 tpp^ := 0; Inc(tpp);
397 end;
398 b := (b and $7f) shl 1;
399 end;
400 end;
401 end;
403 glGenTextures(1, @result);
404 if (result = 0) then raise Exception.Create('can''t create Holmes font texture');
406 glBindTexture(GL_TEXTURE_2D, result);
407 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
408 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
409 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
410 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
412 //GLfloat[4] bclr = 0.0;
413 //glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, bclr.ptr);
415 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA{gltt}, GL_UNSIGNED_BYTE, tex);
416 glFlush();
418 //FreeMem(tex);
419 end;
422 var
423 font6texid: GLuint = 0;
424 font8texid: GLuint = 0;
425 prfont6texid: GLuint = 0;
426 prfont8texid: GLuint = 0;
428 procedure createFonts ();
429 begin
430 if (font6texid = 0) then font6texid := createFontTexture(kgiFont6, kgiFont6PropWidth, false);
431 if (font8texid = 0) then font8texid := createFontTexture(kgiFont8, kgiFont8PropWidth, false);
432 if (prfont6texid = 0) then prfont6texid := createFontTexture(kgiFont6, kgiFont6PropWidth, true);
433 if (prfont8texid = 0) then prfont8texid := createFontTexture(kgiFont8, kgiFont8PropWidth, true);
434 end;
437 function textWidth6 (const s: AnsiString): Integer;
438 var
439 f: Integer;
440 begin
441 result := 0;
442 for f := 1 to Length(s) do Inc(result, Integer(kgiFont6PropWidth[Integer(s[f])] and $0f)+1);
443 if (result > 0) then Dec(result); // don't count last empty pixel
444 end;
447 function textWidth8 (const s: AnsiString): Integer;
448 var
449 f: Integer;
450 begin
451 result := 0;
452 for f := 1 to Length(s) do Inc(result, Integer(kgiFont8PropWidth[Integer(s[f])] and $0f)+1);
453 if (result > 0) then Dec(result); // don't count last empty pixel
454 end;
457 // return width (including last empty pixel)
458 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;
459 var
460 f, c: Integer;
461 tx, ty: Integer;
462 begin
463 result := 0;
464 if (Length(s) = 0) then exit;
465 if (a < 0) then a := 0 else if (a > 255) then a := 255;
466 if (r < 0) then r := 0 else if (r > 255) then r := 255;
467 if (g < 0) then g := 0 else if (g > 255) then g := 255;
468 if (b < 0) then b := 0 else if (b > 255) then b := 255;
470 if (a < 255) then
471 begin
472 glEnable(GL_BLEND);
473 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
474 end
475 else
476 begin
477 glDisable(GL_BLEND);
478 end;
479 glEnable(GL_ALPHA_TEST);
480 glAlphaFunc(GL_NOTEQUAL, 0.0);
481 glEnable(GL_TEXTURE_2D);
482 // color and opacity
483 glColor4f(r/255.0, g/255.0, b/255.0, a/255.0);
484 glBindTexture(GL_TEXTURE_2D, tid);
486 for f := 1 to Length(s) do
487 begin
488 c := Integer(s[f]) and $ff;
489 tx := (c mod 16)*8;
490 ty := (c div 16)*8;
491 glBegin(GL_QUADS);
492 glTexCoord2f((tx+0)/128.0, (ty+0)/128.0); glVertex2i(x+0, y+0); // top-left
493 glTexCoord2f((tx+8)/128.0, (ty+0)/128.0); glVertex2i(x+8, y+0); // top-right
494 glTexCoord2f((tx+8)/128.0, (ty+8)/128.0); glVertex2i(x+8, y+8); // bottom-right
495 glTexCoord2f((tx+0)/128.0, (ty+8)/128.0); glVertex2i(x+0, y+8); // bottom-left
496 glEnd();
497 if prop then
498 begin
499 x += Integer(fontwdt[c] and $0f)+1;
500 result += Integer(fontwdt[c] and $0f)+1;
501 end
502 else
503 begin
504 x += wdt;
505 result += wdt;
506 end;
507 end;
509 glDisable(GL_ALPHA_TEST);
510 glDisable(GL_BLEND);
511 glDisable(GL_TEXTURE_2D);
512 glColor4f(1, 1, 1, 1);
513 glBindTexture(GL_TEXTURE_2D, 0);
514 end;
517 // ////////////////////////////////////////////////////////////////////////// //
518 procedure drawLine (x1, y1, x2, y2: Integer; r, g, b: Integer; a: Integer=255);
519 begin
520 if (a < 0) then a := 0 else if (a > 255) then a := 255;
521 if (r < 0) then r := 0 else if (r > 255) then r := 255;
522 if (g < 0) then g := 0 else if (g > 255) then g := 255;
523 if (b < 0) then b := 0 else if (b > 255) then b := 255;
525 if (a < 255) then
526 begin
527 glEnable(GL_BLEND);
528 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
529 end
530 else
531 begin
532 glDisable(GL_BLEND);
533 end;
535 glDisable(GL_TEXTURE_2D);
536 glColor4f(r/255.0, g/255.0, b/255.0, a/255.0);
538 glLineWidth(1);
539 glPointSize(1);
541 glBegin(GL_LINES);
542 glVertex2f(x1+0.37, y1+0.37);
543 glVertex2f(x2+0.37, y2+0.37);
544 glEnd();
546 if (x1 <> x2) or (y1 <> y2) then
547 begin
548 glBegin(GL_POINTS);
549 glVertex2f(x2+0.37, y2+0.37);
550 glEnd();
551 end;
553 glColor4f(1, 1, 1, 1);
554 glDisable(GL_BLEND);
555 end;
558 procedure drawRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
559 begin
560 if (w < 0) or (h < 0) then exit;
561 if (a < 0) then a := 0 else if (a > 255) then a := 255;
562 if (r < 0) then r := 0 else if (r > 255) then r := 255;
563 if (g < 0) then g := 0 else if (g > 255) then g := 255;
564 if (b < 0) then b := 0 else if (b > 255) then b := 255;
565 if (a < 255) then
566 begin
567 glEnable(GL_BLEND);
568 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
569 end
570 else
571 begin
572 glDisable(GL_BLEND);
573 end;
574 glDisable(GL_TEXTURE_2D);
575 glLineWidth(1);
576 glDisable(GL_LINE_SMOOTH);
577 glDisable(GL_POLYGON_SMOOTH);
578 glColor4f(r/255.0, g/255.0, b/255.0, a/255.0);
579 if (w = 1) and (h = 1) then
580 begin
581 glBegin(GL_POINTS);
582 glVertex2f(x+0.37, y+0.37);
583 glEnd();
584 end
585 else
586 begin
587 glBegin(GL_LINES);
588 glVertex2i(x, y); glVertex2i(x+w, y); // top
589 glVertex2i(x, y+h-1); glVertex2i(x+w, y+h-1); // bottom
590 glVertex2f(x+0.37, y+1); glVertex2f(x+0.37, y+h-1); // left
591 glVertex2f(x+w-1+0.37, y+1); glVertex2f(x+w-1+0.37, y+h-1); // right
592 glEnd();
593 end;
594 //glRect(x, y, x+w, y+h);
595 glColor4f(1, 1, 1, 1);
596 glDisable(GL_BLEND);
597 end;
600 procedure darkenRect (x, y, w, h: Integer; a: Integer);
601 begin
602 if (w < 0) or (h < 0) then exit;
603 if (a < 0) then a := 0;
604 if (a > 255) then a := 255;
605 glEnable(GL_BLEND);
606 glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
607 glDisable(GL_LINE_SMOOTH);
608 glDisable(GL_POLYGON_SMOOTH);
609 glDisable(GL_TEXTURE_2D);
610 glColor4f(0.0, 0.0, 0.0, a/255.0);
611 glBegin(GL_QUADS);
612 glVertex2i(x, y);
613 glVertex2i(x+w, y);
614 glVertex2i(x+w, y+h);
615 glVertex2i(x, y+h);
616 glEnd();
617 //glRect(x, y, x+w, y+h);
618 glColor4f(1, 1, 1, 1);
619 glDisable(GL_BLEND);
620 //glBlendEquation(GL_FUNC_ADD);
621 end;
624 procedure fillRect (x, y, w, h: Integer; r, g, b: Integer; a: Integer=255);
625 begin
626 if (w < 0) or (h < 0) then exit;
627 if (a < 0) then a := 0 else if (a > 255) then a := 255;
628 if (r < 0) then r := 0 else if (r > 255) then r := 255;
629 if (g < 0) then g := 0 else if (g > 255) then g := 255;
630 if (b < 0) then b := 0 else if (b > 255) then b := 255;
631 if (a < 255) then
632 begin
633 glEnable(GL_BLEND);
634 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
635 end
636 else
637 begin
638 glDisable(GL_BLEND);
639 end;
640 glDisable(GL_LINE_SMOOTH);
641 glDisable(GL_POLYGON_SMOOTH);
642 glDisable(GL_TEXTURE_2D);
643 glColor4f(r/255.0, g/255.0, b/255.0, a/255.0);
644 glBegin(GL_QUADS);
645 glVertex2f(x, y);
646 glVertex2f(x+w, y);
647 glVertex2f(x+w, y+h);
648 glVertex2f(x, y+h);
649 glEnd();
650 glColor4f(1, 1, 1, 1);
651 glDisable(GL_BLEND);
652 end;
655 // ////////////////////////////////////////////////////////////////////////// //
656 function drawText6 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
657 begin
658 if (font6texid = 0) then createFonts();
659 drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, false);
660 result := Length(s)*6;
661 end;
663 function drawText8 (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
664 begin
665 if (font8texid = 0) then createFonts();
666 drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, false);
667 result := Length(s)*8;
668 end;
670 function drawText6Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
671 begin
672 if (prfont6texid = 0) then createFonts();
673 result := drawTextInternal(6, x, y, s, r, g, b, a, prfont6texid, kgiFont6PropWidth, true);
674 end;
676 function drawText8Prop (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
677 begin
678 if (prfont8texid = 0) then createFonts();
679 result := drawTextInternal(8, x, y, s, r, g, b, a, prfont8texid, kgiFont8PropWidth, true);
680 end;
683 // ////////////////////////////////////////////////////////////////////////// //
684 // x-centered at `x`
685 function drawText6XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
686 begin
687 if (font6texid = 0) then createFonts();
688 x -= Length(s)*6 div 2;
689 drawTextInternal(6, x, y, s, r, g, b, a, font6texid, kgiFont6PropWidth, false);
690 result := Length(s)*6;
691 end;
693 function drawText8XC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
694 begin
695 if (font8texid = 0) then createFonts();
696 x -= Length(s)*8 div 2;
697 drawTextInternal(8, x, y, s, r, g, b, a, font8texid, kgiFont8PropWidth, false);
698 result := Length(s)*8;
699 end;
701 function drawText6PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
702 begin
703 if (prfont6texid = 0) then createFonts();
704 x -= textWidth6(s) div 2;
705 result := drawTextInternal(6, x, y, s, r, g, b, a, prfont6texid, kgiFont6PropWidth, true);
706 end;
708 function drawText8PropXC (x, y: Integer; const s: AnsiString; r, g, b: Integer; a: Integer=255): Integer;
709 begin
710 if (prfont8texid = 0) then createFonts();
711 x -= textWidth8(s) div 2;
712 result := drawTextInternal(8, x, y, s, r, g, b, a, prfont8texid, kgiFont8PropWidth, true);
713 end;
716 // ////////////////////////////////////////////////////////////////////////// //
717 function monsTypeToString (mt: Byte): AnsiString;
718 begin
719 case mt of
720 MONSTER_NONE: begin result := 'none'; exit; end;
721 MONSTER_DEMON: begin result := 'demon'; exit; end;
722 MONSTER_IMP: begin result := 'imp'; exit; end;
723 MONSTER_ZOMBY: begin result := 'zombie'; exit; end;
724 MONSTER_SERG: begin result := 'serg'; exit; end;
725 MONSTER_CYBER: begin result := 'cyber'; exit; end;
726 MONSTER_CGUN: begin result := 'cgun'; exit; end;
727 MONSTER_BARON: begin result := 'baron'; exit; end;
728 MONSTER_KNIGHT: begin result := 'knight'; exit; end;
729 MONSTER_CACO: begin result := 'caco'; exit; end;
730 MONSTER_SOUL: begin result := 'soul'; exit; end;
731 MONSTER_PAIN: begin result := 'pain'; exit; end;
732 MONSTER_SPIDER: begin result := 'spider'; exit; end;
733 MONSTER_BSP: begin result := 'bsp'; exit; end;
734 MONSTER_MANCUB: begin result := 'mancubus'; exit; end;
735 MONSTER_SKEL: begin result := 'skel'; exit; end;
736 MONSTER_VILE: begin result := 'vile'; exit; end;
737 MONSTER_FISH: begin result := 'fish'; exit; end;
738 MONSTER_BARREL: begin result := 'barrel'; exit; end;
739 MONSTER_ROBO: begin result := 'robo'; exit; end;
740 MONSTER_MAN: begin result := 'man'; exit; end;
741 end;
742 result := 'unknown';
743 end;
746 function monsBehToString (bt: Byte): AnsiString;
747 begin
748 case bt of
749 BH_NORMAL: begin result := 'normal'; exit; end;
750 BH_KILLER: begin result := 'killer'; exit; end;
751 BH_MANIAC: begin result := 'maniac'; exit; end;
752 BH_INSANE: begin result := 'insane'; exit; end;
753 BH_CANNIBAL: begin result := 'cannibal'; exit; end;
754 BH_GOOD: begin result := 'good'; exit; end;
755 end;
756 result := 'unknown';
757 end;
760 function monsStateToString (st: Byte): AnsiString;
761 begin
762 case st of
763 MONSTATE_SLEEP: begin result := 'sleep'; exit; end;
764 MONSTATE_GO: begin result := 'go'; exit; end;
765 MONSTATE_RUN: begin result := 'run'; exit; end;
766 MONSTATE_CLIMB: begin result := 'climb'; exit; end;
767 MONSTATE_DIE: begin result := 'die'; exit; end;
768 MONSTATE_DEAD: begin result := 'dead'; exit; end;
769 MONSTATE_ATTACK: begin result := 'attack'; exit; end;
770 MONSTATE_SHOOT: begin result := 'shoot'; exit; end;
771 MONSTATE_PAIN: begin result := 'pain'; exit; end;
772 MONSTATE_WAIT: begin result := 'wait'; exit; end;
773 MONSTATE_REVIVE: begin result := 'revive'; exit; end;
774 MONSTATE_RUNOUT: begin result := 'runout'; exit; end;
775 end;
776 result := 'unknown';
777 end;