Transparent .tga with DevIL

Started by
9 comments, last by Pipo DeClown 18 years, 11 months ago
Hi, trying to load a transparent .tga file with DevIL. The targa file was created from this photoshop file: PSD-file (18kb) and the targa file is here: Targa (3kb)But when loaded with ilutGLLoadImage(), the transparent part is white. Do I have to do something else with the texture to make it partitially transparent? I haven't used tga's before so it is quite possible that the tga isn't even transparent. In that case, how do I turn it transparent in Photoshop?
Advertisement
I opened the tga with the gimp, and it looks like all the alpha is 1.0.

It does have an alpha channel, so I'd guess you're just not exporting it correctly in photoshop. Maybe you forgot to flatten the layers or something?

Anyway, the psd exports to TGA from the gimp just fine.
[size="1"]
goto ps,
click on the channels tab, + then on the create new channel button (u will get an alpha channel ti the texture)
now u can sabe it (make sure u save the tga at 32bit color and not 24)
Oke, consider the tga transparent, do I have to do anything in the code to load the alpha channel?
not much different from rgb to rgba
just change the GL_RGB -> GL_RGBA etc and read 4 bytes for each pixel instead of 3
Quote:Original post by zedzeek
not much different from rgb to rgba
just change the GL_RGB -> GL_RGBA etc and read 4 bytes for each pixel instead of 3


I assume this is if you do it manually, but shouldn't DevIL handle this for me?

EDIT: Maybe this thread should be in "Alternative game libraries"...

[Edited by - PureW on May 16, 2005 8:18:59 AM]
Yeah, DevIL should handle that for you I think. I've just done a quick scout through my code to try and remember if I wrote any special-case code for textures with transparency, but I didn't, and textures with alpha work fine in my engine.
[size="1"]
This code seems to work:

GLuint texTank = ilutGLLoadImage("data/tank.tga"); //Load in the tank-texture
glEnable(GL_ALPHA_TEST); //Enable alpha-blending
glAlphaFunc(GL_GREATER, 0.01f);

But when I rotate the cube, with texTank as texture, some pixels at the edge between the visible and transparent are white. It is very annoying. I guess it has got something to do with filters but I don't know what.
Quote:Original post by PureW
This code seems to work:

GLuint texTank = ilutGLLoadImage("data/tank.tga"); //Load in the tank-texture
glEnable(GL_ALPHA_TEST); //Enable alpha-blending
glAlphaFunc(GL_GREATER, 0.01f);

But when I rotate the cube, with texTank as texture, some pixels at the edge between the visible and transparent are white. It is very annoying. I guess it has got something to do with filters but I don't know what.


More than likely it IS the filters, if you are using linear filtering. You could either use nearest filtering, or increase the minimum alpha test value. (Something like GL_GREATER than 0.6 is safe, that's what I'm using in my alpha'd sprites)
Are you using Photoshop 7.0? If so, the Targa export is broken. There is a free patch at Adobe's website that fixes this problem (among others).
--Michael Fawcett

This topic is closed to new replies.

Advertisement