Advertisement

tga loading

Started by September 20, 2003 09:53 AM
11 comments, last by Mithoric 21 years, 5 months ago
I followed your tutorial to load tga files and I have it going however when I want alpha the color white becomes transparent. Is there a way to specify another color to be transparent? Or perhaps someone can help me to load png files, it seems to be a bit complex and all the loaders I find need the libraries to be converted into .a files but it doesn''t seem to work for me. Thanks.
quote:
Original post by Mithoric
...when I want alpha the color white becomes transparent. Is there a way to specify another color to be transparent?...

Not in an easy way. Transparency is pulled out from texture's fourth channel (because you're using RGBA, right?) and this works fine in most cases. You'll have to change contents of this channel if you want to change what pixels disappear.
You could use a fragment program to change how alpha is handled but I don't see any good reason to do it.
quote:
Original post by Mithoric
...Or perhaps someone can help me to load png files, it seems to be a bit complex and all the loaders I find need the libraries...

Well, this is not a problem with the file format, however, if you want to get the rid of .tga and go for .png, much better!
Using png is very easy. You can make it work in two days. I can't tell you how right now (I'm in hurry) but I am sure someone will. If they do not, my email is public on my profile.


EDIT: added thing about fp.

[edited by - Krohm on September 20, 2003 1:23:08 PM]

Previously "Krohm"

Advertisement
I''m also having problems loading tgas. When i load a tga that i created in photoshop (with the transparent background) and saved as 32bit. It loads the image all garbled up. But if i save as 24bit it works fine. i first thought it was my code (because i had modified the code from the nehe tga loader), but i tried it with lesson 33 unmodified and it still didn''t work.

If you need a screen capture of what i''m talking about i can post it if needed.
Paulhttp://members.lycos.co.uk/p79
Did you recently download the code? Because I sent in bug corrections to the TGA loader about a month ago. The bugs should be patched now for 32bit tga files.

Also about that alpha masking question, the correction that I sent in to NeHe does make a texture transparent depending on the alpha channel. NeHe removed all that bonus stuff when he uploaded the corrected lesson33. I could email to you my original modifications to lesson33 if you want. Just give me your email.

[edited by - Zy on September 20, 2003 2:31:04 PM]
PsychoPaul : get this patch from adobe to fix the problems with alpha chanel in photoshop : http://www.adobe.com/products/photoshop/update.html

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
yes. i first downloaded the dev-c++ version. didn''t work. so i thought maybe it didn''t get updated so i downloaded the vc++ version and just extracted the tgaloader.h file and recompiled using dev-c++. still didn''t work. though i am not using the original mingw that came with dev-c++ i upated it with one from the mingw web site.
Paulhttp://members.lycos.co.uk/p79
Advertisement
PsychoPaul: the typos in lesson33 are not all in the tgaloader.h. Here is an excerpt from the read me that I sent to NeHe.

--------------------
Summary:

in Lesson33.cpp -

old code had: glTexImage2D(GL_TEXTURE_2D, 0, 3, texture[loop].width, texture[loop].height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture[loop].imageData)

corrected code is: glTexImage2D(GL_TEXTURE_2D, 0, texture[loop].bpp / 8, texture[loop].width, texture[loop].height, 0, texture[loop].type, GL_UNSIGNED_BYTE, texture[loop].imageData);


in TGALoader.cpp - added to the compressed tga loading section

if(texture->bpp == 24)
texture->type = GL_RGB;
else
texture->type = GL_RGBA;

[edited by - Zy on September 20, 2003 2:37:44 PM]
Well i extracted everything from the vc++ file recompiled with dev-c++. now the image loads but whatever is suppose to be transparent is now white (i think it''s the same problem as the other guy).

Also i''m using Photoshop 6. I did the 6.0.1 update after i saw _DarkWing_''s post and it didn''t change much. i''m currently downloading the trial version of PaintShop to see if there is a difference.
Paulhttp://members.lycos.co.uk/p79
PsychoPaul: I''ve emailed to my version of lesson33 to your hotmail account. In my version I only tested tgas that are uncompressed, since I don''t have a program that can compress tgas. The uncompressed tga in my program has an alpha channel.
Zy: Thanks i got it. Umm Something strange is going on because when i use my test tga made in photoshop i get nothing displayed when i use your exe. but when i use the exe from lesson33 vc++. The image shows but whatever is suppose to be transparent is white. Not sure whats going on now.
Paulhttp://members.lycos.co.uk/p79

This topic is closed to new replies.

Advertisement