Jump to content
  • Advertisement
Sign in to follow this  
sascoo

sprite-draw problems

This topic is 3760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently having an unhandled exception when i call the sprite->draw function. It is really weird because I made a temporary sprite and called the draw function right after I loaded my model and it worked there. I call all of these functions so I know that the sprite is getting initialized and I cannot figure out what my problem is... Error: Unhandled exception at 0x6d15ead5 in Engine.exe: 0xC0000005: Access violation reading location 0x00000044. void SpriteBatch::Initialize(Graphics *graphics) { this->graphics = graphics; if (!SUCCEEDED(D3DXCreateSprite((LPDIRECT3DDEVICE9)(graphics->*(graphics->GetGraphicsDevice))(),&p_Sprite))) MessageBox(NULL,"Sprite Creation Failed","Error",MB_OK); } void SpriteBatch::Begin(DWORD value) { p_Sprite->Begin(value); } void SpriteBatch::Draw(Texture2D &texture, Vector3 &position, D3DCOLOR color) { p_Sprite->Draw(texture.GetTexture(),NULL, NULL, &Vec3ToD3D(position),color); } void SpriteBatch::End() { p_Sprite->End(); } btw how do I post code snippets correctly? I spent a fair amount of time searching and failed. Thanks, John

Share this post


Link to post
Share on other sites
Advertisement
An access violation is usually caused by an invalid pointer.

I would guess that your texture is invalid for some reason. Did you check the error codes when you created and loaded it?

I can't remember where the posting semantics are. You can find them if you know where they are, though. :-)

To post small amounts of code use [ c ] ..code.. [ /c ] but NO spaces between the brackets! I put it in that way so it won't be interpreted as a code snippet.

To post larger amounts of code you can use [ source ] ..code.. [ /source ] but NO spaces!

Don't forget to click "Show Preview" to see what you're going to post before posting.

Share this post


Link to post
Share on other sites
Wow that D3DXCreateSprite function call is an absolute mess...why on earth do you have a cast there? All a cast would serve to do in this case is cover up a compiler error.

Share this post


Link to post
Share on other sites
Ahh I found my problem. For some reason when I loaded my texture I passed it by value instead of by reference and then I released the texture inside the loader... doh

Quote:
Wow that D3DXCreateSprite function call is an absolute mess...why on earth do you have a cast there? All a cast would serve to do in this case is cover up a compiler error.


I am using function pointers in my graphics class and that function returns a void*. That code is just temporary and will be cleaned up. I just wanted to make sure it was drawing correctly.

Thanks,
John

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!