Sign in to follow this  
neodingo

SDL Issues [solved]

Recommended Posts

neodingo    103
I'm using Visual Studio 2005 Beta 2 with the latest stable release of SDL and SDL_image. When I use IMG_Load() to load an image and then attempt to use SDL_DisplayFormat() to get the image into the display format for faster blitting, i get an error saying... Unhandled exception at 0x1002706f (SDL.dll) in TINQ DX.exe: 0xC0000005: Access violation reading location 0x00000000. The offending piece of code is as follows.
SDL_Surface* image = IMG_Load("tex.png");
SDL_Surface* tmp = SDL_DisplayFormat(image);
SDL_FreeSurface(image);
image = tmp;


Any ideas ? [Edited by - neodingo on June 9, 2005 10:54:45 AM]

Share this post


Link to post
Share on other sites
Dave Hunt    4872
The most likely cause is that the IMG_Load() function is failing and, therefore, returning NULL. Then you pass NULL to SDL_DisplayFormat() and get the exception. If you check the return value from IMG_Load(), you can catch the error before calling SDL_DisplayFormat().

It is probably just a case of the current directory when executing the application not being where the image file is actually stored.

Share this post


Link to post
Share on other sites
Yamian    100
Yes, if ur coming from a Dev-C++ environtment, ur dirctories had to be relative to the excutable. But in VC7(not sure about 8) the files are relative to the project file, not the executble(which would be like Debug or Release folder which si where u don't want ur images to be).

Share this post


Link to post
Share on other sites
neodingo    103
That was it, I always forget where to place the files in a VCC project. Thanks for the help, I can't believe I failed to think of that. Just comes to show that you should never skimp on the error checking. Well, now I can go cause more havoc.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this