The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
2.0 indexed-color Surfaces, how to?
Maury Markowitz


Joined: 23 Jun 2014
Posts: 5
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?
2.0 indexed-color Surfaces, how to?
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
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 wrote:
Quote:
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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Re: 2.0 indexed-color Surfaces, how to?
Maury Markowitz


Joined: 23 Jun 2014
Posts: 5
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?
2.0 indexed-color Surfaces, how to?
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
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 wrote:
Quote:



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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2.0 indexed-color Surfaces, how to?
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
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 wrote:
Quote:
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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org