Skip to content

Commit b4bada6

Browse files
Merge pull request #48 from suve/update-sdlrender.inc-to-2.0.22
Update sdlrender.inc to 2.0.22
2 parents 4c2a7f4 + 1ad8702 commit b4bada6

File tree

2 files changed

+173
-7
lines changed

2 files changed

+173
-7
lines changed

units/sdl2.pas

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ interface
168168
{$I sdlhints.inc} // 2.0.20
169169
{$I sdlloadso.inc}
170170
{$I sdlmessagebox.inc} // 2.0.14
171-
{$I sdlrenderer.inc}
171+
{$I sdlrenderer.inc} // 2.0.22
172172
{$I sdlscancode.inc}
173173
{$I sdlkeyboard.inc}
174174
{$I sdlmouse.inc}

units/sdlrenderer.inc

+172-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,30 @@ type
2929
max_texture_height: cint32; {**< The maximimum texture height *}
3030
end;
3131

32+
PSDL_Vertex = ^TSDL_Vertex;
33+
TSDL_Vertex = record
34+
position: TSDL_FPoint;
35+
color: TSDL_Color;
36+
tex_coord: TSDL_FPoint;
37+
end;
38+
39+
{**
40+
* The scaling mode for a texture.
41+
*}
42+
PSDL_ScaleMode = ^TSDL_ScaleMode;
43+
TSDL_ScaleMode = type cint;
44+
45+
const
46+
SDL_ScaleModeNearest = TSDL_ScaleMode(0); {**< nearest pixel sampling *}
47+
SDL_ScaleModeLinear = TSDL_ScaleMode(1); {**< linear filtering *}
48+
SDL_ScaleModeBest = TSDL_ScaleMode(2); {**< anisotropic filtering *}
49+
3250
{**
3351
* The access pattern allowed for a texture.
3452
*}
3553
type
3654
PSDL_TextureAccess = ^TSDL_TextureAccess;
37-
TSDL_TextureAccess = cint32;
55+
TSDL_TextureAccess = type cint;
3856

3957
const
4058
SDL_TEXTUREACCESS_STATIC = 0; {**< Changes rarely, not lockable *}
@@ -46,11 +64,12 @@ type
4664
* The texture channel modulation used in SDL_RenderCopy().
4765
*}
4866
PSDL_TextureModulate = ^TSDL_TextureModulate;
49-
TSDL_TextureModulate = (
50-
SDL_TEXTUREMODULATE_NONE, {**< No modulation *}
51-
SDL_TEXTUREMODULATE_COLOR, {**< srcC = srcC * color *}
52-
SDL_TEXTUREMODULATE_ALPHA {**< srcA = srcA * alpha *}
53-
);
67+
TSDL_TextureModulate = type cint;
68+
69+
const
70+
SDL_TEXTUREMODULATE_NONE = TSDL_TextureModulate(0); {**< No modulation *}
71+
SDL_TEXTUREMODULATE_COLOR = TSDL_TextureModulate(1); {**< srcC = srcC * color *}
72+
SDL_TEXTUREMODULATE_ALPHA = TSDL_TextureModulate(2); {**< srcA = srcA * alpha *}
5473

5574
{**
5675
* Flip constants for SDL_RenderCopyEx
@@ -152,6 +171,12 @@ function SDL_CreateSoftwareRenderer(surface: PSDL_Surface): PSDL_Renderer cdecl;
152171
*}
153172
function SDL_GetRenderer(window: PSDL_Window): PSDL_Renderer cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetRenderer' {$ENDIF} {$ENDIF};
154173

174+
{**
175+
* Get the window associated with a renderer.
176+
*}
177+
function SDL_RenderGetWindow(renderer: PSDL_Renderer): PSDL_Window; cdecl;
178+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderGetWindow' {$ENDIF} {$ENDIF};
179+
155180
{**
156181
* Get information about a rendering context.
157182
*}
@@ -293,6 +318,31 @@ function SDL_SetTextureBlendMode(texture: PSDL_Texture; blendMode: TSDL_BlendMod
293318
*}
294319
function SDL_GetTextureBlendMode(texture: PSDL_Texture; blendMode: PSDL_BlendMode): cint32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetTextureBlendMode' {$ENDIF} {$ENDIF};
295320

