Hi. I was wondering if someone could help me out, because I’m utterly baffled.
I created a class for Animated Surfaces. It basically just contiains a tiled
surface, and methods for drawing only a certain tile. Multiple calls (on the
order of 10-15…the specific call that does it changes each time) to its
constructor eventually produce an error “Unhandled exception at 0x77f52f9c in
ATC Game.exe: 0xC0000005: Access violation reading location 0x0091a2ad”
I checked 0x0091a2ad in memory,and it’s completely blank.
If I turn on the Debug heap in memory, it runs fine in the debugger, but crashes
in Explorer (Access violation 0xC0000005 in NTDLL.DLL).
The code for the constructor is:
SDL_AnimSurface(char *filename,short unsigned int Frame_W,short unsigned int
Frame_H,short unsigned int Frame_Count)
{
TColor = 0;
temp = 0;
GFX = SDL_LoadBMP(filename);
Frame_Width = Frame_W;
Frame_Height = Frame_H;
Number_of_Frames = Frame_Count;
TColor = SDL_MapRGB(GFX->format,255, 255, 255);
temp = SDL_SetColorKey(GFX, SDL_SRCCOLORKEY, TColor);
if (temp < 0)
{
fprintf(stderr, "Init Transparency failed :", SDL_GetError());
};
};
…
Using breakpoints, it seems to happen inside the “SDL_SetColorKey()” function…
before that line, all my variables (temp, GFX, TColor, SDL_SRCCOLORKEY) are
fine. While inside it, it crashes, and the debugger shows all my variables as
garbage.
Any help would be mucho appreciated.