Targa Loader - .tga image issues

Started by
12 comments, last by DeschutesCore 23 years, 2 months ago
Does anyone know what editor NeHe uses to create his tga files? I''ve written a TGA image loader for my Delphi OpenGL projects and the .tga files included in his demos load fine. If I create a new tga file in PSP7 or Photoshop, use one from Quake3, or use one from any other source, they appear pure white. Any ideas on this one BTW? Jason
Advertisement
It could be your photo program but just for something for you to try. I had that same problem a while back. Where no matter what I did it was pure white. I discovered that I had not enabled textures. I don''t know how you would do it with TGA files. Haven''t done that tutorial yet, but with the way NeHe sets it up to do it with BMP''s do the following in InitGL()
glEnable(GL_TEXTURE_2D);

Hope this helps!
L.I.G. == Life Is Good
No, the issue isn''t texturing.

Nehe''s .tga files display just fine. Other ones display white. I''ve used two different professional packages(3DStudio Max 3.1 and Adobe PhotoShop) in addition to Paint Shop Pro. This isn''t an issue of poor specification support by the programs generating the tga files, it''s my loader and something about nehe''s images.

Nehe''s .tga file texture my quad just fine, as do bitmaps. If I load his font.tga file, it display, if I edit it in all the above programs, it still works, but if I create a new one, it display''s pure white. I''ve even ensured that the Alpha channel names match exactly, even though alpha isn''t even being looked at yet.

I appreciate your time and response Running_Wolf.

Jason
Did you save the Alpha channel? Without a aplpha channel, then you can get the white effect you are talking since it has no data...

(Of course, not all .tga files have alpha, but you loader should check for that.)

Thanks for the reply Elixer.

I am 100% sure the alpha is there and intact. I make my selection, save it as an alpha channel, then close the image and reload it to make sure. I''ve loaded a new image from the channel to back myself up on this one. Nothing.

This one is baffling me.

Jason
Are you sure you''re saving the TGA''s without compression enabled? His loader can only handle un-compressed TGA''s.


http://www.gdarchive.net/druidgames/
Null and Void,
That was it exactly. 256k without compression, 213k with. I noticed the file sizes after you asked me that, and they are indeed working now.

Now that I can create images I can see mself, I just need to figure out why the .tga images are tinted blue.

Thank you!
Hiho,
you should not only car about RLE but also about the top-down alignment. Some programs like ACDSee 32 save the TGA from the first line down to the last. Some others do it the other way round. So if your texture is sometimes displayed 180° round then you have to switch the Top-Down-Orientation off.
As far as your blue tinting,

Did you remember to flip the blue and red channels??

TGA''s file spec I believe states that they store the image in BGR format, as opposed to the RGB format. Perhaps that is why your images appear blue-tinted?

Hope it helps,

-mihkael
Thanks for the reply Mihkael.

I''ve already fixed it and updated my site with the new loader a few days ago. My problem wasn''t an issue of not trying to swap, I wasn''t paying attention to the fact that Targa files are stored BGRA, not just BGR like bitmaps. I had to change the 3 to a 4 and it finally functioned correctly.

// Here''s the code that works, it was I * 3 that caused the problems
for I :=0 to Width * Height - 1 do
begin
Front := Pointer(Cardinal(pData) + I * 4);
Back := Pointer(Cardinal(pData) + I * 4 + 2);
Temp := Front^;
Front^ := Back^;
Back^ := Temp;
end;

I appreciate everyone taking the time to help with my little problem. I''m currently working on a set of decompression functions next. I''m sure I''ll be asking more questions.


This topic is closed to new replies.

Advertisement