Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

askthedev.com Logo askthedev.com Logo
Sign InSign Up

askthedev.com

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Ubuntu
  • Python
  • JavaScript
  • Linux
  • Git
  • Windows
  • HTML
  • SQL
  • AWS
  • Docker
  • Kubernetes
Home/ Questions/Q 39385
In Process

askthedev.com Latest Questions

Asked: April 11, 20252025-04-11T02:14:21+05:30 2025-04-11T02:14:21+05:30

Why does pygame display at 1.5 times the screen size in fullscreen on Linux, and what is the workaround?

anonymous user

I’ve been diving into a 2D game project using Pygame on my Linux system, and I’ve run into a pretty frustrating problem. Whenever I switch to fullscreen mode, the display ends up being about 1.5 times the actual size of my screen – it’s like I’m playing in some zoomed-in mode or something. The game appears blurred and misaligned, which totally messes with the experience.

I’ve tried to figure out why this is happening, and while I found some threads discussing similar issues on Windows, there doesn’t seem to be anything for Linux users. I read through the existing StackOverflow questions, including this one [Pygame Display Info Giving Wrong Resolution Size](https://stackoverflow.com/questions/27421391/pygame-display-info-giving-wrong-resolution-size) and another one about the fullscreen issue [Pygame Fullscreen Display Issue](https://gamedev.stackexchange.com/questions/105750/pygame-fullsreen-display-issue), but they mostly focus on Windows-specific solutions. One suggested workaround for Windows involves calling some CTypes functions to set DPI awareness, which doesn’t translate to Linux – obviously not helpful for my situation.

Here’s a snippet of my code where the issue is cropping up:

“`python
# Initialize pygame
pygame.init()

# Get screen info for fullscreen
screen_info = pygame.display.Info()
WIDTH = screen_info.current_w
HEIGHT = screen_info.current_h

# Screen setup – fullscreen mode
screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN)
“`

I’m currently just setting the display mode to the reported current width and height, which works fine until I hit fullscreen. It’s leaving me scratching my head about what to do next.

Has anyone else run into this issue on Linux while using Pygame? Is there a known workaround that could help me out? I’m really eager to get back to my game development without dealing with these weird scaling problems. Any insights or tips would be greatly appreciated!

  • 0
  • 0
  • 2 2 Answers
  • 0 Followers
  • 0
Share
  • Facebook

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Continue with Google
    or use

    Forgot Password?

    Need An Account, Sign Up Here
    Continue with Google

    2 Answers

    • Voted
    • Oldest
    • Recent
    1. anonymous user
      2025-04-11T02:14:22+05:30Added an answer on April 11, 2025 at 2:14 am

      It sounds like you’re facing quite the headache with fullscreen mode in Pygame! This issue does seem to crop up sometimes, especially on Linux where things can behave a bit differently than on Windows.

      One thing you might want to try is checking the pixel format and scaling settings of your display. Sometimes, if the scaling is set differently (like to 150% instead of 100%), it can cause the game to appear zoomed in. You can adjust these settings through the display settings in your Linux environment.

      If the problem persists, consider setting your display mode to a specific resolution instead of using the full dimensions reported by pygame.display.Info(). You might want to set it to a native resolution of your monitor:

      
      # Instead of taking current_w and current_h directly,
      # try setting a specific resolution that you know works well.
      
      # Example resolution for a 1080p monitor
      WIDTH = 1920
      HEIGHT = 1080
      
      screen = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN)
      
          

      This won’t be dynamic, so keep in mind that it may not stretch perfectly on every display, but it could solve the blurriness issue.

      Lastly, if you’re able to, try testing the game on different Linux distributions or with different graphics drivers, as sometimes hardware or driver-related quirks could lead to these problems.

      Hope this helps! Getting back to coding is always the goal, right?

        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
    2. anonymous user
      2025-04-11T02:14:23+05:30Added an answer on April 11, 2025 at 2:14 am

      This fullscreen scaling issue on Linux typically arises due to inconsistencies between the display’s actual native resolution and what Pygame detects or utilizes as the display resolution, especially on systems with HiDPI (high-DPI) displays. Pygame relies heavily on the SDL library, which can misinterpret resolution and scaling factors in certain Linux desktop environments like GNOME or KDE. To verify if this is the issue, try explicitly fetching and setting the native resolution using external tools such as xrandr (available on most Linux systems). By running xrandr | grep '*' in your terminal, you can confirm the actual resolution, and then explicitly set your game’s resolution using these coordinates rather than relying entirely on pygame.display.Info(). Alternatively, setting the environment variable SDL_VIDEO_X11_FORCE_EGL=1 before launching your Python script may alleviate some compatibility issues related to scaling and DPI detection on Linux.

      If manually defining the resolution or adjusting SDL environment variables doesn’t help, a reliable workaround is switching to a “borderless windowed fullscreen” approach, which often resolves scaling issues seamlessly. This entails creating a fullscreen-sized window without window decorations, rather than using the standard fullscreen flag, allowing seamless integration with the desktop compositor. You can accomplish this in Pygame by setting a display mode without the FULLSCREEN flag but with the resolution matching the desktop dimensions (retrieved reliably via external methods), and combining it with environment-specific tweaks. Although it’s slightly less performant compared to true fullscreen due to compositing overhead, the visual and alignment issues you currently experience should disappear, providing a smooth and correct user experience.

        • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Sidebar

    Recent Answers

    1. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
    2. anonymous user on How do games using Havok manage rollback netcode without corrupting internal state during save/load operations?
    3. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
    4. anonymous user on How can I efficiently determine line of sight between points in various 3D grid geometries without surface intersection?
    5. anonymous user on How can I update the server about my hotbar changes in a FabricMC mod?
    • Home
    • Learn Something
    • Ask a Question
    • Answer Unanswered Questions
    • Privacy Policy
    • Terms & Conditions

    © askthedev ❤️ All Rights Reserved

    Explore

    • Ubuntu
    • Python
    • JavaScript
    • Linux
    • Git
    • Windows
    • HTML
    • SQL
    • AWS
    • Docker
    • Kubernetes

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.