35 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
35 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt); |
36 procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
36 procedure DrawSpriteClipped(Sprite: TSprite; X, Y, TopY, RightX, BottomY, LeftX: LongInt); |
37 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture); |
37 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture); |
38 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); |
38 procedure DrawTexture(X, Y: LongInt; Texture: PTexture); |
39 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, Frames: LongInt); |
39 procedure DrawTextureF(Texture: PTexture; Scale: GLfloat; X, Y, Frame, Dir, Frames: LongInt); |
|
40 procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, Frames: LongInt; Angle: real); |
40 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
41 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real); |
41 procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
42 procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame, Dir: LongInt; Angle: real); |
42 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
43 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real); |
43 procedure DrawCentered(X, Top: LongInt; Source: PTexture); |
44 procedure DrawCentered(X, Top: LongInt; Source: PTexture); |
44 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
45 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture); |
454 hw: LongInt; |
455 hw: LongInt; |
455 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
456 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
456 begin |
457 begin |
457 glPushMatrix; |
458 glPushMatrix; |
458 glTranslatef(X, Y, 0); |
459 glTranslatef(X, Y, 0); |
459 glScalef(Scale, Scale, 1.0); |
460 |
|
461 if Dir < 0 then |
|
462 hw:= - 16 |
|
463 else |
|
464 hw:= 16; |
|
465 |
|
466 ft:= Frame / Frames * Texture^.ry; |
|
467 fb:= (Frame + 1) / Frames * Texture^.ry; |
|
468 |
|
469 glBindTexture(GL_TEXTURE_2D, Texture^.id); |
|
470 |
|
471 VertexBuffer[0].X:= -hw; |
|
472 VertexBuffer[0].Y:= -16; |
|
473 VertexBuffer[1].X:= hw; |
|
474 VertexBuffer[1].Y:= -16; |
|
475 VertexBuffer[2].X:= hw; |
|
476 VertexBuffer[2].Y:= 16; |
|
477 VertexBuffer[3].X:= -hw; |
|
478 VertexBuffer[3].Y:= 16; |
|
479 |
|
480 TextureBuffer[0].X:= 0; |
|
481 TextureBuffer[0].Y:= ft; |
|
482 TextureBuffer[1].X:= Texture^.rx; |
|
483 TextureBuffer[1].Y:= ft; |
|
484 TextureBuffer[2].X:= Texture^.rx; |
|
485 TextureBuffer[2].Y:= fb; |
|
486 TextureBuffer[3].X:= 0; |
|
487 TextureBuffer[3].Y:= fb; |
|
488 |
|
489 glEnableClientState(GL_VERTEX_ARRAY); |
|
490 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
|
491 |
|
492 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
493 glTexCoordPointer(2, GL_FLOAT, 0, @TextureBuffer[0]); |
|
494 glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer)); |
|
495 |
|
496 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
|
497 glDisableClientState(GL_VERTEX_ARRAY); |
|
498 |
|
499 |
|
500 glPopMatrix |
|
501 end; |
|
502 |
|
503 procedure DrawRotatedTextureF(Texture: PTexture; Scale, OffsetX, OffsetY: GLfloat; X, Y, Frame, Dir, Frames: LongInt; Angle: real); |
|
504 var ft, fb: GLfloat; |
|
505 hw: LongInt; |
|
506 VertexBuffer, TextureBuffer: array [0..3] of TVertex2f; |
|
507 begin |
|
508 glPushMatrix; |
|
509 glTranslatef(X, Y, 0); |
|
510 |
|
511 if Dir < 0 then |
|
512 glRotatef(Angle, 0, 0, -1) |
|
513 else |
|
514 glRotatef(Angle, 0, 0, 1); |
|
515 |
|
516 glTranslatef(Dir*OffsetX, OffsetY, 0); |
|
517 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
460 |
518 |
461 if Dir < 0 then |
519 if Dir < 0 then |
462 hw:= - 16 |
520 hw:= - 16 |
463 else |
521 else |
464 hw:= 16; |
522 hw:= 16; |