Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Weird data corruption

This topic is 5651 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

Hi! I''m working on a project for the GBA but I think the problem is more of a general programming issue so I''ll post it here. Sorry this post is a little long, if anyone might know how to get around this problem I''d really appreciate some tip or help! I made a graphics class which manages sprites and things like that, and I made a binary tree class to allow associative indexing based on character strings. So, for example, instead of having the graphics.LoadImage() function return an Image structure or something like that, you do this: graphics.LoadImage(ptrToImageData, "dragon"); Then, when you want to display the picture, you just say: graphics.DrawImage("dragon", x, y); Anyways, I have a global instance of the Graphics class which is used throughout the code. Now, the problem is that in one function, (call it MainFunction() or whatever) I have loaded an image. If I try to draw the image within the same function, everything works fine. However, say I call another function from MainFunction() and then *that* function (call it MiddleFunction()) tries to draw the image. That''s where it fails.. For some reason, the program tries searching the binary tree to retrieve the pointer to the image and the search fails (it''s not in the tree). I''m pretty confused. I mean, if I try calling DrawImage() Right before calling MiddleFunction(), the search does not fail. But if I move the call to DrawImage() into MiddleFunction(), it stops working. There shouldn''t be any difference between calling DrawImage() from MainFunction() vs. calling it from MiddleFunction(), because either way the same code is being executed, unless there''s some weird stuff that happens in the function call that I''m not aware of. Hmm, well again sorry for such a long post, if anyone might know how to fix this problem please let me know! Thanks so much! Raj

Share this post

Link to post
Share on other sites

  • 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!