BOOL DXContext::StartOrRestartDevice(DXCONTEXT_PARAMS *pParams) { // call this to [re]initialize the DirectX environment with new parameters. // examples: startup; toggle windowed/fullscreen mode; change fullscreen resolution; // and so on. // be sure to clean up all your DirectX stuff first (textures, vertex buffers, // D3DX allocations, etc.) and reallocate it afterwards! // note: for windowed mode, 'pParams->disp_mode' (w/h/r/f) is ignored. if (!m_ready) { // first-time init: create a fresh new device return Internal_Init(pParams, TRUE); } else { // re-init: preserve the DX9 object (m_lpD3D), // but destroy and re-create the DX9 device (m_lpDevice). m_ready = FALSE; //SafeRelease(m_lpDevice); // but leave the D3D object! // RestoreWinamp(); return Internal_Init(pParams, FALSE); } }
BOOL DXContext::StartOrRestartDevice(DXCONTEXT_PARAMS *pParams) { // call this to [re]initialize the DirectX environment with new parameters. // examples: startup; toggle windowed/fullscreen mode; change fullscreen resolution; // and so on. // be sure to clean up all your DirectX stuff first (textures, vertex buffers, // D3DX allocations, etc.) and reallocate it afterwards! // note: for windowed mode, 'pParams->disp_mode' (w/h/r/f) is ignored. // destroy old window if (myWindowState.me) { m_ignore_wm_destroy = 1; if (m_current_mode.screenmode == WINDOWED) SaveWindow(); DestroyWindow(myWindowState.me); myWindowState.me = NULL; m_ignore_wm_destroy = 0; m_hwnd=0; } else if (m_hwnd) { SendMessage(m_hwnd_winamp, WM_WA_IPC, NULL, IPC_SETVISWND); m_ignore_wm_destroy = 1; DestroyWindow(m_hwnd); m_ignore_wm_destroy = 0; m_hwnd = NULL; } if (!m_ready) { // first-time init: create a fresh new device return Internal_Init(pParams, TRUE); } else { // re-init: preserve the DX9 object (m_lpD3D), // but destroy and re-create the DX9 device (m_lpDevice). m_ready = FALSE; SafeRelease(m_lpDevice); // but leave the D3D object! RestoreWinamp(); BOOL rv = Internal_Init(pParams, FALSE); #ifdef MEDIAMONKEY // HACK: post a message to remove the empty VisOut frame, this will come in after we have the new window made. if (pParams && pParams->screenmode == WINDOWED) { PostMessage(m_hwnd, MEDIAMONKEY_HIDE_VISOUT_MSG, 0, 0); } #endif return rv; } }