// // SDLVideoDriver::ShutdownGraphicsPartway // // haleyjd: It was necessary to separate this code from I_ShutdownGraphics // so that the ENDOOM screen can be displayed during shutdown. Otherwise, // the SDL_QuitSubSystem call below would cause a nasty crash. // void SDLVideoDriver::ShutdownGraphicsPartway() { // haleyjd 06/21/06: use UpdateGrab here, not release UpdateGrab(); sdlscreen = NULL; UnsetPrimaryBuffer(); }
// // SDLVideoDriver::ShutdownGraphicsPartway // // haleyjd: It was necessary to separate this code from I_ShutdownGraphics // so that the ENDOOM screen can be displayed during shutdown. Otherwise, // the SDL_QuitSubSystem call below would cause a nasty crash. // void SDLVideoDriver::ShutdownGraphicsPartway() { // haleyjd 06/21/06: use UpdateGrab here, not release UpdateGrab(window); if(sdltexture) { SDL_DestroyTexture(sdltexture); sdltexture = nullptr; } SDL_DestroyRenderer(renderer); renderer = nullptr; SDL_DestroyWindow(window); window = nullptr; UnsetPrimaryBuffer(); }
// // SDLVideoDriver::InitGraphicsMode // // killough 11/98: New routine, for setting hires and page flipping // sf: now returns true if an error occurred // bool SDLVideoDriver::InitGraphicsMode() { // haleyjd 06/19/11: remember characteristics of last successful modeset static int fallback_w = 640; static int fallback_h = 480; static int fallback_w_flags = SDL_WINDOW_ALLOW_HIGHDPI; // SDL_RENDERER_SOFTWARE causes failures in creating renderer static int fallback_r_flags = SDL_RENDERER_TARGETTEXTURE; bool wantfullscreen = false; bool wantdesktopfs = false; bool wantvsync = false; bool wanthardware = false; bool wantframe = true; int v_w = 640; int v_h = 480; int v_displaynum = 0; int window_flags = SDL_WINDOW_ALLOW_HIGHDPI; // SDL_RENDERER_SOFTWARE causes failures in creating renderer int renderer_flags = SDL_RENDERER_TARGETTEXTURE; // haleyjd 04/11/03: "vsync" or page-flipping support if(use_vsync) wantvsync = true; // haleyjd 07/15/09: set defaults using geom string from configuration file I_ParseGeom(i_videomode, &v_w, &v_h, &wantfullscreen, &wantvsync, &wanthardware, &wantframe, &wantdesktopfs); // haleyjd 06/21/06: allow complete command line overrides but only // on initial video mode set (setting from menu doesn't support this) I_CheckVideoCmds(&v_w, &v_h, &wantfullscreen, &wantvsync, &wanthardware, &wantframe, &wantdesktopfs); // Wanting vsync forces framebuffer acceleration on if(wantvsync) { SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1"); renderer_flags |= SDL_RENDERER_PRESENTVSYNC; } else if(wanthardware) SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "1"); else SDL_SetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION, "0"); // haleyjd 10/27/09 if(!wantframe) window_flags |= SDL_WINDOW_BORDERLESS; if(displaynum < SDL_GetNumVideoDisplays()) v_displaynum = displaynum; else displaynum = 0; if(!(window = SDL_CreateWindow(ee_wmCaption, SDL_WINDOWPOS_CENTERED_DISPLAY(v_displaynum), SDL_WINDOWPOS_CENTERED_DISPLAY(v_displaynum), v_w, v_h, window_flags))) { // try 320x200w safety mode if(!(window = SDL_CreateWindow(ee_wmCaption, SDL_WINDOWPOS_CENTERED_DISPLAY(v_displaynum), SDL_WINDOWPOS_CENTERED_DISPLAY(v_displaynum), fallback_w, fallback_h, fallback_w_flags))) { // SDL_TODO: Trim fat from this error message I_FatalError(I_ERR_KILL, "I_SDLInitGraphicsMode: couldn't create window for mode %dx%d;\n" " Also failed to restore fallback mode %dx%d.\n" " Check your SDL video driver settings.\n", v_w, v_h, fallback_w, fallback_h); } // reset these for below population of video struct v_w = fallback_w; v_h = fallback_h; window_flags = fallback_w_flags; } #if EE_CURRENT_PLATFORM == EE_PLATFORM_MACOSX // this and the below #else block are done here as monitor video mode isn't // set when SDL_WINDOW_FULLSCREEN (sans desktop) is ORed in during window creation if(wantfullscreen) SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); #else if(wantfullscreen && wantdesktopfs) SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); else if(wantfullscreen) // && !wantdesktopfs SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN); #endif if(!(renderer = SDL_CreateRenderer(window, -1, renderer_flags))) { if(!(renderer = SDL_CreateRenderer(window, -1, fallback_r_flags))) { // SDL_TODO: Trim fat from this error message I_FatalError(I_ERR_KILL, "I_SDLInitGraphicsMode: couldn't create renderer for mode %dx%d;\n" " Also failed to restore fallback mode %dx%d.\n" " Check your SDL video driver settings.\n", v_w, v_h, fallback_w, fallback_h); } fallback_r_flags = renderer_flags; } // Record successful mode set for use as a fallback mode fallback_w = v_w; fallback_h = v_h; fallback_w_flags = window_flags; fallback_r_flags = renderer_flags; // haleyjd 10/09/05: keep track of fullscreen state fullscreen = !!(SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_DESKTOP); UpdateFocus(window); UpdateGrab(window); // check for letterboxing if(I_VideoShouldLetterbox(v_w, v_h)) { int hs = I_VideoLetterboxHeight(v_w); staticDestRect.x = 0; staticDestRect.y = static_cast<Sint16>(I_VideoLetterboxOffset(v_h, hs)); staticDestRect.w = static_cast<Uint16>(v_w); staticDestRect.h = static_cast<Uint16>(hs); video.width = v_w; video.height = hs; destrect = &staticDestRect; } else { video.width = v_w; video.height = v_h; destrect = nullptr; } video.bitdepth = 8; video.pixelsize = 1; UnsetPrimaryBuffer(); SetPrimaryBuffer(); // haleyjd 11/12/09: set surface palettes immediately I_SDLSetPaletteDirect(static_cast<byte *>(wGlobalDir.cacheLumpName("PLAYPAL", PU_CACHE))); return false; }