| 46 | #endif |
| 47 | |
| 48 | bool SpawnWindow(const char *lpWindowName, int nWidth, int nHeight) |
| 49 | { |
| 50 | if (SDL_Init(SDL_INIT_EVERYTHING & ~SDL_INIT_HAPTIC) <= -1) { |
| 51 | ErrSdl(); |
| 52 | } |
| 53 | |
| 54 | atexit(SDL_Quit); |
| 55 | |
| 56 | #ifdef USE_SDL1 |
| 57 | SDL_EnableUNICODE(1); |
| 58 | #endif |
| 59 | #if defined(USE_SDL1) || defined(__SWITCH__) |
| 60 | InitController(); |
| 61 | #endif |
| 62 | |
| 63 | int upscale = 1; |
| 64 | DvlIntSetting("upscale", &upscale); |
| 65 | if (fullscreen) |
| 66 | DvlIntSetting("fullscreen", (int *)&fullscreen); |
| 67 | |
| 68 | int grabInput = 1; |
| 69 | DvlIntSetting("grab input", &grabInput); |
| 70 | |
| 71 | #ifdef USE_SDL1 |
| 72 | SDL_WM_SetCaption(lpWindowName, WINDOW_ICON_NAME); |
| 73 | const auto &best = *SDL_GetVideoInfo(); |
| 74 | SDL_Log("Best video mode reported as: %dx%d bpp=%d hw_available=%u", |
| 75 | best.current_w, best.current_h, best.vfmt->BitsPerPixel, best.hw_available); |
| 76 | SetVideoModeToPrimary(fullscreen); |
| 77 | if (grabInput) |
| 78 | SDL_WM_GrabInput(SDL_GRAB_ON); |
| 79 | atexit(SDL_VideoQuit); // Without this video mode is not restored after fullscreen. |
| 80 | #else |
| 81 | int flags = 0; |
| 82 | if (upscale) { |
| 83 | flags |= fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_RESIZABLE; |
| 84 | |
| 85 | char scaleQuality[2] = "2"; |
| 86 | DvlStringSetting("scaling quality", scaleQuality, 2); |
| 87 | SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, scaleQuality); |
| 88 | } else if (fullscreen) { |
| 89 | flags |= SDL_WINDOW_FULLSCREEN; |
| 90 | } |
| 91 | |
| 92 | if (grabInput) { |
| 93 | flags |= SDL_WINDOW_INPUT_GRABBED; |
| 94 | } |
| 95 | |
| 96 | window = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, nWidth, nHeight, flags); |
| 97 | #endif |
| 98 | if (window == NULL) { |
| 99 | ErrSdl(); |
| 100 | } |
| 101 | |
| 102 | int refreshRate = 60; |
| 103 | #ifndef USE_SDL1 |
| 104 | SDL_DisplayMode mode; |
| 105 | SDL_GetDisplayMode(0, 0, &mode); |
no test coverage detected