How to mark certain pixels as Alpha (Erase Pixels)

I want to erase pixels , mark them as alpha. I have tried the following
code.
Uint32 *pixels = (Uint32 *)surface->pixels;
pixels[20 * surface->w + 20] = SDL_MapRGBA(surface->format,255,255,255,0);
surface->pixels = pixels;

Though , 20x20 is still not alpha , I have tried it with
SDL_MapRGBA(surface->format,0,0,0,255) and it paints the pixels as black.

Is this SDL 1.2 or SDL2? (Since you’re using surfaces… If you’re on
SDL2, I suspect you’d be better off using textures - but that depends
on what you’re doing.)

Either way, you need to actually enable alpha blending to make use of
the alpha channel. In SDL2, that’s done with
SDL_SetSurfaceBlendMode().On Sat, Feb 6, 2016 at 2:28 PM, Parikshit Singh wrote:

I want to erase pixels , mark them as alpha. I have tried the following
code.
Uint32 *pixels = (Uint32 *)surface->pixels;
pixels[20 * surface->w + 20] = SDL_MapRGBA(surface->format,255,255,255,0);
surface->pixels = pixels;

Though , 20x20 is still not alpha , I have tried it with
SDL_MapRGBA(surface->format,0,0,0,255) and it paints the pixels as black.


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


//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.— Games, examples, libraries, scripting, sound, music, graphics —.
| http://consulting.olofson.net http://olofsonarcade.com |
’---------------------------------------------------------------------’