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.
if (KEY_DOWN(VK_ESCAPE))
{
Game_Shutdown(); //Close music, shutdown sound and shutdown graphics
PostQuitMessage(0);
}
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
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
return 0;
int GFX_Shutdown(void)
{
if (lpddsback)
lpddsback->Release();
if (lpddsprimary)
lpddsprimary->Release();
if (lpdd)
lpdd->Release();
}
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.