SDL_DisplayFormatAlpha(3)

πŸ’– SDL_DisplayFormatAlpha πŸ’–

okay bestie, this is a page from the SDL API Reference β€” it's SDL_DisplayFormatAlpha(3), and she is that girl for getting your surfaces display-ready. let's get into it 🫢


✨ NAME ✨

SDL_DisplayFormatAlpha β€” convert a surface to the display format. literally her whole job πŸ’…


🌸 SYNOPSIS 🌸

#include "SDL.h"

SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface);

πŸ¦‹ DESCRIPTION πŸ¦‹

so what she does is: she takes a surface and copies it onto a brand new surface ✨ β€” one that has the pixel format and colors of the video framebuffer, plus an alpha channel. the whole point? it's suitable for fast blitting onto the display surface. no cap, that's the vibe. 🌈

and under the hood she calls SDL_ConvertSurface, so like… she's doing the convert thing for you, you're welcome πŸ’–

πŸŽ€ pro tip from your girl: if you wanna take advantage of hardware colorkey or alpha blit acceleration, you gotta set the colorkey and the alpha value before you call this function. before, bestie. the order matters. πŸ™ˆ

she can also be used to convert a colourkey to an alpha channel β€” but only if the SDL_SRCCOLORKEY flag is set on the surface. and when that happens? the generated surface will be:

  • transparent (alpha=0) wherever the pixels match the colourkey πŸ«₯
  • opaque (alpha=255) everywhere else πŸ‘‘

iconic behaviour honestly. transparent in the right places, solid in the rest. periodt. ✨


πŸ’€ RETURN VALUE πŸ’€

if the conversion fails, or she runs out of memory? she returns NULL. that's it. that's the whole answer. check your pointers bestie 😭


πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_ConvertSurface
  • SDL_SetAlpha
  • SDL_SetColorKey
  • SDL_DisplayFormat
  • SDL_Surface

and that's the whole page!! this one's from the SDL crew, dated Tue 11 Sep 2001, 23:01 β€” yes the date is ancient, she's a legacy queen and we respect her πŸ’œ mwah, go make something pretty πŸŽ€βœ¨πŸ’…

πŸ“¦ where this page comes from