Jump to content
  • Advertisement
Sign in to follow this  
Brigs

OpenGL .OBJ loader texture error

This topic is 3794 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!