SDL2 + Palletized rendering

Hi,

what’s the proper way to do a palettized application with SDL 2.x? Does SDL 2.x still support palletized displays logically? And physically? Will it work with accelerated rendering or only with SDL_surface?

For example, is it possible to do SDL_CreateWindow, SDL_GetWindowSurface and then set the display color map by calling SDL_SetSurfacePalette on the surface I get?

Can you do accelerated rendering with SDL_render in color indexed mode? I know you can create color indexed palettes, but how do you set the window’s color map then?

Also, how does this work going forward, I believe newer OpenGL versions do not support indexed color very well or at all.

Thanks
-Jiri

You should create a surface with an indexed pixel format then use
SDL_SetPaletteColors, you then use SDL_CreateTextureFromSurface to be
able to render it (Call SDL_CreateTextureFromSurface whenever you
update the palette).

The docs have this to say:
Each pixel in an 8-bit surface is an index into the colors field of
the SDL_Palette structure stored in SDL_PixelFormat. An SDL_Palette
should never need to be created manually. It is automatically created
when SDL allocates an SDL_PixelFormat for a surface. The colors values
of an SDL_Surface’s palette can be set with SDL_SetPaletteColors().On Tue, Nov 26, 2013 at 5:30 AM, Jirik <jirik.svoboda at seznam.cz> wrote:

Hi,

what’s the proper way to do a palettized application with SDL 2.x? Does SDL
2.x still support palletized displays logically? And physically? Will it
work with accelerated rendering or only with SDL_surface?

For example, is it possible to do SDL_CreateWindow, SDL_GetWindowSurface and
then set the display color map by calling SDL_SetSurfacePalette on the
surface I get?

Can you do accelerated rendering with SDL_render in color indexed mode? I
know you can create color indexed palettes, but how do you set the window’s
color map then?

Also, how does this work going forward, I believe newer OpenGL versions do
not support indexed color very well or at all.

Thanks
-Jiri


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Re: “how does it work going forward”. SDL does not render indexed
pixels directly, it coverts them to a non indexed format when you
convert it to a texture.On Wed, Nov 27, 2013 at 4:35 AM, Andre D <@Andre_D> wrote:

You should create a surface with an indexed pixel format then use
SDL_SetPaletteColors, you then use SDL_CreateTextureFromSurface to be
able to render it (Call SDL_CreateTextureFromSurface whenever you
update the palette).

The docs have this to say:
Each pixel in an 8-bit surface is an index into the colors field of
the SDL_Palette structure stored in SDL_PixelFormat. An SDL_Palette
should never need to be created manually. It is automatically created
when SDL allocates an SDL_PixelFormat for a surface. The colors values
of an SDL_Surface’s palette can be set with SDL_SetPaletteColors().

On Tue, Nov 26, 2013 at 5:30 AM, Jirik <jirik.svoboda at seznam.cz> wrote:

Hi,

what’s the proper way to do a palettized application with SDL 2.x? Does SDL
2.x still support palletized displays logically? And physically? Will it
work with accelerated rendering or only with SDL_surface?

For example, is it possible to do SDL_CreateWindow, SDL_GetWindowSurface and
then set the display color map by calling SDL_SetSurfacePalette on the
surface I get?

Can you do accelerated rendering with SDL_render in color indexed mode? I
know you can create color indexed palettes, but how do you set the window’s
color map then?

Also, how does this work going forward, I believe newer OpenGL versions do
not support indexed color very well or at all.

Thanks
-Jiri


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org