Skip to content

Commit c554bef

Browse files
Add comment about SDL_DEFINE_PIXELFOURCC macro + fix integer type
1 parent 73e3072 commit c554bef

File tree

1 file changed

+54
-36
lines changed

1 file changed

+54
-36
lines changed

units/sdlpixels.inc

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,29 @@ const
9696
SDL_PACKEDLAYOUT_2101010 = TSDL_PackedLayout(7);
9797
SDL_PACKEDLAYOUT_1010102 = TSDL_PackedLayout(8);
9898

99-
{
100-
//todo!!
99+
{
100+
SDL2-for-Pascal: The SDL_DEFINE_PIXELFOURCC macro is replaced
101+
by another macro, the SDL_FOURCC macro (in SDL_stdinc.h).
102+
103+
The original C SDL_FOURCC macro:
104+
#define SDL_FOURCC(A, B, C, D) \
105+
((SDL_static_cast(Uint32, SDL_static_cast(Uint8, (A))) << 0) | \
106+
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (B))) << 8) | \
107+
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (C))) << 16) | \
108+
(SDL_static_cast(Uint32, SDL_static_cast(Uint8, (D))) << 24))
109+
110+
In Pascal it is cleaner to implement this directly as a
111+
constant instead of a function. So we do, e. g.:
112+
113+
SDL_PIXELFORMAT_YV12 = (cuint32('Y') ) or
114+
(cuint32('V') shl 8) or
115+
(cuint32('1') shl 16) or
116+
(cuint32('2') shl 24);
101117
102-
function SDL_DEFINE_PIXELFOURCC(A,B,C,D: Variant): Variant;
103-
}
118+
In the future it may be desirable to have a Pascal function.
119+
The prototype could look like this:
120+
function SDL_DEFINE_PIXELFOURCC(A,B,C,D: Variant): Variant;
121+
}
104122

105123
{
106124
SDL2-for-Pascal: The SDL_DEFINE_PIXELFORMAT macro returns the underlying
@@ -408,46 +426,46 @@ const
408426
{$ENDIF}
409427

410428
{**< Planar mode: Y + V + U (3 planes) *}
411-
SDL_PIXELFORMAT_YV12 = (cint('Y') ) or
412-
(cint('V') shl 8) or
413-
(cint('1') shl 16) or
414-
(cint('2') shl 24);
429+
SDL_PIXELFORMAT_YV12 = (cuint32('Y') ) or
430+
(cuint32('V') shl 8) or
431+
(cuint32('1') shl 16) or
432+
(cuint32('2') shl 24);
415433
{**< Planar mode: Y + U + V (3 planes) *}
416-
SDL_PIXELFORMAT_IYUV = (cint('I') ) or
417-
(cint('Y') shl 8) or
418-
(cint('U') shl 16) or
419-
(cint('V') shl 24);
434+
SDL_PIXELFORMAT_IYUV = (cuint32('I') ) or
435+
(cuint32('Y') shl 8) or
436+
(cuint32('U') shl 16) or
437+
(cuint32('V') shl 24);
420438
{**< Packed mode: Y0+U0+Y1+V0 (1 plane) *}
421-
SDL_PIXELFORMAT_YUY2 = (cint('Y') ) or
422-
(cint('U') shl 8) or
423-
(cint('Y') shl 16) or
424-
(cint('2') shl 24);
439+
SDL_PIXELFORMAT_YUY2 = (cuint32('Y') ) or
440+
(cuint32('U') shl 8) or
441+
(cuint32('Y') shl 16) or
442+
(cuint32('2') shl 24);
425443
{**< Packed mode: U0+Y0+V0+Y1 (1 plane) *}
426-
SDL_PIXELFORMAT_UYVY = (cint('U') ) or
427-
(cint('Y') shl 8) or
428-
(cint('V') shl 16) or
429-
(cint('Y') shl 24);
444+
SDL_PIXELFORMAT_UYVY = (cuint32('U') ) or
445+
(cuint32('Y') shl 8) or
446+
(cuint32('V') shl 16) or
447+
(cuint32('Y') shl 24);
430448
{**< Packed mode: Y0+V0+Y1+U0 (1 plane) *}
431-
SDL_PIXELFORMAT_YVYU = (cint('Y') ) or
432-
(cint('V') shl 8) or
433-
(cint('Y') shl 16) or
434-
(cint('U') shl 24);
449+
SDL_PIXELFORMAT_YVYU = (cuint32('Y') ) or
450+
(cuint32('V') shl 8) or
451+
(cuint32('Y') shl 16) or
452+
(cuint32('U') shl 24);
435453
{**< Planar mode: Y + U/V interleaved (2 planes) *}
436-
SDL_PIXELFORMAT_NV12 = (cint('N') ) or
437-
(cint('V') shl 8) or
438-
(cint('1') shl 16) or
439-
(cint('2') shl 24);
454+
SDL_PIXELFORMAT_NV12 = (cuint32('N') ) or
455+
(cuint32('V') shl 8) or
456+
(cuint32('1') shl 16) or
457+
(cuint32('2') shl 24);
440458
{**< Planar mode: Y + V/U interleaved (2 planes) *}
441-
SDL_PIXELFORMAT_NV21 = (cint('N') ) or
442-
(cint('V') shl 8) or
443-
(cint('2') shl 16) or
444-
(cint('1') shl 24);
459+
SDL_PIXELFORMAT_NV21 = (cuint32('N') ) or
460+
(cuint32('V') shl 8) or
461+
(cuint32('2') shl 16) or
462+
(cuint32('1') shl 24);
445463
{**< Android video texture format *}
446464
SDL_PIXELFORMAT_EXTERMAL_OES
447-
= (cint('O') ) or
448-
(cint('E') shl 8) or
449-
(cint('S') shl 16) or
450-
(cint(' ') shl 24);
465+
= (cuint32('O') ) or
466+
(cuint32('E') shl 8) or
467+
(cuint32('S') shl 16) or
468+
(cuint32(' ') shl 24);
451469

452470
type
453471

0 commit comments

Comments
 (0)