SDL_DisplayFormat(3)

πŸ’– SDL_DisplayFormat(3) πŸ’–

okay bestie, welcome to the SDL API Reference ✨ this one's a lil glow-up function and it's honestly so useful, let's get into it 🫢


🌸 NAME 🌸

SDL_DisplayFormat β€” converts a surface to the display format πŸ’…


✨ SYNOPSIS ✨

#include "SDL.h"

SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface);

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, this function takes a surface and copies it onto a brand new surface β€” one that's in the pixel format and colors of the video framebuffer. why do we care?? because that makes it suitable for fast blitting onto the display surface. it's giving speed, it's giving optimized, it's giving main character energy fr fr πŸ”₯

and the way it does that? it calls SDL_ConvertSurface. periodt πŸ’…

✨ pro tip moment ✨ if you wanna take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and the alpha value before you call this function. timing is everything bestie, do it first or it just won't hit the same 😭

and if you're out here wanting an alpha channel? that's a whole different function β€” go see SDL_DisplayFormatAlpha 🧚


πŸ’€ RETURN VALUE πŸ’€

if the conversion fails, or it runs out of memory, it returns NULL. that's it, that's the whole thing. no cap. so pls pls pls check your return value πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

  • SDL_ConvertSurface
  • SDL_DisplayFormatAlpha
  • SDL_SetAlpha
  • SDL_SetColorKey
  • SDL_Surface

that's the page bestie!! 🌈 this was the SDL manpage, dated Tue 11 Sep 2001, 23:01 β€” yeah she's vintage but she still ate πŸ’– go forth and blit fast, ily, bye!! πŸŽ€πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from