Skip to main content
gamedev.net
🔒 Locked

.OBJ loader texture error

Started by Brigs Mar 1, 2008 at 10:57 PM 1 replies 850+ views
Original Post
Brigs
Brigs
I'm trying to figure out why the textures on my .obj model don't load when I load the model into opengl. I'm using a .obj loader written by Karl Berg. And here are the spots that display error messages. First one is here..
if (memcmp(RAW_Header, TGAcompare, sizeof(TGAcompare)) == 0)
      fType = 0;
   else if (memcmp(CMP_Header, TGAcompare, sizeof(TGAcompare)) == 0)
      fType = 1;
   else
   {
      printf("error, invalid formatTGA2!\n");
      fclose(in_file);
      return false;
   }
and if I comment out the fail command the next error I get is here..
texture.width  = header[1] * 256 + header[0];
   texture.height = header[3] * 256 + header[2];
   texture.bpp    = header[4];
   if (texture.width <= 0 || texture.height <= 0 || (texture.bpp != 24 && texture.bpp != 32))
   {
      printf("error, invalid formatWidth!\n");
      fclose(in_file);
      return false;
   }
Now I'm pretty sure the second snippet is telling me that my textures are not the right size? they should be 256x256? But what I don't understand is why the first snippet is giving a fail message? What exactly does that part of code check for in a texture file? Thanks.
dpadam450
dpadam450
I really don't know, but are you sure the .obj format even supports textures inside of them? From what little I have read about them, they dont. Maybe hes loading the texture from file?
NBA2K, Madden, Maneater, Killing Floor, Sims 
snoutmate
snoutmate
Quote:
Original post by Brigs
if (memcmp(RAW_Header, TGAcompare, sizeof(TGAcompare)) == 0)      fType = 0;   else if (memcmp(CMP_Header, TGAcompare, sizeof(TGAcompare)) == 0)      fType = 1;   else   {      printf("error, invalid formatTGA2!\n");      fclose(in_file);      return false;   }


and if I comment out the fail command the next error I get is here..

Commenting out part of code because it aborts due to error really won't get you anywhere, instead you should think of *why* you're getting the error in the first place - in this case the code compares the loaded data with TGA image header as a safe-guard that the file you are reading is really Targa image. In your case it is not (it may be that you're loading it wrong) and hence it fails (and any subsequent reading code after that will read rubish and likely fail too).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.