Hi !
As many have noticed when we move Neuz window the game freeze, ie game loop isn't running.
This can cause several problems with network, calculation of monsters positions, etc ...
Here is a short homemade tutorial to correct this ;)
File: _DirectX\d3dapp.h
After lines:
Add:
It's a simple variable to indicate when user is moving the window.
File: _DirectX\d3dapp.cpp
After lines:
Add:
To initialize our variable.
Then in function LRESULT CD3DApplication::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) replace lines:
By:
And lines:
By:
When user moves the window, the game loop isn't running but the function MsgProc is still called for WM_TIMER messages so we just have to use a timer to update the game.
To finish in function HRESULT CD3DApplication::Render3DEnvironment() replace line:
By:
It seems IsDrawTiming doesn't work when the window is moving and I don't know why, so I added this and it works fine.
Edit: If you got an error with USER_TIMER_MINIMUM non identified, replace it by 0x0000000A :)
There you go ! ;)
As many have noticed when we move Neuz window the game freeze, ie game loop isn't running.
This can cause several problems with network, calculation of monsters positions, etc ...
Here is a short homemade tutorial to correct this ;)
File: _DirectX\d3dapp.h
After lines:
Code:
class CD3DApplication
{
Code:
private:
bool m_movingOrSizingWindow;
File: _DirectX\d3dapp.cpp
After lines:
Code:
CD3DApplication::CD3DApplication()
{
Code:
m_movingOrSizingWindow = false;
Then in function LRESULT CD3DApplication::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) replace lines:
Code:
case WM_ENTERSIZEMOVE:
// Halt frame movement while the app is sizing or moving
Pause( true );
break;
Code:
case WM_ENTERSIZEMOVE:
// Halt frame movement while the app is sizing or moving
//Pause(true);
SetTimer(hWnd, 1, USER_TIMER_MINIMUM, NULL);
m_movingOrSizingWindow = true;
break;
case WM_TIMER:
if (wParam == 1 && m_bActive)
{
if (FAILED(Render3DEnvironment()))
SendMessage(m_hWnd, WM_CLOSE, 0, 0);
}
break;
Code:
case WM_EXITSIZEMOVE:
Pause( false );
HandlePossibleSizeChange();
break;
Code:
case WM_EXITSIZEMOVE:
//Pause(false);
//HandlePossibleSizeChange(); // We can't resize Neuz window
KillTimer(hWnd, 1);
m_movingOrSizingWindow = false;
break;
To finish in function HRESULT CD3DApplication::Render3DEnvironment() replace line:
Code:
if( IsDrawTiming() )
Code:
if (IsDrawTiming() || m_movingOrSizingWindow)
Edit: If you got an error with USER_TIMER_MINIMUM non identified, replace it by 0x0000000A :)
There you go ! ;)