Translate pixel format and colorspace macros#48
Conversation
Free-Pascal-meets-SDL-Website
left a comment
There was a problem hiding this comment.
Great contribution!
Some minor additions would be great; see individual comments.
Maybe you could also add something like "implements several missing macros" to README.MD, v0.x info, please?
Best regards
Matthias
| PSDL_MouseButtonFlags = ^TSDL_MouseButtonFlags; | ||
| TSDL_MouseButtonFlags = type cuint32; | ||
|
|
||
| function SDL_BUTTON_MASK(X: TSDL_MouseButtonFlags): TSDL_MouseButtonFlags; |
There was a problem hiding this comment.
To be consistent with the original code, this function should be right above SDL_BUTTON_LMASK. I would suggest to move it down and have the following structure:
function SDL_BUTTON_MASK(X: TSDL_MouseButtonFlags): TSDL_MouseButtonFlags;
{SDL3-for-Pascal: FPC does not allow assigning function results to consts,
so these values are calculated manually. }
const
SDL_BUTTON_LMASK = TSDL_MouseButtonFlags(1 shl SDL_BUTTON_LEFT-1); { SDL_BUTTON_MASK(SDL_BUTTON_LEFT) }
| { Macros from SDL_pixels.h } | ||
| function SDL_DEFINE_PIXELFOURCC(A, B, C, D: AnsiChar): TSDL_PixelFormat; | ||
| begin | ||
| Result := SDL_FOURCC(A, B, C, D) |
There was a problem hiding this comment.
All Result lines (applies to all macro functions) should be finished with a semi colon, just to make it clean.
| @@ -193,9 +193,155 @@ const | |||
| SDL_PACKEDLAYOUT_2101010 = TSDL_PackedLayout(7); | |||
| SDL_PACKEDLAYOUT_1010102 = TSDL_PackedLayout(8); | |||
|
|
|||
There was a problem hiding this comment.
Add a comment here:
{ SDL3-for-Pascal: Pixel format macros in header file are declared below, because they rely on TSDL_PixelFormat definition. }
(or similar)
| { Macros from SDL_mouse.h } | ||
| function SDL_BUTTON_MASK(X: TSDL_MouseButtonFlags): TSDL_MouseButtonFlags; | ||
| begin | ||
| Result := TSDL_MouseButtonFlags(1) shl (X-1) |
There was a problem hiding this comment.
Add semicolon please.
| { Macros from SDL_stdinc.h} | ||
| function SDL_FOURCC(A, B, C, D: AnsiChar): cuint32; | ||
| begin | ||
| Result := (cuint32(Ord(A)) shl 0) or (cuint32(Ord(B)) shl 8) or (cuint32(Ord(C)) shl 16) or (cuint32(Ord(D)) shl 24) |
There was a problem hiding this comment.
Add semicolon please.
| chroma: TSDL_ChromaLocation | ||
| ): TSDL_Colorspace; | ||
| begin | ||
| Result := (cuint32(type_) shl 28) or (cuint32(range) shl 24) or (cuint32(chroma) shl 20) or |
There was a problem hiding this comment.
All Result lines (applies to all macro functions) should be finished with a semi colon, just to make it clean.
| @@ -723,10 +723,117 @@ const | |||
| SDL_CHROMA_LOCATION_CENTER = TSDL_ChromaLocation(2); {*< In JPEG/JFIF, H.261, and MPEG-1, Cb and Cr are taken at the center of the 2x2 square. In other words, they are offset one-half pixel to the right and one-half pixel down compared to the top-left pixel. } | |||
| SDL_CHROMA_LOCATION_TOPLEFT = TSDL_ChromaLocation(3); {*< In HEVC for BT.2020 and BT.2100 content (in particular on Blu-rays), Cb and Cr are sampled at the same location as the group's top-left Y pixel ("co-sited", "co-located"). } | |||
|
|
|||
There was a problem hiding this comment.
Add comment here:
{ SDL3-for-Pascal: Color space macros in header file are declared below, because they rely on TSDL_Colorspace definition. }
(or similar)
TSDL_PixelFormatandTSDL_Colorspacedefinitions had to be moved to avoid the compiler complaining about unknown types in function arguments/return values.