We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1935 - Problem converting paletted surface to texture
Summary: Problem converting paletted surface to texture
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-02 05:05 UTC by Sebastian
Modified: 2013-10-21 07:43 UTC (History)
0 users

See Also:


Attachments
test programm to reproduce the bug (2.29 KB, text/x-csrc)
2013-07-02 05:05 UTC, Sebastian
Details
Screenshot of the issue (37.84 KB, image/jpeg)
2013-07-12 01:49 UTC, Sebastian
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian 2013-07-02 05:05:14 UTC
Created attachment 1202 [details]
test programm to reproduce the bug

I am trying to convert a paletted surface to a texture and reder it to the screen.
Whe using the renderer I get a garbled output. With the standard non-renderer blit operations the image is fine. 

I attached a small test programm. You'll need stb_truetype.h from (http://nothings.org/stb/stb_truetype.h) and some ttf file.

If you comment the define WITH_RENDERER everything should display just fine. In the other case you get a garbled output.

I have not tested this on any other platforms.

A variation of this code has worked with previous versions of SDL2.
Comment 1 Sam Lantinga 2013-07-12 00:35:59 UTC
I tested this with the latest RC build and it worked fine here, compiled both ways.  Can you check to see if this is fixed for you?

http://www.libsdl.org/tmp/download-2.0.php
Comment 2 Sebastian 2013-07-12 01:49:22 UTC
Created attachment 1220 [details]
Screenshot of the issue
Comment 3 Sebastian 2013-07-12 01:50:53 UTC
I did a clean rebuild of the current HG of SDL2. The issue persists. I have attached a screenshot of the output in both cases.
Is there any more information I can provide to get to the bottom of this?
Comment 4 Sebastian 2013-07-17 02:13:51 UTC
OK, I solved the issue: If i add the line 
colors[i].a = 255;
to the loop at line 52 of the test program the display is just fine.

The problem was, that random memory contents are copied into the palette and the call to SDL_MapRGB to find out the color for SDL_SetColorKey uses those values again.

The SDL documentation states, that the fourth field of the SDL_Color struct is unused. Maybe this should be clarified in the documentation.

For me this issue is resolved. Feel free to close.
Comment 5 Sam Lantinga 2013-10-21 07:43:00 UTC
The documentation has been updated on the wiki, thanks for the feedback!