Skip to content

Commit c1b668c

Browse files
Merge pull request #14 from suve/add-floating-point-rendering-functions
Add floating point rendering functions
2 parents d5c0b96 + 40335e1 commit c1b668c

File tree

3 files changed

+149
-14
lines changed

3 files changed

+149
-14
lines changed

sdlrect.inc

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,41 @@
22

33
type
44
{**
5-
* The structure that defines a point
6-
*
7-
* SDL_EnclosePoints
5+
* The structure that defines a point (integer)
86
*}
9-
107
PSDL_Point = ^TSDL_Point;
118
TSDL_Point = record
129
x: SInt32;
1310
y: SInt32;
1411
end;
1512

1613
{**
17-
* A rectangle, with the origin at the upper left.
18-
*
19-
* SDL_RectEmpty
20-
* SDL_RectEquals
21-
* SDL_HasIntersection
22-
* SDL_IntersectRect
23-
* SDL_UnionRect
24-
* SDL_EnclosePoints
14+
* The structure that defines a point (floating point)
2515
*}
16+
PSDL_FPoint = ^TSDL_FPoint;
17+
TSDL_FPoint = record
18+
x: Single;
19+
y: Single;
20+
end;
2621

22+
{**
23+
* A rectangle, with the origin at the upper left. (integer)
24+
*}
2725
PSDL_Rect = ^TSDL_Rect;
2826
TSDL_Rect = record
2927
x,y: SInt32;
3028
w,h: SInt32;
3129
end;
3230

31+
{**
32+
* A rectangle, with the origin at the upper left. (floating point)
33+
*}
34+
PSDL_FRect = ^TSDL_FRect;
35+
TSDL_FRect = record
36+
x,y: Single;
37+
w,h: Single;
38+
end;
39+
3340
{**
3441
* \brief Returns true if point resides inside a rectangle.
3542
*}

