SDL Issues [solved]

Started by
2 comments, last by neodingo 18 years, 10 months ago
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]
Advertisement
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.
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).
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.

This topic is closed to new replies.

Advertisement