-static qboolean VID_InitModeSoft(viddef_mode_t *mode)
-{
-#if SDL_MAJOR_VERSION == 1
- int flags = SDL_HWSURFACE;
- if(!COM_CheckParm("-noasyncblit")) flags |= SDL_ASYNCBLIT;
-#else
- int windowflags = SDL_WINDOW_SHOWN;
-#endif
-
- win_half_width = mode->width>>1;
- win_half_height = mode->height>>1;
-
- if(vid_resizable.integer)
-#if SDL_MAJOR_VERSION == 1
- flags |= SDL_RESIZABLE;
-#else
- windowflags |= SDL_WINDOW_RESIZABLE;
-#endif
-
- VID_OutputVersion();
-
- vid_isfullscreen = false;
- if (mode->fullscreen) {
-#if SDL_MAJOR_VERSION == 1
- const SDL_VideoInfo *vi = SDL_GetVideoInfo();
- mode->width = vi->current_w;
- mode->height = vi->current_h;
- mode->bitsperpixel = vi->vfmt->BitsPerPixel;
- flags |= SDL_FULLSCREEN;
-#else
- if (vid_desktopfullscreen.integer)
- windowflags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
- else
- windowflags |= SDL_WINDOW_FULLSCREEN;
-#endif
- vid_isfullscreen = true;
- }
-
- video_bpp = mode->bitsperpixel;
-#if SDL_MAJOR_VERSION == 1
- video_flags = flags;
- screen = VID_WrapSDL_SetVideoMode(mode->width, mode->height, mode->bitsperpixel, flags);
- if (screen == NULL)
- {
- Con_Printf("Failed to set video mode to %ix%i: %s\n", mode->width, mode->height, SDL_GetError());
- VID_Shutdown();
- return false;
- }
- mode->width = screen->w;
- mode->height = screen->h;
-#else
- window_flags = windowflags;
- window = SDL_CreateWindow(gamename, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, mode->width, mode->height, windowflags);
- if (window == NULL)
- {
- Con_Printf("Failed to set video mode to %ix%i: %s\n", mode->width, mode->height, SDL_GetError());
- VID_Shutdown();
- return false;
- }
- SDL_GetWindowSize(window, &mode->width, &mode->height);
-#endif
-
- // create a framebuffer using our specific color format, we let the SDL blit function convert it in VID_Finish
- vid_softsurface = SDL_CreateRGBSurface(SDL_SWSURFACE, mode->width, mode->height, 32, 0x00FF0000, 0x0000FF00, 0x00000000FF, 0xFF000000);
- if (vid_softsurface == NULL)
- {
- Con_Printf("Failed to setup software rasterizer framebuffer %ix%ix32bpp: %s\n", mode->width, mode->height, SDL_GetError());
- VID_Shutdown();
- return false;
- }
-#if SDL_MAJOR_VERSION == 1
- SDL_SetAlpha(vid_softsurface, 0, 255);
-#endif
-
- vid.softpixels = (unsigned int *)vid_softsurface->pixels;
- vid.softdepthpixels = (unsigned int *)calloc(1, mode->width * mode->height * 4);
- if (DPSOFTRAST_Init(mode->width, mode->height, vid_soft_threads.integer, vid_soft_interlace.integer, (unsigned int *)vid_softsurface->pixels, (unsigned int *)vid.softdepthpixels) < 0)
- {
- Con_Printf("Failed to initialize software rasterizer\n");
- VID_Shutdown();
- return false;
- }
-
-#if SDL_MAJOR_VERSION == 1
- // init keyboard
- SDL_EnableUNICODE( SDL_ENABLE );
- // enable key repeat since everyone expects it
- SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
-#endif
-
- VID_Soft_SharedSetup();
-
- vid_hidden = false;
- vid_activewindow = false;
- vid_hasfocus = true;
- vid_usingmouse = false;
- vid_usinghidecursor = false;
-
-#if SDL_MAJOR_VERSION == 1
- SDL_WM_GrabInput(SDL_GRAB_OFF);
-#endif
- return true;
-}
-