hedgewars/uStore.pas
changeset 775 23c253aae336
parent 769 788efc1d649f
child 777 86177328b094
equal deleted inserted replaced
774:c2d6476e741f 775:23c253aae336
    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: 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 DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
    34 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
    34 procedure DrawCentered(X, Top: LongInt; Source: PTexture);
    35 procedure DrawCentered(X, Top: LongInt; Source: PTexture);
    35 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface);
    36 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface);
    36 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Surface: PSDL_Surface);
    37 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Surface: PSDL_Surface);
    37 function  RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture;
    38 function  RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture;
   324 _r:= (r^.x + r^.w) / SourceTexture^.w;
   325 _r:= (r^.x + r^.w) / SourceTexture^.w;
   325 _t:= r^.y / SourceTexture^.h;
   326 _t:= r^.y / SourceTexture^.h;
   326 _b:= (r^.y + r^.h) / SourceTexture^.h;
   327 _b:= (r^.y + r^.h) / SourceTexture^.h;
   327 
   328 
   328 glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
   329 glBindTexture(GL_TEXTURE_2D, SourceTexture^.id);
   329 glEnable(GL_TEXTURE_2D);
       
   330 
   330 
   331 glBegin(GL_QUADS);
   331 glBegin(GL_QUADS);
   332 
   332 
   333 glTexCoord2f(_l, _t);
   333 glTexCoord2f(_l, _t);
   334 glVertex2i(X, Y);
   334 glVertex2i(X, Y);
   346 end;
   346 end;
   347 
   347 
   348 procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
   348 procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
   349 begin
   349 begin
   350 glBindTexture(GL_TEXTURE_2D, Texture^.id);
   350 glBindTexture(GL_TEXTURE_2D, Texture^.id);
   351 glEnable(GL_TEXTURE_2D);
       
   352 
   351 
   353 glBegin(GL_QUADS);
   352 glBegin(GL_QUADS);
   354 
   353 
   355 glTexCoord2f(0, 0);
   354 glTexCoord2f(0, 0);
   356 glVertex2i(X, Y);
   355 glVertex2i(X, Y);
   363 
   362 
   364 glTexCoord2f(0, 1);
   363 glTexCoord2f(0, 1);
   365 glVertex2i(X, Texture^.h + Y);
   364 glVertex2i(X, Texture^.h + Y);
   366 
   365 
   367 glEnd()
   366 glEnd()
       
   367 end;
       
   368 
       
   369 procedure DrawRotated(Sprite: TSprite; X, Y: LongInt; Angle: real);
       
   370 var hw, hh: LongInt;
       
   371 begin
       
   372 glPushMatrix;
       
   373 glTranslatef(X, Y, 0);
       
   374 glRotatef(Angle, 0, 0, 1);
       
   375 
       
   376 hw:= SpritesData[Sprite].Width;
       
   377 hh:= SpritesData[Sprite].Height;
       
   378 
       
   379 glBindTexture(GL_TEXTURE_2D, SpritesData[Sprite].Texture^.id);
       
   380 
       
   381 glBegin(GL_QUADS);
       
   382 
       
   383 glTexCoord2f(0, 0);
       
   384 glVertex2i(-hw, -hh);
       
   385 
       
   386 glTexCoord2f(1, 0);
       
   387 glVertex2i(hw, -hh);
       
   388 
       
   389 glTexCoord2f(1, 1);
       
   390 glVertex2i(hw, hh);
       
   391 
       
   392 glTexCoord2f(0, 1);
       
   393 glVertex2i(-hw, hh);
       
   394 
       
   395 glEnd();
       
   396 
       
   397 glPopMatrix
   368 end;
   398 end;
   369 
   399 
   370 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface);
   400 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface);
   371 begin
   401 begin
   372 r.y:= r.y + Height * Position;
   402 r.y:= r.y + Height * Position;
   450    l:= Step * 32 / HHTexture^.w;
   480    l:= Step * 32 / HHTexture^.w;
   451    r:= (Step + 1) * 32 / HHTexture^.w
   481    r:= (Step + 1) * 32 / HHTexture^.w
   452    end;
   482    end;
   453 
   483 
   454 glBindTexture(GL_TEXTURE_2D, HHTexture^.id);
   484 glBindTexture(GL_TEXTURE_2D, HHTexture^.id);
   455 glEnable(GL_TEXTURE_2D);
       
   456 
   485 
   457 glBegin(GL_QUADS);
   486 glBegin(GL_QUADS);
   458 
   487 
   459 glTexCoord2f(l, t);
   488 glTexCoord2f(l, t);
   460 glVertex2i(X, Y);
   489 glVertex2i(X, Y);
   563    texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', false, true, true);
   592    texsurf:= LoadImage(Pathz[ptGraphics] + '/Progress', false, true, true);
   564    ProgrTex:= Surface2Tex(texsurf);
   593    ProgrTex:= Surface2Tex(texsurf);
   565    SDL_FreeSurface(texsurf)
   594    SDL_FreeSurface(texsurf)
   566    end;
   595    end;
   567 glClear(GL_COLOR_BUFFER_BIT);
   596 glClear(GL_COLOR_BUFFER_BIT);
       
   597 glEnable(GL_TEXTURE_2D);
   568 r.x:= 0;
   598 r.x:= 0;
   569 r.w:= ProgrTex^.w;
   599 r.w:= ProgrTex^.w;
   570 r.h:= ProgrTex^.w;
   600 r.h:= ProgrTex^.w;
   571 r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w;
   601 r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w;
   572 DrawFromRect((cScreenWidth - ProgrTex^.w) div 2,
   602 DrawFromRect((cScreenWidth - ProgrTex^.w) div 2,
   573              (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex, SDLPrimSurface);
   603              (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex, SDLPrimSurface);
       
   604 glDisable(GL_TEXTURE_2D);
   574 SDL_GL_SwapBuffers();
   605 SDL_GL_SwapBuffers();
   575 inc(Step);
   606 inc(Step);
   576 end;
   607 end;
   577 
   608 
   578 procedure FinishProgress;
   609 procedure FinishProgress;