321+
{**
322+
* Set the scale mode used for texture scale operations.
323+
* If the scale mode is not supported, the closest supported mode is chosen.
324+
*}
325+
function SDL_SetTextureScaleMode(texture: PSDL_Texture; scaleMode: TSDL_ScaleMode): cint; cdecl;
326+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetTextureScaleMode' {$ENDIF} {$ENDIF};
327+
328+
{**
329+
* Get the scale mode used for texture scale operations.
330+
*}
331+
function SDL_GetTextureScaleMode(texture: PSDL_Texture; scaleMode: PSDL_ScaleMode): cint; cdecl;
332+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetTextureScaleMode' {$ENDIF} {$ENDIF};
333+
334+
{**
335+
* Associate a user-specified pointer with a texture.
336+
*}
337+
function SDL_SetTextureUserData(texture: PSDL_Texture; userdata: Pointer): cint; cdecl;
338+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetTextureUserData' {$ENDIF} {$ENDIF};
339+
340+
{**
341+
* Get the user-specified pointer associated with a texture.
342+
*}
343+
function SDL_GetTextureUserData(texture: PSDL_Texture): Pointer; cdecl;
344+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetTextureUserData' {$ENDIF} {$ENDIF};
345+
296346
{**
297347
* Update the given texture rectangle with new pixel data.
298348
*
@@ -529,6 +579,22 @@ function SDL_RenderSetScale(renderer: PSDL_Renderer; scaleX: cfloat; scaleY: cfl
529579
*}
530580
procedure SDL_RenderGetScale(renderer: PSDL_Renderer; scaleX: pcfloat; scaleY: pcfloat) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderGetScale' {$ENDIF} {$ENDIF};
531581

582+
{**
583+
* Get logical coordinates of point in renderer when given real coordinates of
584+
* point in window. Logical coordinates will differ from real coordinates when
585+
* render is scaled and logical renderer size set.
586+
*}
587+
procedure SDL_RenderWindowToLogical(renderer: PSDL_Renderer; windowX, windowY: cint; logicalX, logicalY: PSingle); cdecl;
588+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderWindowToLogical' {$ENDIF} {$ENDIF};
589+
590+
{**
591+
* Get real coordinates of point in window when given logical coordinates of
592+
* point in renderer. Logical coordinates will differ from real coordinate
593+
* when render is scaled and logical renderer size set.
594+
*}
595+
procedure SDL_RenderLogicalToWindow(renderer: PSDL_Renderer; logicalX, logicalY: Single; windowX, windowY: Pcint); cdecl;
596+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderLogicalToWindow' {$ENDIF} {$ENDIF};
597+
532598
{**
533599
* Set the color used for drawing operations (Rect, Line and Clear).
534600
*
@@ -838,6 +904,35 @@ function SDL_RenderCopyEx(renderer: PSDL_Renderer; texture: PSDL_Texture; const
838904
function SDL_RenderCopyExF(renderer: PSDL_Renderer; texture: PSDL_Texture; const srcrect: PSDL_Rect; dstrect: PSDL_FRect; angle: Double; center: PSDL_FPoint; flip: cint): cint32 cdecl;
839905
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderCopyExF' {$ENDIF} {$ENDIF};
840906

907+
{**
908+
* Render a list of triangles, optionally using a texture and indices into the
909+
* vertex array. Color and alpha modulation is done per vertex.
910+
* SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored.
911+
*}
912+
function SDL_RenderGeometry(
913+
renderer: PSDL_Renderer;
914+
texture: PSDL_Texture;
915+
Const vertices: PSDL_Vertex; num_vertices: cint;
916+
Const indices: Pcint; num_indices: cint
917+
): cint; cdecl;
918+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderGeometry' {$ENDIF} {$ENDIF};
919+
920+
{**
921+
* Render a list of triangles, optionally using a texture and indices into the
922+
* vertex arrays. Color and alpha modulation is done per vertex.
923+
* SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored.
924+
*}
925+
function SDL_RenderGeometryRaw(
926+
renderer: PSDL_Renderer;
927+
texture: PSDL_Texture;
928+
Const xy: PSingle; xy_stride: cint;
929+
Const color: PSDL_Color; color_stride: cint;
930+
Const uv: PSingle; uv_stride: cint;
931+
num_vertices: cint;
932+
Const indices: Pointer; num_indices, size_indices: cint
933+
): cint; cdecl;
934+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderGeometryRaw' {$ENDIF} {$ENDIF};
935+
841936
{**
842937
* Read pixels from the current rendering target.
843938
*
@@ -876,6 +971,32 @@ procedure SDL_DestroyTexture(texture: PSDL_Texture) cdecl; external SDL_LibName
876971
*}
877972
procedure SDL_DestroyRenderer(renderer: PSDL_Renderer) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_DestroyRenderer' {$ENDIF} {$ENDIF};
878973

974+
{**
975+
* Force the rendering context to flush any pending commands to the underlying
976+
* rendering API.
977+
*
978+
* You do not need to (and in fact, shouldn't) call this function unless you
979+
* are planning to call into OpenGL/Direct3D/Metal/whatever directly in
980+
* addition to using an SDL_Renderer.
981+
*
982+
* This is for a very-specific case: if you are using SDL's render API, you
983+
* asked for a specific renderer backend (OpenGL, Direct3D, etc), you set
984+
* SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever
985+
* calls in addition to SDL render API calls. If all of this applies, you
986+
* should call SDL_RenderFlush() between calls to SDL's render API and the
987+
* low-level API you're using in cooperation.
988+
*
989+
* In all other cases, you can ignore this function. This is only here to get
990+
* maximum performance out of a specific situation. In all other cases, SDL
991+
* will do the right thing, perhaps at a performance loss.
992+
*
993+
* This function is first available in SDL 2.0.10, and is not needed in 2.0.9
994+
* and earlier, as earlier versions did not queue rendering commands at all,
995+
* instead flushing them to the OS immediately.
996+
*}
997+
function SDL_RenderFlush(renderer: PSDL_Renderer): cint; cdecl;
998+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderFlush' {$ENDIF} {$ENDIF};
999+
8791000
{**
8801001
* Bind the texture to the current OpenGL/ES/ES2 context for use with
8811002
* OpenGL instructions.
@@ -897,6 +1018,36 @@ function SDL_GL_BindTexture(texture: PSDL_Texture; texw: pcfloat; texh: pcfloat)
8971018
*}
8981019
function SDL_GL_UnbindTexture(texture: PSDL_Texture): cint32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GL_UnbindTexture' {$ENDIF} {$ENDIF};
8991020

1021+
{**
1022+
* Get the CAMetalLayer associated with the given Metal renderer.
1023+
*
1024+
* This function returns a raw Pointer, so SDL doesn't have to include Metal's headers,
1025+
* but it can be safely cast to a pointer to `CAMetalLayer`.
1026+
*
1027+
*}
1028+
function SDL_RenderGetMetalLayer(renderer: PSDL_Renderer): Pointer; cdecl;
1029+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderGetMetalLayer' {$ENDIF} {$ENDIF};
1030+
1031+
{**
1032+
* Get the Metal command encoder for the current frame
1033+
*
1034+
* This function returns a raw Pointer, so SDL doesn't have to include Metal's headers,
1035+
* but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
1036+
*
1037+
* Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
1038+
* SDL a drawable to render to, which might happen if the window is
1039+
* hidden/minimized/offscreen. This doesn't apply to command encoders for
1040+
* render targets, just the window's backbacker. Check your return values!
1041+
*}
1042+
function SDL_RenderGetMetalCommandEncoder(renderer: PSDL_Renderer): Pointer; cdecl;
1043+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderGetMetalCommandEncoder' {$ENDIF} {$ENDIF};
1044+
1045+
{**
1046+
* Toggle VSync of the given renderer.
1047+
*}
1048+
function SDL_RenderSetVSync(renderer: PSDL_Renderer; vsync: cint): cint; cdecl;
1049+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_RenderSetVSync' {$ENDIF} {$ENDIF};
1050+
9001051
{**
9011052
* Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
9021053
*
@@ -917,3 +1068,18 @@ function SDL_GL_UnbindTexture(texture: PSDL_Texture): cint32 cdecl; external SDL
9171068
*}
9181069
function SDL_UpdateYUVTexture(texture: PSDL_Texture; rect: PSDL_Rect; Yplane: pcuint8; Ypitch: cint32; Uplane: pcuint8; UPitch: cint32; Vplane: pcuint8; VPitch: cint32):cint32;
9191070
cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UpdateYUVTexture' {$ENDIF} {$ENDIF};
1071+
1072+
{**
1073+
* Update a rectangle within a planar NV12 or NV21 texture with new pixels.
1074+
*
1075+
* You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
1076+
* block of NV12/21 planes in the proper order, but this function is available
1077+
* if your pixel data is not contiguous.
1078+
*}
1079+
function SDL_UpdateNVTexture(
1080+
texture: PSDL_Texture;
1081+
Const rect: PSDL_Rect;
1082+
Const Yplane: Pcuint8; Ypitch: cint;
1083+
Const UVplane: Pcuint8; UVpitch: cint
1084+
): cint; cdecl;
1085+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_UpdateNVTexture' {$ENDIF} {$ENDIF};

0 commit comments

Comments
 (0)