22 |
22 |
23 interface |
23 interface |
24 |
24 |
25 uses SDLh, uTypes, GLunit, uConsts; |
25 uses SDLh, uTypes, GLunit, uConsts; |
26 |
26 |
27 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
27 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt); |
28 procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
28 procedure DrawSprite (Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
29 |
29 procedure DrawSpriteFromRect (Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); |
30 procedure DrawSprite(Sprite: TSprite; X, Y, Frame: LongInt); |
30 procedure DrawSpriteClipped (Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
31 procedure DrawSprite(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
31 procedure DrawSpriteRotated (Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
32 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); |
32 procedure DrawSpriteRotatedF (Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
33 procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
33 |
34 |
34 procedure DrawTexture (X, Y: LongInt; Texture: PTexture); inline; |
35 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); inline; |
35 procedure DrawTexture (X, Y: LongInt; Texture: PTexture; Scale: GLfloat); |
36 procedure DrawTexture(X, Y: LongInt; Texture: PTexture; Scale: GLfloat); |
36 procedure DrawTextureFromRect (X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
37 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
37 procedure DrawTextureFromRect (X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
38 |
38 procedure DrawTextureCentered (X, Top: LongInt; Source: PTexture); |
39 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
39 procedure DrawTextureF (Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
40 procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
40 procedure DrawTextureRotated (Texture: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
41 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
41 procedure DrawTextureRotatedF (Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
42 procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
42 |
43 |
43 procedure DrawCircle (X, Y, Radius, Width: LongInt); |
44 procedure DrawCentered(X, Top: LongInt; Source: PTexture); |
44 procedure DrawCircle (X, Y, Radius, Width: LongInt; r, g, b, a: Byte); |
45 procedure DrawLine(X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
45 |
46 procedure DrawFillRect(r: TSDL_Rect); |
46 procedure DrawLine (X0, Y0, X1, Y1, Width: Single; r, g, b, a: Byte); |
47 procedure DrawCircle(X, Y, Radius, Width: LongInt); |
47 procedure DrawFillRect (r: TSDL_Rect); |
48 procedure DrawCircle(X, Y, Radius, Width: LongInt; r, g, b, a: Byte); |
48 procedure DrawHedgehog (X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
49 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real); |
49 procedure DrawScreenWidget (widget: POnScreenWidget); |
50 procedure DrawScreenWidget(widget: POnScreenWidget); |
50 |
51 |
51 procedure Tint (r, g, b, a: Byte); inline; |
52 procedure Tint(r, g, b, a: Byte); inline; |
52 procedure Tint (c: Longword); inline; |
53 procedure Tint(c: Longword); inline; |
|
54 |
53 |
55 |
54 |
56 implementation |
55 implementation |
57 uses uVariables; |
56 uses uVariables; |
58 |
57 |
59 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); |
58 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt); |
60 begin |
59 begin |
61 r.y:= r.y + Height * Position; |
60 r.y:= r.y + Height * Position; |
62 r.h:= Height; |
61 r.h:= Height; |
63 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
62 DrawTextureFromRect(X, Y, @r, SpritesData[Sprite].Texture) |
64 end; |
63 end; |
65 |
64 |
66 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
65 procedure DrawTextureFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
67 begin |
66 begin |
68 DrawFromRect(X, Y, r^.w, r^.h, r, SourceTexture) |
67 DrawTextureFromRect(X, Y, r^.w, r^.h, r, SourceTexture) |
69 end; |
68 end; |
70 |
69 |
71 procedure DrawFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
70 procedure DrawTextureFromRect(X, Y, W, H: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
72 var rr: TSDL_Rect; |
71 var rr: TSDL_Rect; |
73 _l, _r, _t, _b: real; |
72 _l, _r, _t, _b: real; |
74 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
73 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
75 begin |
74 begin |
76 if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then |
75 if (SourceTexture^.h = 0) or (SourceTexture^.w = 0) then |
139 glPopMatrix |
137 glPopMatrix |
140 end; |
138 end; |
141 |
139 |
142 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
140 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, w, h: LongInt); |
143 begin |
141 begin |
144 DrawRotatedTextureF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) |
142 DrawTextureRotatedF(Texture, Scale, 0, 0, X, Y, Frame, Dir, w, h, 0) |
145 end; |
143 end; |
146 |
144 |
147 procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
145 procedure DrawTextureRotatedF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, w, h: LongInt; Angle: real); |
148 var ft, fb, fl, fr: GLfloat; |
146 var ft, fb, fl, fr: GLfloat; |
149 hw, nx, ny: LongInt; |
147 hw, nx, ny: LongInt; |
150 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
148 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
151 begin |
149 begin |
152 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |
150 // do not draw anything outside the visible screen space (first check fixes some sprite drawing, e.g. hedgehogs) |