extern "C" DLL void rglDDrawActivate(unsigned char active) { HRESULT rval; if (WINDOWED || lpDD == NULL) { return; } if (active) { if (!bActive) { for (;;) { rval = lpDD->SetDisplayMode(SCRWIDTH, SCRHEIGHT, 16); if (rval == DD_OK) { break; } if (rval == DDERR_SURFACELOST) { if (!restoreAll()) { break; } } } bActive = TRUE; } } else { if (bActive) { for (;;) { rval = lpDD->RestoreDisplayMode(); if (rval == DD_OK) { break; } if (rval == DDERR_SURFACELOST) { if (!restoreAll()) { break; } } } bActive = FALSE; } } }
~WSurfaceData() { if (clipper) clipper->Release(); if (LeftBuffer) ((LPDIRECTDRAWSURFACE)LeftBuffer)->Release(); if (RightBuffer) ((LPDIRECTDRAWSURFACE)RightBuffer)->Release(); if (screen) screen->Release(); if (ddraw) { if (!window_mode) ddraw->RestoreDisplayMode(); ddraw->Release(); } LeftBuffer=RightBuffer=0; ddraw=0,screen=0; }
int dd_SetMode(int xres, int yres, int bpp, bool windowflag) { HRESULT hr; if (!dd_initd) dd_init(); //do this now for the gamewindow, because this is the first time we know what size to make the gamewindow if(!dd_bGameWindowRectInitialized) { RECT r; dd_gameWindow->adjust(xres,yres,&r); int base_win_x_res = getInitialWindowXres(); int base_win_y_res = getInitialWindowYres(); /// this is for the windowsize verge.cfg vars. if( base_win_x_res > 0 && base_win_y_res > 0 ) { int win_offset_x = (r.right-r.left) - xres; int win_offset_y = (r.bottom-r.top) - yres; dd_gameWindow->winw = win_offset_x+base_win_x_res; dd_gameWindow->winh = win_offset_y+base_win_y_res; } else { dd_gameWindow->winw = r.right-r.left; dd_gameWindow->winh = r.bottom-r.top; } WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(dd_gameWindow->hwnd,&wp); wp.rcNormalPosition.left = GetSystemMetrics(SM_CXSCREEN)/2-xres/2; wp.rcNormalPosition.top = GetSystemMetrics(SM_CYSCREEN)/2-yres/2; wp.rcNormalPosition.right = wp.rcNormalPosition.left + dd_gameWindow->winw; wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + dd_gameWindow->winh; SetWindowPlacement(dd_gameWindow->hwnd,&wp); dd_bGameWindowRectInitialized = true; } //must deactivate all auxwindows if(vid_window && !windowflag) for(std::vector<dd_Window*>::iterator it = dd_windows.begin(); it != dd_windows.end(); it++) { if(!(*it)->bGameWindow) (*it)->deactivate(); } if (!windowflag) { //if we are switching into fullscreen, we are going to lose these sizes and positions //save them now so we can restore them when we flip back to windowmode if(vid_window) { WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(dd_gameWindow->hwnd,&wp); dd_gameWindow->winx = wp.rcNormalPosition.left; dd_gameWindow->winy = wp.rcNormalPosition.top; dd_gameWindow->winw = wp.rcNormalPosition.right - wp.rcNormalPosition.left; dd_gameWindow->winh = wp.rcNormalPosition.bottom - wp.rcNormalPosition.top; dd_bWasMaximized = (wp.showCmd == SW_SHOWMAXIMIZED); } //ShowWindow(dd_gameWindow->hwnd,SW_SHOWMAXIMIZED); ShowWindow(dd_gameWindow->hwnd,SW_HIDE); int ret = dd_gameWindow->set_fullscreen(xres,yres,bpp); if(!ret) return 0; ShowWindow(dd_gameWindow->hwnd,SW_SHOW); dd_gameWindow->xres = xres; dd_gameWindow->yres = yres; vid_xres = xres; vid_yres = yres; vid_window = false; dd_bHasBeenFullscreen = true; dd_RegisterBlitters(); return ret; } else { DX_RELEASE(dx_ps); DX_RELEASE(dx_win_ps); if (bpp != DesktopBPP) return 0; if (!vid_window) dx_dd->RestoreDisplayMode(); dx_dd->SetCooperativeLevel(dd_gameWindow->hwnd, DDSCL_NORMAL); hr = dx_dd->CreateSurface(&dx_win_psd, &dx_win_ps, NULL); if (hr != DD_OK) { return 0; } int ret = dd_gameWindow->set_win(xres,yres,bpp); if(!ret) return 0; if(dd_bHasBeenFullscreen) { WINDOWPLACEMENT wp; wp.length = sizeof(WINDOWPLACEMENT); GetWindowPlacement(dd_gameWindow->hwnd,&wp); wp.rcNormalPosition.left = dd_gameWindow->winx; wp.rcNormalPosition.top = dd_gameWindow->winy; wp.rcNormalPosition.right = wp.rcNormalPosition.left + dd_gameWindow->winw; wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + dd_gameWindow->winh; SetWindowPlacement(dd_gameWindow->hwnd,&wp); if(dd_bWasMaximized) ShowWindow(dd_gameWindow->hwnd,SW_SHOWMAXIMIZED); } //must activate all auxwindows if(!vid_window) for(std::vector<dd_Window*>::iterator it = dd_windows.begin(); it != dd_windows.end(); it++) if(!(*it)->bGameWindow) (*it)->activate(); //bring the gamewindow back to the front SetWindowPos(dd_gameWindow->hwnd,HWND_TOP,0,0,0,0,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE); dd_gameWindow->xres = xres; dd_gameWindow->yres = yres; vid_xres = xres; vid_yres = yres; vid_window = true; dd_RegisterBlitters(); return 1; } return 0; }