Skip to content

Upcoming libsdl2-2.23 and HiDPI #61

@sjnewbury

Description

@sjnewbury

The upcoming release of SDL2 has reworked the HiDPI support and doesn't need the manual scaling_factor adjustment anymore. I've inlined a tested patch to the sdl2.patch which removes it, but that does mean it will only work with subsequent SDL releases. My thinking is this doesn't matter too much since SDL2 support is still optional and it could just be noted that HiDPI support requires libsdl2-2.23 or greater going forwards.. Maybe it would be better to check for the SDL2 version?

--- ./patches/sdl2.patch~       2022-06-23 10:33:59.000000000 +0100
+++ ./patches/sdl2.patch        2022-06-23 10:44:12.101013273 +0100
@@ -78,7 +78,7 @@
 +#if SDLQUAKE == 2
 +      int display_index;
 +      SDL_DisplayMode desktop_mode;
-+      int screen_w, screen_h, scaling_factor = 100;
++      int screen_w, screen_h;
 +#endif
  
        in_mode_set = true;
@@ -91,7 +91,7 @@
        // setup the attributes
        if (bpp >= 32)
        {
-@@ -452,6 +479,81 @@ static qboolean VID_SetMode (int modenum)
+@@ -452,6 +479,72 @@ static qboolean VID_SetMode (int modenum)
  
        Con_SafePrintf ("Requested mode %d: %dx%dx%d\n", modenum, modelist[modenum].width, modelist[mo
  
@@ -113,11 +113,6 @@
 +                      SDL_GetWindowSize(window, &screen_w, &screen_h);
 +                      SDL_GL_GetDrawableSize(window, &drawable_w, &drawable_h);
 +
-+                      scaling_factor = (100 * drawable_w) / screen_w;
-+
-+                      if (scaling_factor != 100)
-+                              Con_Printf ("High DPI scaling in effect! (%d%%)\n", scaling_factor);
-+
 +                      if (screen_w == desktop_mode.w && screen_h == desktop_mode.h)
 +                      {
 +                              flags = SDL_WINDOW_FULLSCREEN_DESKTOP;
@@ -148,10 +143,6 @@
 +              // Now that we have the fullscreen flags, set them
 +              SDL_SetWindowFullscreen(window, flags);
 +
-+      // Modify mode with real width and height
-+      modelist[modenum].width = modelist[modenum].width * scaling_factor / 100;
-+      modelist[modenum].height = modelist[modenum].height * scaling_factor / 100;
-+
 +      glcontext = SDL_GL_CreateContext(window);
 +      if (!glcontext)
 +      {
@@ -173,7 +164,7 @@
        VID_SetIcon();
  
        screen = SDL_SetVideoMode (modelist[modenum].width, modelist[modenum].height, bpp, flags);
-@@ -473,9 +575,13 @@ static qboolean VID_SetMode (int modenum)
+@@ -473,9 +566,13 @@ static qboolean VID_SetMode (int modenum)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions