pygame / pygame

🐍🎮 pygame (the library) is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL.
https://www.pygame.org
7.34k stars 3.25k forks source link

SDL2 display.set_palette #2099

Open illume opened 4 years ago

illume commented 4 years ago

set_palette is not supported in SDL2

See display.set_palette PR and issue:

SDL Palette documentation

https://wiki.libsdl.org/SDL_Palette https://wiki.libsdl.org/SDL_SetPaletteColors https://wiki.libsdl.org/SDL_AllocPalette https://wiki.libsdl.org/SDL_FreePalette

pygame.display.set_palette documentation

https://www.pygame.org/docs/ref/display.html#pygame.display.set_palette

 pygame.display.set_palette()
    Set the display color palette for indexed displays
    set_palette(palette=None) -> None

This will change the video display color palette for 8-bit displays. This does not change the palette for the actual display Surface, only the palette that is used to display the Surface. If no palette argument is passed, the system default palette will be restored. The palette is a sequence of RGB triplets.

robertpfeiffer commented 4 years ago

It's easy to emulate this with OpenGL, or to have a layer of indirection to perform the palette swap every time on pygame.display.update. I'm not sure if it's worth implementing the ugly but reliable solution here.

(The ugly but reliable solution would be to do the palette-swap in software. OpenGL is out of the question for reasons of portability. Even doing the swap with Renderer would mean adding fuctionality to upsteam SDL2)

illume commented 3 years ago

From what I can tell, there is no easy solution for this. There are some users of this function, so it's important. However, there's no way to address it before the release of pygame 2 on the 28th of Oct. For these reasons I'll remove the critical label, and this can be added to a list of things that are not compatible (along with cdrom, and scrap) in the release.