TGA Loading??
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???
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
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
jepp... 12 bytes long header.
...and what is the first parameter to CTextureTGA::LoadUncompressedTGA for?
...and what is the first parameter to CTextureTGA::LoadUncompressedTGA for?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement