Search code examples
pythonpygameopensuse

Pygame window does not responding in fullscreen mode


So when i use window mode in pygame everything works fine, but if i use fullscreen mode my screen becomes black and i can't draw anything or update the screen (There's no any errors in the console as well)

# works fine
win = pygame.display.set_mode((1920, 1080))

# does not work fine
win = pygame.display.set_mode((1920, 1080), pygame.FULLSCREEN)
# i tried adding flags pygame.HWSURFACE and pygame.DOUBLEBUF, it did not work

It seems like this problem is because of my operating system (openSUSE), because on Windows 7 it works fine in fullscreen mode.

So i don't know- does this happen because of some missing library or package, or because of something else?

I wrote here about my OS and software specs:

OS: openSUSE Leap 15.2 x64
KDE Plasma version: 5.18.5
Pygame version: 2.0.0dev12 (On pygame 1.9.6 i have the same problem)
Python version: 3.6.10

If you need more information just ask about it and i'll add it into this article


Solution

  • I have heard of people having issues with fullscreen SDL on Linux. An alternative approach is to use a borderless window, e.g.

    # force window position to be centred
    os.environ["SDL_VIDEO_CENTERED"] = "1"
    pygame.init()
    # get the current screen size
    info = pygame.display.Info()
    width, height = info.current_w, info.current_h
    screen = pygame.display.set_mode((width, height), pygame.NOFRAME)