TGA Loading??

Started by
3 comments, last by OleKaiwalker 20 years, 11 months ago
Hey, I''m building a TGA loader, but I have a BIG problem!! My code --> GLvoid CTextureTGA::LoadTGA(char* strFileName){ GLbyte TGAHeader[3] = {0}; FILE *fileTGA; if (!(fileTGA = fopen(strFileName, "rb"))) return; if (!(fread(TGAHeader, sizeof(GLbyte), 3, fileTGA))) return; if (TGAHeader[2] == 2) LoadUncompressedTGA(strFileName, fileTGA); else if (TGAHeader[2] == 10) return; else return; } GLvoid CTextureTGA::LoadUncompressedTGA(char *strFileName, FILE *fileTGA){ GLbyte TGAHeader[6]; fread(TGAHeader, sizeof(GLbyte), 6, fileTGA); } The first time it reads the TGA header alright (I think), but second time in the second function (LoadUncompressedTGA) it dosn''t read the header... It just gives me a array filled with zeros??? What''s wrong???
Advertisement
hm i always thought the TGA headers are 12 bytes long
so why don t you load the 12 bytes all at once ?

your header should look like this

GLubyte TGAheader[12]={0,0,2,0,0,0,0,0,0,0,0,0};
and the width and so on are stored in another 6 byte chunk i think
so i think i have answered your question

load a 12 byte chunk and compare it with the TGAheader show above

if(memcmp!=0)
return;
and then read the other 6 bytes to get the width and the bits per pixel

http://www.8ung.at/basiror/theironcross.html
jepp... 12 bytes long header.
...and what is the first parameter to CTextureTGA::LoadUncompressedTGA for?
our new version has many new and good features. sadly, the good ones are not new and the new ones are not good
you don t need it :D

it confused me quite a bit at first:D
http://www.8ung.at/basiror/theironcross.html
Thx...

The problem is solved!! Yes the first parameter for LoadUncompressed() is a mistake...

By anyways - thx again!

This topic is closed to new replies.

Advertisement