Skip to content

Commit 1b00d25

Browse files
Add full description comments for all functions
1 parent a77bea6 commit 1b00d25

File tree

1 file changed

+194
-34
lines changed

1 file changed

+194
-34
lines changed

units/sdlpixels.inc

Lines changed: 194 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -501,119 +501,279 @@ type
501501
end;
502502

503503
{**
504-
* Get the human readable name of a pixel format
504+
* Get the human readable name of a pixel format.
505+
*
506+
* \param format the pixel format to query
507+
* \returns the human readable name of the specified pixel format or
508+
* `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized.
509+
*
510+
* \since This function is available since SDL 2.0.0.
505511
*}
506512
function SDL_GetPixelFormatName(format: cuint32): PAnsiChar; cdecl;
507513
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetPixelFormatName' {$ENDIF} {$ENDIF};
508514

509515
{**
510-
* Convert one of the enumerated pixel formats to a bpp and RGBA masks.
516+
* Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
517+
*
518+
* \param format one of the SDL_PixelFormatEnum values
519+
* \param bpp a bits per pixel value; usually 15, 16, or 32
520+
* \param Rmask a pointer filled in with the red mask for the format
521+
* \param Gmask a pointer filled in with the green mask for the format
522+
* \param Bmask a pointer filled in with the blue mask for the format
523+
* \param Amask a pointer filled in with the alpha mask for the format
524+
* \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't
525+
* possible; call SDL_GetError() for more information.
511526
*
512-
* SDL_TRUE, or SDL_FALSE if the conversion wasn't possible.
527+
* \since This function is available since SDL 2.0.0.
513528
*
514-
* SDL_MasksToPixelFormatEnum()
529+
* \sa SDL_MasksToPixelFormatEnum
515530
*}
516531
function SDL_PixelFormatEnumToMasks(format: cuint32; bpp: pcint;
517532
Rmask: pcuint32; Gmask: pcuint32; Bmask: pcuint32; Amask: pcuint32): TSDL_Bool; cdecl;
518533
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PixelFormatEnumToMasks' {$ENDIF} {$ENDIF};
519534

520535
{**
521-
* Convert a bpp and RGBA masks to an enumerated pixel format.
536+
* Convert a bpp value and RGBA masks to an enumerated pixel format.
522537
*
523-
* The pixel format, or SDL_PIXELFORMAT_UNKNOWN if the conversion
524-
* wasn't possible.
538+
* This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't
539+
* possible.
525540
*
526-
* SDL_PixelFormatEnumToMasks()
541+
* \param bpp a bits per pixel value; usually 15, 16, or 32
542+
* \param Rmask the red mask for the format
543+
* \param Gmask the green mask for the format
544+
* \param Bmask the blue mask for the format
545+
* \param Amask the alpha mask for the format
546+
* \returns one of the SDL_PixelFormatEnum values
547+
*
548+
* \since This function is available since SDL 2.0.0.
549+
*
550+
* \sa SDL_PixelFormatEnumToMasks
527551
*}
528552
function SDL_MasksToPixelFormatEnum(bpp: cint; Rmask: cuint32; Gmask: cuint32; Bmask: cuint32; Amask: cuint32): cuint32; cdecl;
529553
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MasksToPixelFormatEnum' {$ENDIF} {$ENDIF};
530554

531555
{**
532-
* Create an SDL_PixelFormat structure from a pixel format enum.
556+
* Create an SDL_PixelFormat structure corresponding to a pixel format.
557+
*
558+
* Returned structure may come from a shared global cache (i.e. not newly
559+
* allocated), and hence should not be modified, especially the palette. Weird
560+
* errors such as `Blit combination not supported` may occur.
561+
*
562+
* \param pixel_format one of the SDL_PixelFormatEnum values
563+
* \returns the new SDL_PixelFormat structure or NULL on failure; call
564+
* SDL_GetError() for more information.
565+
*
566+
* \since This function is available since SDL 2.0.0.
567+
*
568+
* \sa SDL_FreeFormat
533569
*}
534570
function SDL_AllocFormat(pixel_format: cuint32): PSDL_PixelFormat; cdecl;
535571
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AllocFormat' {$ENDIF} {$ENDIF};
536572

537573
{**
538-
* Free an SDL_PixelFormat structure.
574+
* Free an SDL_PixelFormat structure allocated by SDL_AllocFormat().
575+
*
576+
* \param format the SDL_PixelFormat structure to free
577+
*
578+
* \since This function is available since SDL 2.0.0.
579+
*
580+
* \sa SDL_AllocFormat
539581
*}
540582
procedure SDL_FreeFormat(format: PSDL_PixelFormat); cdecl;
541583
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreeFormat' {$ENDIF} {$ENDIF};
542584

543585
{**
544-
* Create a palette structure with the specified number of color
545-
* entries.
586+
* Create a palette structure with the specified number of color entries.
587+
*
588+
* The palette entries are initialized to white.
546589
*
547-
* A new palette, or nil if there wasn't enough memory.
590+
* \param ncolors represents the number of color entries in the color palette
591+
* \returns a new SDL_Palette structure on success or NULL on failure (e.g. if
592+
* there wasn't enough memory); call SDL_GetError() for more
593+
* information.
548594
*
549-
* The palette entries are initialized to white.
595+
* \since This function is available since SDL 2.0.0.
550596
*
551-
* SDL_FreePalette()
597+
* \sa SDL_FreePalette
552598
*}
553599
function SDL_AllocPalette(ncolors: cint): PSDL_Palette; cdecl;
554600
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_AllocPalette' {$ENDIF} {$ENDIF};
555601

556602
{**
557-
* Set the palette for a pixel format structure.
603+
* Set the palette for a pixel format structure.
604+
*
605+
* \param format the SDL_PixelFormat structure that will use the palette
606+
* \param palette the SDL_Palette structure that will be used
607+
* \returns 0 on success or a negative error code on failure; call
608+
* SDL_GetError() for more information.
609+
*
610+
* \since This function is available since SDL 2.0.0.
611+
*
612+
* \sa SDL_AllocPalette
613+
* \sa SDL_FreePalette
558614
*}
559615
function SDL_SetPixelFormatPalette(format: PSDL_PixelFormat; palette: PSDL_Palette): cint; cdecl;
560616
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetPixelFormatPalette' {$ENDIF} {$ENDIF};
561617

562618
{**
563-
* Set a range of colors in a palette.
619+
* Set a range of colors in a palette.
564620
*
565-
* palette The palette to modify.
566-
* colors An array of colors to copy into the palette.
567-
* firstcolor The index of the first palette entry to modify.
568-
* ncolors The number of entries to modify.
621+
* \param palette the SDL_Palette structure to modify
622+
* \param colors an array of SDL_Color structures to copy into the palette
623+
* \param firstcolor the index of the first palette entry to modify
624+
* \param ncolors the number of entries to modify
625+
* \returns 0 on success or a negative error code if not all of the colors
626+
* could be set; call SDL_GetError() for more information.
569627
*
570-
* 0 on success, or -1 if not all of the colors could be set.
628+
* \since This function is available since SDL 2.0.0.
629+
*
630+
* \sa SDL_AllocPalette
631+
* \sa SDL_CreateRGBSurface
571632
*}
572633
function SDL_SetPaletteColors(palette: PSDL_Palette; const colors: PSDL_Color; firstcolor: cint; ncolors: cint): cint; cdecl;
573634
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_SetPaletteColors' {$ENDIF} {$ENDIF};
574635

575636
{**
576-
* Free a palette created with SDL_AllocPalette().
637+
* Free a palette created with SDL_AllocPalette().
638+
*
639+
* \param palette the SDL_Palette structure to be freed
640+
*
641+
* \since This function is available since SDL 2.0.0.
577642
*
578-
* SDL_AllocPalette()
643+
* \sa SDL_AllocPalette
579644
*}
580645
procedure SDL_FreePalette(palette: PSDL_Palette); cdecl;
581646
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FreePalette' {$ENDIF} {$ENDIF};
582647

583648
{**
584-
* Maps an RGB triple to an opaque pixel value for a given pixel format.
649+
* Map an RGB triple to an opaque pixel value for a given pixel format.
650+
*
651+
* This function maps the RGB color value to the specified pixel format and
652+
* returns the pixel value best approximating the given RGB color value for
653+
* the given pixel format.
654+
*
655+
* If the format has a palette (8-bit) the index of the closest matching color
656+
* in the palette will be returned.
585657
*
586-
* SDL_MapRGBA
658+
* If the specified pixel format has an alpha component it will be returned as
659+
* all 1 bits (fully opaque).
660+
*
661+
* If the pixel format bpp (color depth) is less than 32-bpp then the unused
662+
* upper bits of the return value can safely be ignored (e.g., with a 16-bpp
663+
* format the return value can be assigned to a Uint16, and similarly a Uint8
664+
* for an 8-bpp format).
665+
*
666+
* \param format an SDL_PixelFormat structure describing the pixel format
667+
* \param r the red component of the pixel in the range 0-255
668+
* \param g the green component of the pixel in the range 0-255
669+
* \param b the blue component of the pixel in the range 0-255
670+
* \returns a pixel value
671+
*
672+
* \since This function is available since SDL 2.0.0.
673+
*
674+
* \sa SDL_GetRGB
675+
* \sa SDL_GetRGBA
676+
* \sa SDL_MapRGBA
587677
*}
588678
function SDL_MapRGB(const format: PSDL_PixelFormat; r: cuint8; g: cuint8; b: cuint8): cuint32; cdecl;
589679
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MapRGB' {$ENDIF} {$ENDIF};
590680

591681
{**
592-
* Maps an RGBA quadruple to a pixel value for a given pixel format.
682+
* Map an RGBA quadruple to a pixel value for a given pixel format.
683+
*
684+
* This function maps the RGBA color value to the specified pixel format and
685+
* returns the pixel value best approximating the given RGBA color value for
686+
* the given pixel format.
687+
*
688+
* If the specified pixel format has no alpha component the alpha value will
689+
* be ignored (as it will be in formats with a palette).
593690
*
594-
* SDL_MapRGB
691+
* If the format has a palette (8-bit) the index of the closest matching color
692+
* in the palette will be returned.
693+
*
694+
* If the pixel format bpp (color depth) is less than 32-bpp then the unused
695+
* upper bits of the return value can safely be ignored (e.g., with a 16-bpp
696+
* format the return value can be assigned to a Uint16, and similarly a Uint8
697+
* for an 8-bpp format).
698+
*
699+
* \param format an SDL_PixelFormat structure describing the format of the
700+
* pixel
701+
* \param r the red component of the pixel in the range 0-255
702+
* \param g the green component of the pixel in the range 0-255
703+
* \param b the blue component of the pixel in the range 0-255
704+
* \param a the alpha component of the pixel in the range 0-255
705+
* \returns a pixel value
706+
*
707+
* \since This function is available since SDL 2.0.0.
708+
*
709+
* \sa SDL_GetRGB
710+
* \sa SDL_GetRGBA
711+
* \sa SDL_MapRGB
595712
*}
596713
function SDL_MapRGBA(const format: PSDL_PixelFormat; r: cuint8; g: cuint8; b: cuint8; a: cuint8): cuint32; cdecl;
597714
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_MapRGBA' {$ENDIF} {$ENDIF};
598715

599716
{**
600-
* Get the RGB components from a pixel of the specified format.
717+
* Get RGB values from a pixel in the specified format.
718+
*
719+
* This function uses the entire 8-bit [0..255] range when converting color
720+
* components from pixel formats with less than 8-bits per RGB component
721+
* (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
722+
* 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
601723
*
602-
* SDL_GetRGBA
724+
* \param pixel a pixel value
725+
* \param format an SDL_PixelFormat structure describing the format of the
726+
* pixel
727+
* \param r a pointer filled in with the red component
728+
* \param g a pointer filled in with the green component
729+
* \param b a pointer filled in with the blue component
730+
*
731+
* \since This function is available since SDL 2.0.0.
732+
*
733+
* \sa SDL_GetRGBA
734+
* \sa SDL_MapRGB
735+
* \sa SDL_MapRGBA
603736
*}
604737
procedure SDL_GetRGB(pixel: cuint32; const format: PSDL_PixelFormat; r: pcuint8; g: pcuint8; b: pcuint8); cdecl;
605738
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetRGB' {$ENDIF} {$ENDIF};
606739

607740
{**
608-
* Get the RGBA components from a pixel of the specified format.
741+
* Get RGBA values from a pixel in the specified format.
742+
*
743+
* This function uses the entire 8-bit [0..255] range when converting color
744+
* components from pixel formats with less than 8-bits per RGB component
745+
* (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
746+
* 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
747+
*
748+
* If the surface has no alpha component, the alpha will be returned as 0xff
749+
* (100% opaque).
750+
*
751+
* \param pixel a pixel value
752+
* \param format an SDL_PixelFormat structure describing the format of the
753+
* pixel
754+
* \param r a pointer filled in with the red component
755+
* \param g a pointer filled in with the green component
756+
* \param b a pointer filled in with the blue component
757+
* \param a a pointer filled in with the alpha component
609758
*
610-
* SDL_GetRGB
759+
* \since This function is available since SDL 2.0.0.
760+
*
761+
* \sa SDL_GetRGB
762+
* \sa SDL_MapRGB
763+
* \sa SDL_MapRGBA
611764
*}
612765
procedure SDL_GetRGBA(pixel: cuint32; const format: PSDL_PixelFormat; r: pcuint8; g: pcuint8; b: pcuint8; a: pcuint8); cdecl;
613766
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetRGBA' {$ENDIF} {$ENDIF};
614767

615-
{**
616-
* Calculate a 256 entry gamma ramp for a gamma value.
768+
{/**
769+
* Calculate a 256 entry gamma ramp for a gamma value.
770+
*
771+
* \param gamma a gamma value where 0.0 is black and 1.0 is identity
772+
* \param ramp an array of 256 values filled in with the gamma ramp
773+
*
774+
* \since This function is available since SDL 2.0.0.
775+
*
776+
* \sa SDL_SetWindowGammaRamp
617777
*}
618778
procedure SDL_CalculateGammaRamp(gamma: cfloat; ramp: pcuint16); cdecl;
619779
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_CalculateGammaRamp' {$ENDIF} {$ENDIF};

0 commit comments

Comments
 (0)