SDL_MapRGB konvertiert eine RGB Farbe in eine möglichst ähnliche Farbe in dem gegebene Pixel Format.
#include <SDL.h> Uint32 SDL_MapRGB(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b);
Das Zielformat (Beispielsweise aus SDL_Surface::format)
Die RGB Farbkomponenten.
Um eine Farbe im Bildschirmformat zu erhalten kann man wie folgt vorgehen:
// Fenster erstellen SDL_Surface *screen = SDL_SetVideoMode(312, 61, 16, SDL_DOUBLEBUF); // Rote Farbe im Bildschirmformat Uint32 red_color = SDL_MapRGB(screen->format, 255, 0, 0);