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
Simple Directmedia Layer Forums
Unable to properly blend textures when using transparent png
Moon Mooner
Guest
Posted: Mon Sep 28, 2015 1:55 am
So I'm having this problem with textures while working on a game. Let me explain:I have a .png, all of its pixels are white (RGB = 255, 255, 255) and have alpha values equal to 0. I load that png to a texture, this is supposed to be transparent texture. I create second texture from actual drawings for the game. When I put the transparent texture on the top of the actual game image - nothing gets displayed on the screen. Because the transparent texture doesn't have any non-0 alpha pixels, it shouldn't affect the drawings on the screen, right? It's like blending mode get set to SDL_BLENDMODE_NONE for this case.Â
I tried setting the blending for the textures to SDL_BLENDMODE_BLEND (although the textures are created with the same blend mode as far as I know), I tried changing the renderer's blend mode still (from desperation) - nothing. The problem doesn't seem to appear if I have non-transparent pixels on texture. Why is this happening? Can I make the blending actually work in this way? Â
Thanks
Danni111111
Joined: 30 Aug 2015
Posts: 5
Posted: Mon Sep 28, 2015 10:35 pm
Hi,
Have you set the rederer to the right blend mode?
Code:
SDL_SetRenderDrawBlendMode(*Render Name Here*, SDL_BLENDMODE_BLEND);