I'm updating a program from SDL 1 to SDL 2 and need to use color palettes. Originally, I used SDL_SetColors(screen, color, 0, intColors);
but that does't work in SDL 2. I'm trying to use:
SDL_Palette *palette = (SDL_Palette *)malloc(sizeof(color)*intColors);
SDL_SetPaletteColors(palette, color, 0, intColors);
SDL_SetSurfacePalette(surface, palette);
But SDL_SetPaletteColors()
returns -1 and fails. SDL_GetError
gives me no information.
How can I make a palette from a SDL_Color
and then set it as my surface's palette?