Skip to content

Translate pixel format and colorspace macros#48

Open
suve wants to merge 4 commits into
PascalGameDevelopment:mainfrom
suve:add-more-macros
Open

Translate pixel format and colorspace macros#48
suve wants to merge 4 commits into
PascalGameDevelopment:mainfrom
suve:add-more-macros

Conversation

@suve

@suve suve commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

TSDL_PixelFormat and TSDL_Colorspace definitions had to be moved to avoid the compiler complaining about unknown types in function arguments/return values.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread units/SDL_mouse.inc
PSDL_MouseButtonFlags = ^TSDL_MouseButtonFlags;
TSDL_MouseButtonFlags = type cuint32;

function SDL_BUTTON_MASK(X: TSDL_MouseButtonFlags): TSDL_MouseButtonFlags;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)  }

Comment thread units/SDL3.pas
{ Macros from SDL_pixels.h }
function SDL_DEFINE_PIXELFOURCC(A, B, C, D: AnsiChar): TSDL_PixelFormat;
begin
Result := SDL_FOURCC(A, B, C, D)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Result lines (applies to all macro functions) should be finished with a semi colon, just to make it clean.

Comment thread units/SDL_pixels.inc
@@ -193,9 +193,155 @@ const
SDL_PACKEDLAYOUT_2101010 = TSDL_PackedLayout(7);
SDL_PACKEDLAYOUT_1010102 = TSDL_PackedLayout(8);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment thread units/SDL3.pas
{ Macros from SDL_mouse.h }
function SDL_BUTTON_MASK(X: TSDL_MouseButtonFlags): TSDL_MouseButtonFlags;
begin
Result := TSDL_MouseButtonFlags(1) shl (X-1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add semicolon please.

Comment thread units/SDL3.pas
{ 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add semicolon please.

Comment thread units/SDL3.pas
chroma: TSDL_ChromaLocation
): TSDL_Colorspace;
begin
Result := (cuint32(type_) shl 28) or (cuint32(range) shl 24) or (cuint32(chroma) shl 20) or

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Result lines (applies to all macro functions) should be finished with a semi colon, just to make it clean.

Comment thread units/SDL_pixels.inc
@@ -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"). }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment here:

{ SDL3-for-Pascal: Color space macros in header file are declared below, because they rely on TSDL_Colorspace definition. }

(or similar)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants