Jump to content
  • Advertisement

Archived

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

Erzengeldeslichtes

Access Violation in Direct Draw

This topic is 5687 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 have a class called cSpriteImageReader that reads images and writes them to a direct draw surface. I have another class called cSprite that creates an array of surfaces (okay, a pointer that then generates a new array of the needed number, then uses the ddraw object to CreateSurface in the pointed to variable). I then have another class called cBoard that manages these sprites (you want a sprite, use cBoard). cBoard has member variables of pointers to sprites it needs. In the initialization it creates these cSprites with new. The cSprites then load the bmp with cSpriteImageReader and draws the information from that onto its array of surfaces. Following so far? Now when the cSprites use cSpriteImageReader's draw, pointing at the already initialized surfaces, it gives me an AccessViolation when the draw function attempts to access the surface (usually for locking purposes, but any other function also causes the problem). My question is... Why? I had an Access Violation before because I attempted to create a surface before initializing Direct Draw (note to self: when using DirectX, use an initialization function rather than the constructer). I fixed that, but now I'm getting it on surfaces that have already been initialized. I can't lock it, I can't unlock it, I can't do anything to it, even though this is being called by a function that had just initialized the surfaces one line before. [edited by - Erzengeldeslichtes on January 23, 2003 8:09:16 PM]

Share this post


Link to post
Share on other sites
Advertisement
You are probably accesing a not initialized pointer (which is pointing to limbo or #CCCCCCC. You should set all your member pointer variables to NULL in your class constructor. Then debug the code and watch every pointer you are using there to see wich one has the problem.

I hope this helps.

Share this post


Link to post
Share on other sites
Yes, my constructer (which creates the initial array) does go through and set all of them to NULL. Then it calls a function that tells my DDraw object to create a new surface on each one of those (and if it can''t, set it to NULL again).
As for Debugging, this has been quite useful, I admit, because it told me of the Access Violation whenever I try to access the surface. If I ran it when it WASN''T in debug mode it would just flash the screen and vanish.

However, watching debug by stepping through has a tendancy to freeze up my computer because my program is fullscreen mode and when it first shows the application window it just freezes up.

Share this post


Link to post
Share on other sites
quote:
Original post by Erzengeldeslichtes
However, watching debug by stepping through has a tendancy to freeze up my computer because my program is fullscreen mode and when it first shows the application window it just freezes up.


Consider implementing a windowed version for debuging, it isn''t more difficult than fullscreen. You computer doesn''t freezes it''s just you stoped the execution, try presing some hot-keys (ENTER, ALT-D, ARROW KEYS) hopefuly you''ll see the menus prompting. Without debug you''re blind.

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!