Skip to content

Calling a second time pygame.display.set_mode with vsync and vsync already enabled doesn't work correctly #2571

Open
@bilhox

Description

@bilhox

Environment:

  • Operating system : Windows 11
  • Python version : 3.11.4 / 3.12.0
  • SDL version : 2.26.5
  • PyGame version : 2.3.2 / 2.4.0.dev2

Current behavior:

If you call pygame.display.set_mode with vsync enabled and then again with vsync enabled, the screen is black (like you lost the hand on the screen) and when you resize, the rest of the window is transparent.

Expected behavior:

You don't lost the hand on the screen, and it correctly resizes.
Note : If you quit pygame between the two calls, the problem is fixed, could you tell me if it's what we should do ?

Screenshots

image
Capture d'écran 2023-11-19 142026

Test program:

import pygame
import math

pygame.init()

screen = pygame.display.set_mode([800, 800], flags=pygame.RESIZABLE+pygame.SCALED, vsync=1)
screen2 = pygame.display.set_mode([900, 800], flags=pygame.RESIZABLE+pygame.SCALED, vsync=1)

clock = pygame.Clock()
pos = []
timer = 0

running = True

while running:

    dt = clock.tick() / 1000
    timer += dt

    screen.fill("black")

    pos = [400 + 40*math.cos(5*timer) + 20*math.cos(10*timer) + 200*math.cos(timer), 400 + 20*math.sin(10*timer) + 40*math.sin(5*timer) + 200*math.sin(timer)]

    pygame.draw.circle(screen, "red", pos, 20)

    pygame.display.flip()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            running = False

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugNot working as intendeddisplaypygame.displaysegfaultFor PRs that fix segfaults or issues containing segfaults which have an higher priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions