access violation and pointers question (SDL)

Hi,

If I have any more than ten pointers to ten different sprite sheets i get an access violation on any pointer after that. Any help would be appreciated.

Cheers.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

        image=SDL_DisplayFormat(SDL_LoadBMP("A/run.BMP"));
	image2=SDL_DisplayFormat(SDL_LoadBMP("B/jump.BMP"));
	image3=SDL_DisplayFormat(SDL_LoadBMP("A/roll.bmp"));
	image4=SDL_DisplayFormat(SDL_LoadBMP("B/parry.bmp"));
	image5=SDL_DisplayFormat(SDL_LoadBMP("A/side_step.bmp"));
	image6=SDL_DisplayFormat(SDL_LoadBMP("B/flip.bmp"));
	image7=SDL_DisplayFormat(SDL_LoadBMP("A/roundHouse.bmp"));
	image8=SDL_DisplayFormat(SDL_LoadBMP("B/punch.bmp"));
	image9=SDL_DisplayFormat(SDL_LoadBMP("A/sweep.bmp"));
	image10=SDL_DisplayFormat(SDL_LoadBMP("B/block.bmp"));





The number of pointers doesn't matter.

What's probably happening is that SDL_LoadBMP is failing (maybe because the filename is wrong), and therefore you are passing a null pointer to SDL_DisplayFormat which causes an access violation because it's expecting a non-null pointer.

Double check to make sure all of these are loading properly.
.....Does it matter that my sprites are 640 x 480 and 30 frames, and that memory runs out maybe?
Is 640x480 the size of a whole sheet or a single frame on a sheet? Ten images of 640x480 shouldn't make much of dent.
I suppose it's possible, but not very likely. If you have 10 images at 30*640*480, that would use about 351 MB of video memory (assuming SDL puts these in video memory -- but I'm doubtful of that). Since these are surfaces for blitting, it's probably putting them in system memory... where 351 MB is considerable, but not something crash worthy.


Did you confirm that the load is failing? Once you are sure that is the problem, the next step would be to check the error code/message to see why it's failing. Much better to have SDL tell you what's wrong rather than you trying to guess blindly.

I'm pretty sure SDL has an error reporting function. SDL_GetError maybe? Look it up in the docs.

EDIT: fixed my math.
EDIT 2: fixed my math again.
Last edited on
@Lachlan Easton--- It's the size of a single frame on a sprite sheet ( image). I have 3 rows of 10 of 640 x 480 frames . 30 frames total, and I have 14 sprite sheets. Mondo!


@Disch-- hmmm, I added four more ( total of 14 now) sprite sheets and it works, I think you were right about me some how messing up the filename SDL_LoadBitmap. I double checked the names this time. The debugger was saying that I had NULL pointers before. Thanks for your help.
Topic archived. No new replies allowed.