[SDL] png transparency in testgl.c from sdl package

David Olofson david at olofson.net
Mon Dec 13 05:06:55 PST 2010


On Monday 13 December 2010, at 04.13.37, "image28" <image28 at slingshot.co.nz> 
wrote:
> changing the line glColor4ub(0,0,0,255); to glColor4ub(0,0,0,128); makes
> all images 50% transparent. for some reason it is using the colour setting
> from that line instead of the individual pixels colour in the texture.

I haven't spotted anything obvious in the code you posted earlier. It seems 
like it should work, provided there actually is an alpha channel i the loaded 
image.

The glColor*() call shouldn't have anything to do with it. Whatever values you 
set for color and alpha that way are only going to scale whatever comes from 
the texture, so 0 means "always zero" and 255 means "use texel data as is."

BTW, restoring the alpha attributes of the new SDL surface shouldn't matter 
either, as OpenGL only ever sees the raw pixel data. Unless you RLE the 
surface, the attributes will only affect the SDL_Surface struct; not the 
actual pixel data.

I would suggest somehow verifying the surface/texture data along the way. 
Print out the values of the alpha channel, to verify that there actually is 
anything but opaque pixels in the surface uploaded. An OpenGL debugger 
(gDEBugger or similar) might give some hints as well.


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

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
|   http://consulting.olofson.net          http://olofsonarcade.com   |
'---------------------------------------------------------------------'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20101213/e4cf622c/attachment-0008.htm>


More information about the SDL mailing list