And I can use the following method when changing the Resolution?
IDirect3DStateBlock9* pStateBlock = NULL; m_pDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlock); pStateBlock->Capture(); pStateBlock->Apply(); pStateBlock->Release();
Thanks
IDirect3DStateBlock9* pStateBlock = NULL; m_pDevice->CreateStateBlock(D3DSBT_ALL, &pStateBlock); pStateBlock->Capture(); pStateBlock->Apply(); pStateBlock->Release();
void DxManager::ChangeScreenResolution(int iWidth, int iHeight, bool bFullscreen){ if(bFullscreen && m_pFullscreen) // If we are fullscreen already.. if((iWidth == m_pWidth) && (iHeight == m_pHeight)) return; // Already in requested mode. d3dpp.Windowed = !bFullscreen; d3dpp.BackBufferWidth = iWidth; d3dpp.BackBufferHeight = iHeight; if(!bFullscreen) { RECT client = {0, 0, iWidth, iHeight}; AdjustWindowRect(&client, WS_OVERLAPPEDWINDOW, false); d3dpp.FullScreen_RefreshRateInHz = 0; d3dpp.BackBufferFormat = D3DFMT_R5G6B5; SetWindowLongPtr(wndHandle, GWL_STYLE, WS_POPUP); SetWindowPos(wndHandle, HWND_TOP, 100, 100, client.right, client.bottom, SWP_NOZORDER | SWP_SHOWWINDOW); } else { d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT; d3dpp.BackBufferFormat = D3DFMT_R5G6B5; SetWindowLongPtr(wndHandle, GWL_STYLE, WS_POPUP); SetWindowPos(wndHandle, HWND_TOP, 0, 0, iWidth, iHeight, SWP_NOZORDER | SWP_SHOWWINDOW); } direct3dDevice->Reset(&d3dpp); return; }
Quote:
my thinking is correct?
//some managed "resources" have OnLostDevice()/OnResetDevice() methods//so you dont need to recreate them from scratch//they can "survive" device->Reset() methodvoid DxManager::OnPreReset()//function to release all res.{ effect1->OnLostDevice(); effect2->OnLostDevice(); effect3->OnLostDevice(); ... //release dynamic V/I B's vertexBuffer1->Release(); vertexBuffer2->Release(); indexBuffer1->Release(); ...}void DxManager::OnPostReset()//function to recreate res.{ effect1->OnResetDevice(); effect2->OnResetDevice(); effect3->OnResetDevice(); ... //here create V/I B's again from scratch ...}void DxManager::ChangeScreenResolution(int iWidth, int iHeight, bool bFullscreen)//your function{ //ommited your code ... OnPreReset(); device->Reset(newParams) hr = device->TextCooperativeLevel();//check if succeded if (succesfuly reseted ) { OnPostReset(); } ...}
Quote:...d3dpp.Windowed = !bFullscreen;//why '!' if you pass bFullscreen as parametar?//d3dpp.Windowed = bFullscreen;//should be this...