I noticed I got the error from D3D9:
Direct3D9: (ERROR) :GetClientRect Failed ?
It was trying to call LPDIRECT3DDEVICE9's function Present(); But my window has terminated.
I have a function called Main() that looks like this
void Main()
{
InitGame();
//Main loop
while(MsgCheck())
{
Input();
Logic();
Render();
}
QuitGame();
return;
}
Which is called from WinMain(). MsgCheck looks like this
bool MsgCheck()
{
while(PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE))
{
if(msg.message==WM_QUIT)
return false;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return true;
}
If I press the X button in the right cornor of the window, shouldn't it send a WM_QUIT message to the window and then it checks for WM_QUIT in the MsgCheck() function and if the message is WM_QUIT it returns false which causes the loop in Main() to fail thus running QuitGame() ? Where am I wrong?