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
How to mark certain pixels as Alpha (Erase Pixels)
Parikshit Singh
Guest

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

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
How to mark certain pixels as Alpha (Erase Pixels)
David Olofson
Guest

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:
Quote:
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

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 |
'---------------------------------------------------------------------'
_______________________________________________
SDL mailing list

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