Jump to content
  • Advertisement
Sign in to follow this  
finky45

OpenGL TGA loading crash (from Nehe's site)

This topic is 3849 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've tried to switch from BMPS to TGAS in this game I'm making, and found NeHe's tutorials. I basically copied (by hand at first - to get a better understanding) the tutorial from the site, just to see if it would work. Well it didn't. After trying to figure out what was going on, I gave up and resorted to copying and pasting the code from one of the files, with only a few modifications to make it compatible with SDL. I only changed the error reporting code. Long story short it still crashes when I call the function:
fLoadTGA( playerTexture, "res/gfx/Compressed.tga" );

The TGA loading function is identical to the .cpp file in: http://nehe.gamedev.net/data/lessons/devc/lesson33.zip Except for the error boxes, which I replaced with fprint(). I traced the crash to the following line(s) in loading a compressed TGA:
	texture->width  = tga.header[1] * 256 + tga.header[0];					// Determine The TGA Width	(highbyte*256+lowbyte)
	texture->height = tga.header[3] * 256 + tga.header[2];		

It actually crashes at the first line. I tried replacing with manual values just to see if it would get past that line and it still didn't. I'm stumped. I don't really care which TGA loading function or library I use. I don't feel like having to waste time reinventing the wheel, so if anyone knows of a OpenGL library that loads TGAs (and that actually works) could you please point me to it? Or maybe we can fix this one... Any help is much appreciated =)

Share this post


Link to post
Share on other sites
Advertisement
Why do you assume that the library is broken, and not your code? The line you showed, and the problem you descibed, suggests that the texture structure isn't properly allocated, which is a problem in your code.

Share this post


Link to post
Share on other sites
Hey you're right, something I did broke it, but I still can't figure out what it is.

EDIT:

I'm a nubcake. I was using a pointer to a "Texture" instead of a Texture. Thank you Brother Bob, for taking the time to point the error of my ways =)

[Edited by - finky45 on January 6, 2008 1:28:42 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by finky45
...with only a few modifications to make it compatible with SDL...
I've never used it, but if you're already using SDL why not use SDL_image to load images with built-in SDL compatibility? It supports several different image formats 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!