sdlrenderer.inc

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,18 @@ function SDL_RenderClear(renderer: PSDL_Renderer): SInt32 cdecl; external SDL_Li
585585
*}
586586
function SDL_RenderDrawPoint(renderer: PSDL_Renderer; x: SInt32; y: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawPoint' {$ENDIF} {$ENDIF};
587587

588+
{**
589+
* Draw a point on the current rendering target.
590+
*
591+
* renderer The renderer which should draw a point.
592+
* x The x coordinate of the point.
593+
* y The y coordinate of the point.
594+
*
595+
* 0 on success, or -1 on error
596+
*}
597+
function SDL_RenderDrawPointF(renderer: PSDL_Renderer; x, y: single): SInt32 cdecl;
598+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawPointF' {$ENDIF} {$ENDIF};
599+
588600
{**
589601
* Draw multiple points on the current rendering target.
590602
*
@@ -596,6 +608,18 @@ function SDL_RenderDrawPoint(renderer: PSDL_Renderer; x: SInt32; y: SInt32): SIn
596608
*}
597609
function SDL_RenderDrawPoints(renderer: PSDL_Renderer; points: PSDL_Point; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawPoints' {$ENDIF} {$ENDIF};
598610

611+
{**
612+
* Draw multiple points on the current rendering target.
613+
*
614+
* renderer The renderer which should draw multiple points.
615+
* points The points to draw
616+
* count The number of points to draw
617+
*
618+
* 0 on success, or -1 on error
619+
*}
620+
function SDL_RenderDrawPointsF(renderer: PSDL_Renderer; points: PSDL_FPoint; count: SInt32): SInt32 cdecl;
621+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawPointsF' {$ENDIF} {$ENDIF};
622+
599623
{**
600624
* Draw a line on the current rendering target.
601625
*
@@ -609,6 +633,20 @@ function SDL_RenderDrawPoints(renderer: PSDL_Renderer; points: PSDL_Point; count
609633
*}
610634
function SDL_RenderDrawLine(renderer: PSDL_Renderer; x1: SInt32; y1: SInt32; x2: SInt32; y2: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawLine' {$ENDIF} {$ENDIF};
611635

636+
{**
637+
* Draw a line on the current rendering target.
638+
*
639+
* renderer The renderer which should draw a line.
640+
* x1 The x coordinate of the start point.
641+
* y1 The y coordinate of the start point.
642+
* x2 The x coordinate of the end point.
643+
* y2 The y coordinate of the end point.
644+
*
645+
* 0 on success, or -1 on error
646+
*}
647+
function SDL_RenderDrawLineF(renderer: PSDL_Renderer; x1, y1, x2, y2: single): SInt32 cdecl;
648+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawLineF' {$ENDIF} {$ENDIF};
649+
612650
{**
613651
* \brief Draw a series of connected lines on the current rendering target.
614652
*
@@ -620,6 +658,18 @@ function SDL_RenderDrawLine(renderer: PSDL_Renderer; x1: SInt32; y1: SInt32; x2:
620658
*}
621659
function SDL_RenderDrawLines(renderer: PSDL_Renderer; points: PSDL_Point; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawLines' {$ENDIF} {$ENDIF};
622660

661+
{**
662+
* Draw a series of connected lines on the current rendering target.
663+
*
664+
* renderer The renderer which should draw multiple lines.
665+
* points The points along the lines
666+
* count The number of points, drawing count-1 lines
667+
*
668+
* 0 on success, or -1 on error
669+
*}
670+
function SDL_RenderDrawLinesF(renderer: PSDL_Renderer; points: PSDL_FPoint; count: SInt32): SInt32 cdecl;
671+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawLinesF' {$ENDIF} {$ENDIF};
672+
623673
{**
624674
* Draw a rectangle on the current rendering target.
625675
*
@@ -630,6 +680,17 @@ function SDL_RenderDrawLines(renderer: PSDL_Renderer; points: PSDL_Point; count:
630680
*}
631681
function SDL_RenderDrawRect(renderer: PSDL_Renderer; rect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawRect' {$ENDIF} {$ENDIF};
632682

683+
{**
684+
* Draw a rectangle on the current rendering target.
685+
*
686+
* renderer The renderer which should draw a rectangle.
687+
* rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
688+
*
689+
* 0 on success, or -1 on error
690+
*}
691+
function SDL_RenderDrawRectF(renderer: PSDL_Renderer; rect: PSDL_FRect): SInt32 cdecl;
692+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawRectF' {$ENDIF} {$ENDIF};
693+
633694
{**
634695
* Draw some number of rectangles on the current rendering target.
635696
*
@@ -641,6 +702,18 @@ function SDL_RenderDrawRect(renderer: PSDL_Renderer; rect: PSDL_Rect): SInt32 cd
641702
*}
642703
function SDL_RenderDrawRects(renderer: PSDL_Renderer; rects: PSDL_Rect; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawRects' {$ENDIF} {$ENDIF};
643704

705+
{**
706+
* Draw some number of rectangles on the current rendering target.
707+
*
708+
* renderer The renderer which should draw multiple rectangles.
709+
* rects A pointer to an array of destination rectangles.
710+
* count The number of rectangles.
711+
*
712+
* 0 on success, or -1 on error
713+
*}
714+
function SDL_RenderDrawRectsF(renderer: PSDL_Renderer; rects: PSDL_FRect; count: SInt32): SInt32 cdecl;
715+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderDrawRectsF' {$ENDIF} {$ENDIF};
716+
644717
{**
645718
* Fill a rectangle on the current rendering target with the drawing color.
646719
*
@@ -652,6 +725,17 @@ function SDL_RenderDrawRects(renderer: PSDL_Renderer; rects: PSDL_Rect; count: S
652725
*}
653726
function SDL_RenderFillRect(renderer: PSDL_Renderer; rect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderFillRect' {$ENDIF} {$ENDIF};
654727

728+
{**
729+
* Fill a rectangle on the current rendering target with the drawing color.
730+
*
731+
* renderer The renderer which should fill a rectangle.
732+
* rect A pointer to the destination rectangle, or NULL for the entire rendering target.
733+
*
734+
* 0 on success, or -1 on error
735+
*}
736+
function SDL_RenderFillRectF(renderer: PSDL_Renderer; rect: PSDL_FRect): SInt32 cdecl;
737+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderFillRectF' {$ENDIF} {$ENDIF};
738+
655739
{**
656740
* Fill some number of rectangles on the current rendering target with the drawing color.
657741
*
@@ -663,6 +747,18 @@ function SDL_RenderFillRect(renderer: PSDL_Renderer; rect: PSDL_Rect): SInt32 cd
663747
*}
664748
function SDL_RenderFillRects(renderer: PSDL_Renderer; rects: PSDL_Rect; count: SInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderFillRects' {$ENDIF} {$ENDIF};
665749

750+
{**
751+
* Fill some number of rectangles on the current rendering target with the drawing color.
752+
*
753+
* renderer The renderer which should fill multiple rectangles.
754+
* rects A pointer to an array of destination rectangles.
755+
* count The number of rectangles.
756+
*
757+
* 0 on success, or -1 on error
758+
*}
759+
function SDL_RenderFillRectsF(renderer: PSDL_Renderer; rects: PSDL_FRect; count: SInt32): SInt32 cdecl;
760+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderFillRectsF' {$ENDIF} {$ENDIF};
761+
666762
{**
667763
* Copy a portion of the texture to the current rendering target.
668764
*
@@ -677,6 +773,19 @@ function SDL_RenderFillRects(renderer: PSDL_Renderer; rects: PSDL_Rect; count: S
677773
*}
678774
function SDL_RenderCopy(renderer: PSDL_Renderer; texture: PSDL_Texture; srcrect: PSDL_Rect; dstrect: PSDL_Rect): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderCopy' {$ENDIF} {$ENDIF};
679775

776+
{**
777+
* Copy a portion of the texture to the current rendering target.
778+
*
779+
* renderer The renderer which should copy parts of a texture.
780+
* texture The source texture.
781+
* srcrect A pointer to the source rectangle, or NIL for the entire texture.
782+
* dstrect A pointer to the destination rectangle, or NIL for the entire rendering target.
783+
*
784+
* 0 on success, or -1 on error
785+
*}
786+
function SDL_RenderCopyF(renderer: PSDL_Renderer; texture: PSDL_Texture; srcrect: PSDL_Rect; dstrect: PSDL_FRect): SInt32 cdecl;
787+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderCopyF' {$ENDIF} {$ENDIF};
788+
680789
{**
681790
* Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
682791
*
@@ -694,6 +803,22 @@ function SDL_RenderCopy(renderer: PSDL_Renderer; texture: PSDL_Texture; srcrect:
694803
*}
695804
function SDL_RenderCopyEx(renderer: PSDL_Renderer; texture: PSDL_Texture; const srcrect: PSDL_Rect; dstrect: PSDL_Rect; angle: Double; center: PSDL_Point; flip: Integer): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderCopyEx' {$ENDIF} {$ENDIF};
696805

806+
{**
807+
* Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
808+
*
809+
* renderer The renderer which should copy parts of a texture.
810+
* texture The source texture.
811+
* srcrect A pointer to the source rectangle, or NIL for the entire texture.
812+
* dstrect A pointer to the destination rectangle, or NIL for the entire rendering target.
813+
* angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
814+
* center A pointer to a point indicating the point around which dstrect will be rotated (if NIL, rotation will be done around dstrect.w/2, dstrect.h/2).
815+
* flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture
816+
*
817+
* 0 on success, or -1 on error
818+
*}
819+
function SDL_RenderCopyExF(renderer: PSDL_Renderer; texture: PSDL_Texture; const srcrect: PSDL_Rect; dstrect: PSDL_FRect; angle: Double; center: PSDL_FPoint; flip: Integer): SInt32 cdecl;
820+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderCopyExF' {$ENDIF} {$ENDIF};
821+
697822
{**
698823
* Read pixels from the current rendering target.
699824
*

sdlversion.inc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ type
2020
patch: UInt8; {**< update version *}
2121
end;
2222

23-
{* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
23+
{*
24+
Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
25+
26+
Last updated when TSDL_FPoint and TSDL_FRect were added.
2427
*}
2528
const
2629
SDL_MAJOR_VERSION = 2;
2730
SDL_MINOR_VERSION = 0;
28-
SDL_PATCHLEVEL = 4;
31+
SDL_PATCHLEVEL = 10;
2932

3033
{**
3134
* Macro to determine SDL version program was compiled against.

0 commit comments

Comments
 (0)