49 procedure StoreRelease; |
49 procedure StoreRelease; |
50 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); |
50 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); |
51 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
51 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
52 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
52 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
53 procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
53 procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
54 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); |
54 procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat = 1.0); |
55 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
55 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
56 procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
56 procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
57 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
57 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
58 procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
58 procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
59 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
59 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
248 if flagsurf = nil then |
248 if flagsurf = nil then |
249 flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone); |
249 flagsurf:= LoadImage(Pathz[ptFlags] + '/hedgewars', ifNone); |
250 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
250 TryDo(flagsurf <> nil, 'Failed to load flag "' + Flag + '" as well as the default flag', true); |
251 copyToXY(flagsurf, texsurf, 2, 2); |
251 copyToXY(flagsurf, texsurf, 2, 2); |
252 SDL_FreeSurface(flagsurf); |
252 SDL_FreeSurface(flagsurf); |
|
253 flagsurf:= nil; |
253 |
254 |
254 // restore black border pixels inside the flag |
255 // restore black border pixels inside the flag |
255 PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; |
256 PLongwordArray(texsurf^.pixels)^[32 * 2 + 2]:= cNearBlackColor; |
256 PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; |
257 PLongwordArray(texsurf^.pixels)^[32 * 2 + 23]:= cNearBlackColor; |
257 PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; |
258 PLongwordArray(texsurf^.pixels)^[32 * 16 + 2]:= cNearBlackColor; |
258 PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor; |
259 PLongwordArray(texsurf^.pixels)^[32 * 16 + 23]:= cNearBlackColor; |
259 |
260 |
260 FlagTex:= Surface2Tex(texsurf, false); |
261 FlagTex:= Surface2Tex(texsurf, false); |
261 SDL_FreeSurface(texsurf); |
262 SDL_FreeSurface(texsurf); |
262 texsurf:= nil; |
|
263 |
263 |
264 dec(drY, r.h + 2); |
264 dec(drY, r.h + 2); |
265 DrawHealthY:= drY; |
265 DrawHealthY:= drY; |
266 for i:= 0 to 7 do |
266 for i:= 0 to 7 do |
267 with Hedgehogs[i] do |
267 with Hedgehogs[i] do |
272 begin |
272 begin |
273 if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then |
273 if (Length(Hat) > 39) and (Copy(Hat,1,8) = 'Reserved') and (Copy(Hat,9,32) = PlayerHash) then |
274 texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone) |
274 texsurf:= LoadImage(Pathz[ptHats] + '/Reserved/' + Copy(Hat,9,Length(s)-8), ifNone) |
275 else |
275 else |
276 texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone); |
276 texsurf:= LoadImage(Pathz[ptHats] + '/' + Hat, ifNone); |
277 if texsurf <> nil then |
277 if texsurf <> nil then |
278 begin |
278 begin |
279 HatTex:= Surface2Tex(texsurf, true); |
279 HatTex:= Surface2Tex(texsurf, true); |
280 SDL_FreeSurface(texsurf) |
280 SDL_FreeSurface(texsurf) |
281 end |
281 end; |
|
282 texsurf:= nil; |
282 end |
283 end |
283 end; |
284 end; |
284 end; |
285 end; |
285 MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical); |
286 MissionIcons:= LoadImage(Pathz[ptGraphics] + '/missions', ifCritical); |
286 iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask); |
287 iconsurf:= SDL_CreateRGBSurface(SDL_SWSURFACE, 28, 28, 32, RMask, GMask, BMask, AMask); |
287 if iconsurf <> nil then |
288 if iconsurf <> nil then |
288 begin |
289 begin |
289 r.x:= 0; |
290 r.x:= 0; |
290 r.y:= 0; |
291 r.y:= 0; |
291 r.w:= 28; |
292 r.w:= 28; |
292 r.h:= 28; |
293 r.h:= 28; |
293 DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true); |
294 DrawRoundRect(@r, cWhiteColor, cNearBlackColor, iconsurf, true); |
294 ropeIconTex:= Surface2Tex(iconsurf, false); |
295 ropeIconTex:= Surface2Tex(iconsurf, false); |
295 SDL_FreeSurface(iconsurf) |
296 SDL_FreeSurface(iconsurf); |
|
297 iconsurf:= nil; |
296 end; |
298 end; |
297 end; |
299 end; |
298 |
300 |
299 procedure MakeCrossHairs; |
301 procedure MakeCrossHairs; |
300 var t: LongInt; |
302 var t: LongInt; |
522 |
524 |
523 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
525 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
524 glDisableClientState(GL_VERTEX_ARRAY) |
526 glDisableClientState(GL_VERTEX_ARRAY) |
525 end; |
527 end; |
526 |
528 |
527 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); |
529 procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat); |
528 begin |
530 begin |
529 glPushMatrix; |
531 glPushMatrix; |
530 glTranslatef(X, Y, 0); |
532 glTranslatef(X, Y, 0); |
|
533 glScalef(Scale, Scale, 1); |
531 |
534 |
532 glBindTexture(GL_TEXTURE_2D, Texture^.id); |
535 glBindTexture(GL_TEXTURE_2D, Texture^.id); |
533 |
536 |
534 glEnableClientState(GL_VERTEX_ARRAY); |
537 glEnableClientState(GL_VERTEX_ARRAY); |
535 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
538 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
813 var ii: TSprite; |
816 var ii: TSprite; |
814 begin |
817 begin |
815 for ii:= Low(TSprite) to High(TSprite) do |
818 for ii:= Low(TSprite) to High(TSprite) do |
816 begin |
819 begin |
817 FreeTexture(SpritesData[ii].Texture); |
820 FreeTexture(SpritesData[ii].Texture); |
|
821 SpritesData[ii].Texture:= nil; |
818 if SpritesData[ii].Surface <> nil then |
822 if SpritesData[ii].Surface <> nil then |
819 SDL_FreeSurface(SpritesData[ii].Surface) |
823 SDL_FreeSurface(SpritesData[ii].Surface); |
|
824 SpritesData[ii].Surface:= nil; |
820 end; |
825 end; |
821 SDL_FreeSurface(MissionIcons); |
826 SDL_FreeSurface(MissionIcons); |
822 FreeTexture(ropeIconTex); |
827 FreeTexture(ropeIconTex); |
823 FreeTexture(HHTexture); |
828 FreeTexture(HHTexture); |
824 end; |
829 end; |