@@ -98,14 +98,36 @@ const
9898
9999 {
100100 //todo!!
101- function SDL_DEFINE_PIXELFORMAT(type, order, layour, bit, bytes: cuint32): Result;
102101
103102function SDL_DEFINE_PIXELFOURCC(A,B,C,D: Variant): Variant;
104-
105- #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
106- ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
107- ((bits) << 8) | ((bytes) << 0))
108- }
103+ }
104+
105+ {
106+ SDL2-for-Pascal: The SDL_DEFINE_PIXELFORMAT macro returns the underlying
107+ pixel format based on five arguments.
108+
109+ The original C macro:
110+ #define SDL_DEFINE_PIXELFORMAT(type, order, layout, bits, bytes) \
111+ ((1 << 28) | ((type) << 24) | ((order) << 20) | ((layout) << 16) | \
112+ ((bits) << 8) | ((bytes) << 0))
113+
114+ This C implementation could be replaced by a Pascal function,
115+ but from a performance stand point this will be slower.
116+ Therefore we decided to keep it as it has been implemented
117+ before by the original binding authors and translate
118+ every pixel format constant by the very same expression:
119+
120+ SDL_PIXELFORMAT_[...] = (1 shl 28) or
121+ (SDL_PIXELTYPE_[...] shl 24) or
122+ (SDL_BITMAPORDER_[...] shl 20) or
123+ ([...] shl 16) or
124+ ([...] shl 8) or
125+ ([...] shl 0);
126+
127+ In the future it may be desirable to have a Pascal function.
128+ The prototype could look like this:
129+ function SDL_DEFINE_PIXELFORMAT(type, order, layour, bit, bytes: cuint32): Result;
130+ }
109131
110132function SDL_PIXELFLAG (X: cuint32): cuint32;
111133function SDL_PIXELTYPE (X: cuint32): cuint32;
@@ -155,7 +177,6 @@ function SDL_BITSPERPIXEL(X: cuint32): cuint32;
155177{ * The flag is set to 1 because 0x1? is not in the printable ASCII range *}
156178function SDL_ISPIXELFORMAT_FOURCC (format: Variant): Boolean;
157179
158- { TODO : Use SDL_DEFINE_FORMAT macro? Examine results in detail. }
159180{ * Note: If you modify this list, update SDL_GetPixelFormatName() *}
160181const
161182 SDL_PIXELFORMAT_UNKNOWN = 0 ;
0 commit comments