Access violation reading location

Started by
12 comments, last by Evil Steve 17 years, 11 months ago
Did you neglect to call the ID3DXSprite::Begin and ::End functions? Are you sure that you correctly loaded the texture file into car_image?

You should also check the HRESULT with:

if (FAILED(hr))

or

if (SUCCEEDED(hr))
--------------------------Most of what I know came from Frank D. Luna's DirectX books
Advertisement
Good news, I changed the location of the D3DXCreateSprite function call and by magic and the grace of god it works again.

Just for the record, I do actually have the Begin and End functions.

Also when I checked the vlaues during debugging I found that sprite_handler had a normal value while car_image, barrier etc had the 0xcdcdcdcd value.

Thank you very much to everyone who helped me, I REALLY appreciate it.

Quote:Original post by BryanSpence
Good news, I changed the location of the D3DXCreateSprite function call and by magic and the grace of god it works again.
.


Danger, Will Robinsons... Danger.

If you don't understand WHY it now works, please pause the spaceship and examine the code until you do. Failure to do so will result in you being mobbed by big, scary space BUGS.

It most likely failed because you
a) Didn't initialize the textures or
b) Called the Draw function before you initalized the textures.

Setting pointers to NULL is a good idea because:
a) in Release mode, VC won't help you out by resetting memory to 0xCDCDCDCD
b) you can verify pointers before you use them:
if (car_image){sprite_handler->Draw(car_image, NULL, NULL,&position,D3DCOLOR_XRGB(255,255,255));}   
------------------------------ BOOMZAPTry our latest game, Jewels of Cleopatra
I completely agree with __ODIN__. Also, install the debug runtimes and link with d3dx9d.lib in debug builds! If you had them installed, then D3DX would validate the pointers, realise it wasn't valid and let you know in the debug output.

Your variable isn't getting initialized, either because you're not creating it, or you're releasing it somehow (Which I don't think is the case, because then the debugger would use a value other than 0xcdcdcdcd).

You really need to find out what's wrong here. Not doing anything will just cause huge problems later on when another part of your code breaks and suddenly this bug pops up again.

This topic is closed to new replies.

Advertisement