2.0 indexed-color Surfaces, how to?

I’m porting old code that was written in the era of 8-bit indexed color. The code loads sprites into an array of uint8 mallocs. To draw, it gets the Surface->pixels and then memcopies into it. It draws an entire screen and then SDL_Flips. I’m using the Migration Guide’s section on software rendered screens, building a Texture on my Renderer and using that to screen flip.

According to the thread “Indexed color still around for SDL2?”, it shouldn’t make much of a difference what my Texture is like, because it’s supposed to magically convert from the Surface to the Texture. That’s good, because any attempt to make a surface other than SDL_PIXELFORMAT_ARGB8888 fails on my machine.

So then it looks like the solution is to make the right Surface. The docs seem to suggest that using SDL_CreateRGBSurface and setting the depth to 8-bit is going to do what I want.

But that doesn’t seem to be working for me. I do get graphics, but they are mis-aligned so you get the old vertical-hold and venetian-blind problems.

Any advice?

This sounds like a bug. Can you report it on bugzilla.libsdl.org and
include a simple test case (with images?)

Thanks!On Thu, Jun 26, 2014 at 8:55 AM, Maury Markowitz <maury.markowitz at gmail.com> wrote:

I’m porting old code that was written in the era of 8-bit indexed color.
The code loads sprites into an array of uint8 mallocs. To draw, it gets the
Surface->pixels and then memcopies into it. It draws an entire screen and
then SDL_Flips. I’m using the Migration Guide’s section on software
rendered screens, building a Texture on my Renderer and using that to
screen flip.

According to the thread “Indexed color still around for SDL2?”, it
shouldn’t make much of a difference what my Texture is like, because it’s
supposed to magically convert from the Surface to the Texture. That’s good,
because any attempt to make a surface other than SDL_PIXELFORMAT_ARGB8888
fails on my machine.

So then it looks like the solution is to make the right Surface. The docs
seem to suggest that using SDL_CreateRGBSurface and setting the depth to
8-bit is going to do what I want.

But that doesn’t seem to be working for me. I do get graphics, but they
are mis-aligned so you get the old vertical-hold and venetian-blind
problems.

Any advice?


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

Sam Lantinga wrote:

This sounds like a bug. Can you report it on bugzilla.libsdl.org (http://bugzilla.libsdl.org) and include a simple test case (with images?)

Done… but I’m not sure this isn’t just something in my code. Do you have a Mac to test on?

Yup! If you provide a minimal example with the bug report, I’ll be happy
to check it out.On Mon, Jul 7, 2014 at 1:08 PM, Maury Markowitz <maury.markowitz at gmail.com> wrote:

Sam Lantinga wrote:

This sounds like a bug. Can you report it on bugzilla.libsdl.org and
include a simple test case (with images?)

Done… but I’m not sure this isn’t just something in my code. Do you have
a Mac to test on?


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

Oh, this is an easy fix. You want to create your texture with
SDL_TEXTUREACCESS_STREAMING. None of the renderers currently support 8 bit
textures, and the texture upload code assumes you’re uploading in the
format of the texture. So, you just need to convert from 8-bit to 32-bit
right before the texture update. The easiest way to do this is to do a blit
from your 8 bit surface to a 32-bit surface and then upload from that.On Thu, Jun 26, 2014 at 8:55 AM, Maury Markowitz <maury.markowitz at gmail.com> wrote:

I’m porting old code that was written in the era of 8-bit indexed color.
The code loads sprites into an array of uint8 mallocs. To draw, it gets the
Surface->pixels and then memcopies into it. It draws an entire screen and
then SDL_Flips. I’m using the Migration Guide’s section on software
rendered screens, building a Texture on my Renderer and using that to
screen flip.

According to the thread “Indexed color still around for SDL2?”, it
shouldn’t make much of a difference what my Texture is like, because it’s
supposed to magically convert from the Surface to the Texture. That’s good,
because any attempt to make a surface other than SDL_PIXELFORMAT_ARGB8888
fails on my machine.

So then it looks like the solution is to make the right Surface. The docs
seem to suggest that using SDL_CreateRGBSurface and setting the depth to
8-bit is going to do what I want.

But that doesn’t seem to be working for me. I do get graphics, but they
are mis-aligned so you get the old vertical-hold and venetian-blind
problems.

Any advice?


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