[SDL] colorkey in SDL_Texture

MBrening micah.brening at gmail.com
Mon Dec 20 14:27:11 PST 2010


You might need to post some code.  According to the example code, it should be as follows:

temp = SDL_LoadBMP(file);
SDL_SetColorKey(temp, SDL_TRUE, key);
sprite = SDL_CreateTextureFromSurface(0, temp);

One thing I noticed is that with SDL_SetColorKey, if the second argument is 0 it disables the ColorKey.

The CreateTextureFromSurface should take the colorkey data and set it to an Alpha channel set to 0.

I hope that helps!
If not, try posting some code.
Also, look at the LoadSprite function in the testspriteminimal.c in the test folder of the SDL Mercurial.

T-1000 wrote:
> I am porting a project to SDL 1.3 from SDL 1.2
> I need to use a colorkey for my sprites and when i do 
> SDL_CreateTextureFromSurface(surface) i loose the colorkey info in the 
> SDL_Surface and all the pixels are rendered.
> How can i use a SDL_Texture with colorkey?
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20101220/d97c8216/attachment-0008.htm>

More information about the SDL mailing list