hedgewars/uStore.pas
changeset 777 86177328b094
parent 775 23c253aae336
child 780 f45b0e513dfd
equal deleted inserted replaced
776:8fc7e59d9cb4 777:86177328b094
    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: PTexture; 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 DrawRotated(Sprite: TSprite; X, Y: LongInt; Angle: real);
    33 procedure DrawRotated(Sprite: TSprite; X, Y: LongInt; Angle: real);
       
    34 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y: LongInt; Angle: real);
    34 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
    35 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
    35 procedure DrawCentered(X, Top: LongInt; Source: PTexture);
    36 procedure DrawCentered(X, Top: LongInt; Source: PTexture);
    36 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface);
    37 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface);
    37 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Surface: PSDL_Surface);
    38 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Surface: PSDL_Surface);
    38 function  RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture;
    39 function  RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture;
   160 
   161 
   161     procedure MakeCrossHairs;
   162     procedure MakeCrossHairs;
   162     var t: LongInt;
   163     var t: LongInt;
   163         tmpsurf, texsurf: PSDL_Surface;
   164         tmpsurf, texsurf: PSDL_Surface;
   164         s: string;
   165         s: string;
   165         Color: Longword;
   166         Color, i: Longword;
   166     begin
   167     begin
   167     s:= Pathz[ptGraphics] + '/' + cCHFileName;
   168     s:= Pathz[ptGraphics] + '/' + cCHFileName;
   168     tmpsurf:= LoadImage(s, true, true, false);
   169     tmpsurf:= LoadImage(s, true, true, false);
   169 
   170 
   170     for t:= 0 to Pred(TeamsCount) do
   171     for t:= 0 to Pred(TeamsCount) do
   176       Color:= Clan^.Color;
   177       Color:= Clan^.Color;
   177       Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF);
   178       Color:= SDL_MapRGB(texsurf^.format, Color shr 16, Color shr 8, Color and $FF);
   178       SDL_FillRect(texsurf, nil, Color);
   179       SDL_FillRect(texsurf, nil, Color);
   179 
   180 
   180       SDL_UpperBlit(tmpsurf, nil, texsurf, nil);
   181       SDL_UpperBlit(tmpsurf, nil, texsurf, nil);
   181       TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
   182 
       
   183       TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Ooops', true);
       
   184 
       
   185       if SDL_MustLock(texsurf) then
       
   186          SDLTry(SDL_LockSurface(texsurf) >= 0, true);
       
   187 
       
   188       // make black pixel be alpha-transparent
       
   189       for i:= 0 to texsurf^.w * texsurf^.h - 1 do
       
   190           if PLongwordArray(texsurf^.pixels)^[i] = $FF000000 then PLongwordArray(texsurf^.pixels)^[i]:= 0;
       
   191 
       
   192       if SDL_MustLock(texsurf) then
       
   193          SDL_UnlockSurface(texsurf);
   182 
   194 
   183       CrosshairTex:= Surface2Tex(texsurf);
   195       CrosshairTex:= Surface2Tex(texsurf);
   184       SDL_FreeSurface(texsurf)
   196       SDL_FreeSurface(texsurf)
   185       end;
   197       end;
   186 
   198 
   367 end;
   379 end;
   368 
   380 
   369 procedure DrawRotated(Sprite: TSprite; X, Y: LongInt; Angle: real);
   381 procedure DrawRotated(Sprite: TSprite; X, Y: LongInt; Angle: real);
   370 var hw, hh: LongInt;
   382 var hw, hh: LongInt;
   371 begin
   383 begin
       
   384 DrawRotatedTex(SpritesData[Sprite].Texture,
       
   385                SpritesData[Sprite].Width,
       
   386                SpritesData[Sprite].Height,
       
   387                X, Y, Angle)
       
   388 end;
       
   389 
       
   390 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y: LongInt; Angle: real);
       
   391 begin
   372 glPushMatrix;
   392 glPushMatrix;
   373 glTranslatef(X, Y, 0);
   393 glTranslatef(X, Y, 0);
   374 glRotatef(Angle, 0, 0, 1);
   394 glRotatef(Angle, 0, 0, 1);
   375 
   395 
   376 hw:= SpritesData[Sprite].Width;
   396 glBindTexture(GL_TEXTURE_2D, Tex^.id);
   377 hh:= SpritesData[Sprite].Height;
       
   378 
       
   379 glBindTexture(GL_TEXTURE_2D, SpritesData[Sprite].Texture^.id);
       
   380 
   397 
   381 glBegin(GL_QUADS);
   398 glBegin(GL_QUADS);
   382 
   399 
   383 glTexCoord2f(0, 0);
   400 glTexCoord2f(0, 0);
   384 glVertex2i(-hw, -hh);
   401 glVertex2i(-hw, -hh);