Original Post
Hello people!
I've been working on a 2D platform game with my DirectX and C++ engine, and It's coming along nice (considering that I just learned DirectX 5 weeks ago). Anyway, now I'm trying to implement the toggle fullscreen at runtime functionality on the engine but I'm having some problems...
This is the code I'm using:
When i press alt+enter the window style is the only thing that changes, the game keeps running and accepting input but the game screen is frozen.
Anyone knows what am I doing wrong????
I've been working on a 2D platform game with my DirectX and C++ engine, and It's coming along nice (considering that I just learned DirectX 5 weeks ago). Anyway, now I'm trying to implement the toggle fullscreen at runtime functionality on the engine but I'm having some problems...
This is the code I'm using:
void Engine::ToggleFullScreen(bool value)
{
DWORD dwStyle, dwExStyle;
D3DDISPLAYMODE dm;
this->mD3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dm);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = !value;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.EnableAutoDepthStencil = true;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.hDeviceWindow = mWindowHandle;
d3dpp.BackBufferCount = 1;
d3dpp.BackBufferFormat = dm.Format;
if(value)
{
d3dpp.BackBufferWidth = dm.Width;
d3dpp.BackBufferHeight = dm.Height;
dwStyle = WS_POPUP;
dwExStyle = WS_EX_APPWINDOW;
ShowCursor(false);
}
else
{
d3dpp.BackBufferWidth = gEngine->GetScreenWidth();
d3dpp.BackBufferHeight = gEngine->GetScreenHeight();
dwStyle = WS_OVERLAPPED | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX;
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
ShowCursor(true);
}
mSpriteHandler->OnLostDevice();
HRESULT hRes = mDevice->Reset(&d3dpp);
mSpriteHandler->OnResetDevice();
SetWindowLong(mWindowHandle, GWL_STYLE, dwStyle);
SetWindowLong(mWindowHandle, GWL_EXSTYLE, dwExStyle);
ShowWindow(mWindowHandle, SW_SHOW);
}
When i press alt+enter the window style is the only thing that changes, the game keeps running and accepting input but the game screen is frozen.
Anyone knows what am I doing wrong????