LoadBMP faling

Hello everyone!

I have been messing around and reading up on SDL. To get to the point, simple SDL program that puts the SDL logo on the screen. Everything compiles and links fine. The thing is that when I execute the program from within VC++ I keep getting:

Unhandled exception at 0x1002b1cf in SDL Test.exe: 0xC0000005: Access violation reading location 0x00000000.

at: SDL_Surface* temp = SDL_LoadBMP(“sdl.bmp”);

I’m guessing LoadBMP is failing. That’s part of the problem.

When I go to my actual .exe and run it manually (no VC++), it works fine! I looked all over the place for this and I couldn’t find anything on it.

Sum up: With VC++ the app doesn’t work. When I run it on it’s own, it works fine.

Any suggestions?------------

I’ve never used VC++, but a guess is that it is running your
executable in a different directory, causing LoadBMP to fail (it
can’t find the file), and when you attempt to blit it segfaults.
You should check the return value of SDL_LoadBMP and take action
appropriately instead of blindly assuming it works.

Miguel M. writes:> Hello everyone!

I have been messing around and reading up on SDL. To get to the point, simple SDL program that puts the SDL logo on the screen. Everything compiles and links fine. The thing is that when I execute the program from within VC++ I keep getting:

Unhandled exception at 0x1002b1cf in SDL Test.exe: 0xC0000005: Access violation reading location 0x00000000.

at: SDL_Surface* temp = SDL_LoadBMP(“sdl.bmp”);

I’m guessing LoadBMP is failing. That’s part of the problem.

When I go to my actual .exe and run it manually (no VC++), it works fine! I looked all over the place for this and I couldn’t find anything on it.

Sum up: With VC++ the app doesn’t work. When I run it on it’s own, it works fine.

Any suggestions?



Free POP3 Email from www.Gawab.com
Sign up NOW and get your account @gawab.com!!

“but a guess is that it is running your executable in a different directory, causing LoadBMP to fail
(it can’t find the file),”

It gets me so mad b/c I thought about that but did nothing. Turns out I had to but the bmp in the PROJECT directory. I learn from experience.

Thanks Kevin!------------