basic TGA question

Started by
14 comments, last by clint8565 19 years, 4 months ago
I'm using lesson 32 and it runs fine, but if I try to edit one of the images it can't load the TGA anymore, can someone please help me
Advertisement
Make sure you are saving them in the correct format. I'm not sure if lesson 32's tga loader supports compressed TGAs. TGAs have lots of options with how they are saved, like compressed, flipped, color depth, alpha channel.. etc..
ummm... when I go to save my TGA I don't get any options, it just saves it

I get all kinds of options for PNG, does someone know how to load them in Dev C++?
I think devpaks.org has a PNG library.
there is a bug in the nehe TGA load code witch makes tga files from PSP8+ not be able to load, but PSP7 saved tga files still work.

It has to do with the idHeader, psp7 doesn't save it but psp8 does(i guess it's the same with other programs to).
the nehe TGA load code asumes that it doesn't exist.

to fix it add
char tgaID[256]; // TGA header

to the beginning of the file right after
TGAHeader tgaheader; // Used To Store Our File Header

and in both LoadCompressedTGA and LoadUncompressedTGA add

	if(tgaheader[0])	{		if(fread(&tgaID, tgaheader[0], 1, fTGA) == 0)					// Read TGA ID		{													if(fTGA != NULL)													// if file is still open			{				fclose(fTGA);													// Close it			}			return false;														// Return failular		}		}


right after

	if((texture->width <= 0) || (texture->height <= 0) || ((texture->bpp != 24) && (texture->bpp !=32)))	// Make sure all information is valid	{		if(fTGA != NULL)													// Check if file is still open		{			fclose(fTGA);													// If so, close it		}		return false;														// Return failed	}


This should fix it, perhaps with a little fiddeling.
thanks lc_overlord, but I don't know how to fix the errors

TGALoader.cpp In function `bool LoadUncompressedTGA(Texture*, char*, FILE*)':
85 TGALoader.cpp no match for 'operator[]' in 'tgaheader[0]'
89 TGALoader.cpp `lg' undeclared (first use this function)
89 TGALoader.cpp `CF_ERROR' undeclared (first use this function)

and the same for LoadCompressedTGA



thanks vampyre_dark, could you tell me how to use the devpak? I can't find a help or any examples

[Edited by - clint8565 on November 25, 2004 2:16:17 PM]
Hmm i might have revritten the code just a little bit to mutch.

You can delete line 89 it's just a part of my error logger, so remove it.

the bug on line 85 is a bit tricky, but if you replace tgaheader[0] with a char and take the first byte from the header and put it in that char.

my tga header is just a array of 12 chars, witch makes it more easy to read the compression type.
Perhaps i should just take the lesson 32 code, modify it and put it on the web.
Quote:Original post by clint8565

thanks vampyre_dark, could you tell me how to use the devpak? I can't find a help or any examples


I've never used it before. You're going to need to find the header, and the libray file. Read the header (or a readme.txt).
I'm guessing it's

libping.a
libping.h
lc_overlord, if you want to mod one of the tut's for on the web you could use 33 it's the same, at least for the TGA part, 33's a lot simpler that's all

umm... I got rid of line 89, but I'm not exactly sure what to do with tgaheader[0]

do you mean like make a variable
char something = tgaheader[0]; ?
Is this a crosspost?

These questions a related, so I think one thread would have been enough.
Anyway, glad you found the answer. [wink]

This topic is closed to new replies.

Advertisement