[SDL] SDL 2.0: Loading textures on iOS with alpha

Sam Lantinga slouken at libsdl.org
Tue Feb 7 18:59:06 PST 2012


I'm glad you figured it out! :)

On Tue, Feb 7, 2012 at 4:08 PM, Atis <atis at aol.es> wrote:

>
> OK, so after looking at what SDL_SetAlpha() actually did,
> turns out I needed to disable blending on the source surface using
>
>   SDL_SetSurfaceBlendMode(img, SDL_BLENDMODE_NONE);
>
> Thanks for listening,
> Atis
>
> -----Original Message-----
> From: Atis <atis at aol.es>
> To: sdl <sdl at lists.libsdl.org>
> Sent: Tue, 7 Feb 2012 22:42
> Subject: [SDL] SDL 2.0: Loading textures on iOS with alpha
>
>
>
> -----
>
> int bpp;
> Uint32 Rmask, Gmask, Bmask, Amask;
> SDL_PixelFormatEnumToMasks(SDL_PIXELFORMAT_ABGR8888, &bpp, &Rmask,
>                           &Gmask, &Bmask, &Amask);
> SDL_Surface *img_rgba8888 = SDL_CreateRGBSurface(0, img->w, img->h, bpp,
>                                                  Rmask, Gmask, Bmask,
> Amask);
> SDL_SetAlpha(img, SDL_RLEACCEL, 0);
> SDL_BlitSurface(img, NULL, img_rgba8888, NULL);
>
> uint pow_w = nearest_pow2(img->w);
> uint pow_h = nearest_pow2(img->h);
> glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pow_w, pow_h, 0, GL_RGBA,
>             GL_UNSIGNED_BYTE, NULL);
> glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, img->w, img->h, GL_RGBA,
>                GL_UNSIGNED_BYTE, img_rgba8888->pixels);
>
> -----
>
> > Summary: the above texture loading code messes up image alpha
> > values. Not sure what to do. Please help!
>
> _______________________________________________
> 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/20120207/30080788/attachment-0008.htm>


More information about the SDL mailing list