DD_Shutdown

Started by
14 comments, last by jtecin 24 years, 3 months ago
Pretty sure I have that, here is my code:

if (KEY_DOWN(VK_ESCAPE))
{
Game_Shutdown(); //Close music, shutdown sound and shutdown graphics
PostQuitMessage(0);
}

It seems to work fine in my other programs.
Advertisement
Not sure, but it seems you're trying to use the DDobjects/surfaces after they've been released. If the code from above is placed on the message handler, and you weren't setting the lpdds's and lpdd to zero or not checking in the main blitting/flipping action if they are different from zero, that would mess thing up, since it's possible the drawing will still happen after you release the objects... just a thought.
Hmmmm.....I'm just wndering. I don't know that much about the window procedure but I do know that you have to break after each Window message.

Try putting a break after your PostQuitMessage(0). I think it's because of that why it is doing that stuff.

My reasoning:
If you don't break, it will return DefWindowProc on the end of your Window procedure, in that case it will try to access the DirectDraw stuff again, which will crash, because they don't exist anymore. I'm not quite sure if the postQuitMessage breaks out of it, so........give this a try.

------------------
Dance with me......

http://members.xoom.com/CJdeVos/index.htm

Actually, you'd return 0 - not break. A typical windows message function will break and fall down to the default message handler if you don't return.

I would suggest you make a very simple program that uses your init function, then immediately calls the shutdown function and exits. Don't even start the message loop. See what happens.

If it bombs, it most likely your init functions are not happening. If it works, then somewhere in the other program it's happening.

Also, when you structure your code, I would recomend you place the init function BEFORE the message loop, and the shutdown function AFTER the message loop - don't put either in the message loop under WM_DESTROY or WM_ACTIVE or whatever.


Jim

Okay, I can't understand why this is not working. In my Game_Shutdown function, I call the following function to shut down direct draw:


int GFX_Shutdown(void)
{
if (lpddsback)
lpddsback->Release();
if (lpddsprimary)
lpddsprimary->Release();
if (lpdd)
lpdd->Release();

return 0;
}


Now, I can run my game and stuff and it works fine. But when I quit, this screws everything up. If I don't call this function, the program exits fine. However, I'm supposed to release the surfaces' resources, right? Anyway, I'm pretty sure there is nothing wrong with the actual function, so is there some way I could have screwed this up in a previous function, like initializes it wrong or something? Thanks for any help.

I want to say thanks to all of you who replied as the problem finally got solved. I used PostQuitMessage(0) when escape is pushed and then in WM_QUIT I did Game_Shutdown and then used break. Once again, thanks.

This topic is closed to new replies.

Advertisement