Sign in to follow this  

Transparent .tga with DevIL

This topic is 4598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
What I do for transparency in Photoshop:
1) Make a copy of the lowest layer, most of the time it's called 'Background'.
2) Delete the lowest layer.
3) Use the eraser on the copy.

Now you should see a checkered grid which represents transparency in PS.

Share this post


Link to post
Share on other sites

This topic is 4598 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this