Skip to content

Instantly share code, notes, and snippets.

@ClearlyKyle
Created January 3, 2022 22:03
Show Gist options
  • Save ClearlyKyle/8ff2185a06fd30af330ab07dc9f20a3c to your computer and use it in GitHub Desktop.
Save ClearlyKyle/8ff2185a06fd30af330ab07dc9f20a3c to your computer and use it in GitHub Desktop.
SDL_Colour to Uint32 for SDL_gfx
Uint32 SDL_Colour_To_Uint32(const SDL_Colour *col)
{
// Must be format AABBGGRR for gfx library
return (Uint32)((col->a << 24) + (col->b << 16) + (col->g << 8) + (col->r << 0));
}
SDL_Colour Uint32_To_SDL_Colour(const Uint32 colour)
{
SDL_Colour tmp;
tmp.a = (colour >> 24) & 0xFF;
tmp.b = (colour >> 16) & 0xFF;
tmp.g = (colour >> 8) & 0xFF;
tmp.r = colour & 0xFF;
return tmp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment