25 procedure StoreLoad; |
25 procedure StoreLoad; |
26 procedure StoreRelease; |
26 procedure StoreRelease; |
27 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface); |
27 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface); |
28 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt; Surface: PSDL_Surface); |
28 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt; Surface: PSDL_Surface); |
29 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt; Surface: PSDL_Surface); |
29 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt; Surface: PSDL_Surface); |
30 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: GLuint; Surface: PSDL_Surface); |
30 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture; Surface: PSDL_Surface); |
31 procedure DrawLand (X, Y: LongInt); |
31 procedure DrawLand (X, Y: LongInt); |
32 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); |
32 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); |
33 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface); |
33 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface); |
34 procedure DrawCentered(X, Top: LongInt; Source: PTexture); |
34 procedure DrawCentered(X, Top: LongInt; Source: PTexture); |
35 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface); |
35 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface); |
59 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
59 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
60 var r: TSDL_Rect; |
60 var r: TSDL_Rect; |
61 begin |
61 begin |
62 r:= rect^; |
62 r:= rect^; |
63 if Clear then SDL_FillRect(Surface, @r, 0); |
63 if Clear then SDL_FillRect(Surface, @r, 0); |
|
64 |
|
65 BorderColor:= SDL_MapRGB(Surface^.format, BorderColor shr 16, BorderColor shr 8, BorderColor and $FF); |
|
66 FillColor:= SDL_MapRGB(Surface^.format, FillColor shr 16, FillColor shr 8, FillColor and $FF); |
|
67 |
64 r.y:= rect^.y + 1; |
68 r.y:= rect^.y + 1; |
65 r.h:= rect^.h - 2; |
69 r.h:= rect^.h - 2; |
66 SDL_FillRect(Surface, @r, BorderColor); |
70 SDL_FillRect(Surface, @r, BorderColor); |
67 r.x:= rect^.x + 1; |
71 r.x:= rect^.x + 1; |
68 r.w:= rect^.w - 2; |
72 r.w:= rect^.w - 2; |
130 NameTagTex:= RenderStringTex(TeamName, Clan^.Color, Font); |
135 NameTagTex:= RenderStringTex(TeamName, Clan^.Color, Font); |
131 |
136 |
132 r.w:= cTeamHealthWidth + 5; |
137 r.w:= cTeamHealthWidth + 5; |
133 r.h:= NameTagTex^.h; |
138 r.h:= NameTagTex^.h; |
134 |
139 |
135 HealthSurf:= SDL_CreateRGBSurface(SDL_HWSURFACE, r.w, r.h, cBits, PixelFormat^.RMask, PixelFormat^.GMask, PixelFormat^.BMask, PixelFormat^.AMask); |
140 texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 32, RMask, GMask, BMask, AMask); |
136 TryDo(HealthSurf <> nil, errmsgCreateSurface, true); |
141 TryDo(texsurf <> nil, errmsgCreateSurface, true); |
137 TryDo(SDL_SetColorKey(HealthSurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
142 TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
138 |
143 |
139 DrawRoundRect(@r, cWhiteColor, cColorNearBlack, HealthSurf, true); |
144 DrawRoundRect(@r, cWhiteColor, cColorNearBlack, texsurf, true); |
140 rr:= r; |
145 rr:= r; |
141 inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); |
146 inc(rr.x, 2); dec(rr.w, 4); inc(rr.y, 2); dec(rr.h, 4); |
142 DrawRoundRect(@rr, Clan^.AdjColor, Clan^.AdjColor, HealthSurf, false); |
147 DrawRoundRect(@rr, Clan^.Color, Clan^.Color, texsurf, false); |
|
148 HealthTex:= Surface2Tex(texsurf); |
|
149 SDL_FreeSurface(texsurf); |
143 |
150 |
144 dec(drY, r.h + 2); |
151 dec(drY, r.h + 2); |
145 DrawHealthY:= drY; |
152 DrawHealthY:= drY; |
146 for i:= 0 to 7 do |
153 for i:= 0 to 7 do |
147 with Hedgehogs[i] do |
154 with Hedgehogs[i] do |
150 end; |
157 end; |
151 end; |
158 end; |
152 |
159 |
153 procedure MakeCrossHairs; |
160 procedure MakeCrossHairs; |
154 var t: LongInt; |
161 var t: LongInt; |
155 tmpsurf: PSDL_Surface; |
162 tmpsurf, texsurf: PSDL_Surface; |
156 s: string; |
163 s: string; |
|
164 Color: Longword; |
157 begin |
165 begin |
158 s:= Pathz[ptGraphics] + '/' + cCHFileName; |
166 s:= Pathz[ptGraphics] + '/' + cCHFileName; |
159 tmpsurf:= LoadImage(s, true, true, false); |
167 tmpsurf:= LoadImage(s, true, true, false); |
160 |
168 |
161 for t:= 0 to Pred(TeamsCount) do |
169 for t:= 0 to Pred(TeamsCount) do |
162 with TeamsArray[t]^ do |
170 with TeamsArray[t]^ do |
163 begin |
171 begin |
164 CrosshairSurf:= SDL_CreateRGBSurface(SDL_HWSURFACE, tmpsurf^.w, tmpsurf^.h, cBits, PixelFormat^.RMask, PixelFormat^.GMask, PixelFormat^.BMask, PixelFormat^.AMask); |
172 texsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, tmpsurf^.w, tmpsurf^.h, 32, RMask, GMask, BMask, AMask); |
165 TryDo(CrosshairSurf <> nil, errmsgCreateSurface, true); |
173 TryDo(texsurf <> nil, errmsgCreateSurface, true); |
166 SDL_FillRect(CrosshairSurf, nil, Clan^.AdjColor); |
174 |
167 SDL_UpperBlit(tmpsurf, nil, CrosshairSurf, nil); |
175 Color:= Clan^.Color; |
168 TryDo(SDL_SetColorKey(CrosshairSurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
176 Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF); |
|
177 SDL_FillRect(texsurf, nil, Color); |
|
178 |
|
179 SDL_UpperBlit(tmpsurf, nil, texsurf, nil); |
|
180 TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
|
181 |
|
182 CrosshairTex:= Surface2Tex(texsurf); |
|
183 SDL_FreeSurface(texsurf) |
169 end; |
184 end; |
170 |
185 |
171 SDL_FreeSurface(tmpsurf) |
186 SDL_FreeSurface(tmpsurf) |
172 end; |
187 end; |
173 |
188 |
184 end |
199 end |
185 end; |
200 end; |
186 |
201 |
187 procedure LoadGraves; |
202 procedure LoadGraves; |
188 var t: LongInt; |
203 var t: LongInt; |
|
204 texsurf: PSDL_Surface; |
189 begin |
205 begin |
190 for t:= 0 to Pred(TeamsCount) do |
206 for t:= 0 to Pred(TeamsCount) do |
191 if TeamsArray[t] <> nil then |
207 if TeamsArray[t] <> nil then |
192 with TeamsArray[t]^ do |
208 with TeamsArray[t]^ do |
193 begin |
209 begin |
194 if GraveName = '' then GraveName:= 'Simple'; |
210 if GraveName = '' then GraveName:= 'Simple'; |
195 GraveSurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, false, true, true); |
211 texsurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, false, true, true); |
|
212 GraveTex:= Surface2Tex(texsurf); |
|
213 SDL_FreeSurface(tmpsurf) |
196 end |
214 end |
197 end; |
215 end; |
198 |
216 |
199 procedure GetSkyColor; |
217 procedure GetSkyColor; |
200 // var p: PByteArray; |
218 // var p: PByteArray; |
300 {$ENDIF} |
318 {$ENDIF} |
301 end; |
319 end; |
302 |
320 |
303 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface); |
321 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface); |
304 var rr: TSDL_Rect; |
322 var rr: TSDL_Rect; |
305 t, b: real; |
323 _l, _r, _t, _b: real; |
306 begin |
324 begin |
307 if SourceTexture^.h = 0 then exit; |
325 if SourceTexture^.h = 0 then exit; |
308 rr.x:= X; |
326 rr.x:= X; |
309 rr.y:= Y; |
327 rr.y:= Y; |
310 rr.w:= r^.w; |
328 rr.w:= r^.w; |
311 rr.h:= r^.h; |
329 rr.h:= r^.h; |
312 |
330 |
313 t:= r^.y / SourceTexture^.h; |
331 _l:= r^.x / SourceTexture^.w; |
314 b:= (r^.y + r^.h) / SourceTexture^.h; |
332 _r:= (r^.x + r^.w) / SourceTexture^.w; |
|
333 _t:= r^.y / SourceTexture^.h; |
|
334 _b:= (r^.y + r^.h) / SourceTexture^.h; |
315 |
335 |
316 glBindTexture(GL_TEXTURE_2D, SourceTexture^.id); |
336 glBindTexture(GL_TEXTURE_2D, SourceTexture^.id); |
317 glEnable(GL_TEXTURE_2D); |
337 glEnable(GL_TEXTURE_2D); |
318 |
338 |
319 glBegin(GL_QUADS); |
339 glBegin(GL_QUADS); |
320 |
340 |
321 glTexCoord2f(0, t); |
341 glTexCoord2f(_l, _t); |
322 glVertex2i(X, Y); |
342 glVertex2i(X, Y); |
323 |
343 |
324 glTexCoord2f(1, t); |
344 glTexCoord2f(_r, _t); |
325 glVertex2i(rr.w + X, Y); |
345 glVertex2i(rr.w + X, Y); |
326 |
346 |
327 glTexCoord2f(1, b); |
347 glTexCoord2f(_r, _b); |
328 glVertex2i(rr.w + X, rr.h + Y); |
348 glVertex2i(rr.w + X, rr.h + Y); |
329 |
349 |
330 glTexCoord2f(0, b); |
350 glTexCoord2f(_l, _b); |
331 glVertex2i(X, rr.h + Y); |
351 glVertex2i(X, rr.h + Y); |
332 |
352 |
333 glEnd() |
353 glEnd() |
334 end; |
354 end; |
335 |
355 |
380 r.y:= FrameY * SpritesData[Sprite].Height; |
400 r.y:= FrameY * SpritesData[Sprite].Height; |
381 r.h:= SpritesData[Sprite].Height; |
401 r.h:= SpritesData[Sprite].Height; |
382 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture, Surface) |
402 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture, Surface) |
383 end; |
403 end; |
384 |
404 |
385 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: GLuint; Surface: PSDL_Surface); |
405 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture; Surface: PSDL_Surface); |
386 //var r: TSDL_Rect; |
406 var r: TSDL_Rect; |
387 begin |
407 begin |
388 //r.x:= 0; |
408 r.x:= 0; |
389 //r.w:= Source^.w; |
409 r.w:= Source^.w; |
390 //r.y:= Frame * Height; |
410 r.y:= Frame * Height; |
391 //r.h:= Height; |
411 r.h:= Height; |
392 //DrawFromRect(X, Y, @r, Source, Surface) |
412 DrawFromRect(X, Y, @r, Source, Surface) |
393 end; |
413 end; |
394 |
414 |
395 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface); |
415 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface); |
396 var clr: TSDL_Color; |
416 var clr: TSDL_Color; |
397 tmpsurf: PSDL_Surface; |
417 tmpsurf: PSDL_Surface; |
514 else begin |
534 else begin |
515 WriteLnToConsole(msgFailed); |
535 WriteLnToConsole(msgFailed); |
516 exit(nil) |
536 exit(nil) |
517 end; |
537 end; |
518 |
538 |
519 if setTransparent then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true); |
539 if setTransparent then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); |
520 //if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) |
540 //if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) |
521 // else Result:= SDL_DisplayFormat(tmpsurf); |
541 // else Result:= SDL_DisplayFormat(tmpsurf); |
522 {$IFDEF DEBUGFILE}WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') ');{$ENDIF} |
542 {$IFDEF DEBUGFILE}WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') ');{$ENDIF} |
523 WriteLnToConsole(msgOK); |
543 WriteLnToConsole(msgOK); |
524 LoadImage:= tmpsurf//Result |
544 LoadImage:= tmpsurf//Result |