Archived

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

x33

releasing objects in DirectDraw

Recommended Posts

I''m new to DirectX programming and I''m trying to create DDraw wrapper. I got stuck with coding my destructors. I have a DDraw object, the primary surface, the backbuffer surface (it is a simple offscreen surface, cause i need my app to run windowed, i''m doing blitting from backbuffer to the primary surface instead of page flipping) and the clipper object which is attached to the primary surface. I initalize my DDraw in this order: 1. Create the DDraw object and initialize it. 2. Create the primary surface. 3. Create the off-screen surface to use it as a backbuffer. 4. Create the clipper and attach it to the primary surface. So my question is: in what order should I release objects? I tried everything but I get errors (Not DX errors, but system)when exiting my app (I think WM_DESTROY processing code is a good place for releasing DDraw objects). The second question is: where to get info on managing DDraw objects in windowed mode? How to be sure that there are no memory leaks? "I''ll be Bach!" (c) Johann Sebastian Schwarzenegger

Share this post


Link to post
Share on other sites
Have you tried to debug your app in "single-step" mode and find out at which instruction the error occours?
What does the system errormessage look like?
I''m not quite sure if the order of releasing DirectX interfaces is of any importance at all but i release them in opposite order of creating them which works fine.

Share this post


Link to post
Share on other sites
The error is the most famous one =) "This application has performed an illegal operation and will be shutdown"...
And how do i debug in single-step mode?

"I'll be Bach!" (c) Johann Sebastian Schwarzenegger

[edited by - x33 on March 16, 2003 12:58:01 PM]

Share this post


Link to post
Share on other sites
if you are using Visual C++ 6.0 (may also work for earlier or later version but i don`t know) you need to set a breakpoint to a line of code near the point on which you suppose your app to crash. You do this by setting the cursor to that line and pressing "F9" (or clicking "Set Breakpoint" in the debug menu). Now you run the app in Debug mode (F5). It will automatically stop when it reaches the breakpoint. You can go through every line of code step by step by either pressing F10 or selecting "Single Step" from the debug toolbar. By doing so, you can also check the value of your interface pointers by the time you try to release them.

The error is most likely to occur when trying to perform operations with a non-valid (NULL-)pointer.

Share this post


Link to post
Share on other sites