Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_mode() wont change the graphics mode the second time when OPENGL flag is used #4224

Open
jairov-apptio opened this issue May 4, 2024 · 6 comments

Comments

@jairov-apptio
Copy link

jairov-apptio commented May 4, 2024

Environment:

You can get some of this info from the text that pops up in the console when you run a pygame program.

  • Operating system: Windows 11
  • Python version: 3.11.6
  • SDL version : 2.28.3
  • PyGame version: 2.5.2

Current behavior:

When the OPENGL flag is used, the set_mode() wont change the graphics mode after the first time is used.

Expected behavior:

set_mode() should change the graphics mode all the times irrespective of the OPENGL flag use.

Steps to reproduce:

Use the test code and run

Test code

If possible add a simple test program that shows the problem described in this report.

from pygame.display import set_mode, init
from pygame.locals import OPENGL

init()

s1 = set_mode((1280, 720), OPENGL)
assert s1.get_size() == (1280, 720)  # first time is ok!

s2 = set_mode((1920, 1080), OPENGL)
print(s2.get_size())  # should print (1920, 1080), but the graphics mode is still 1280x720
# assert s3.get_size() == (1920, 1080)  # commented because wont make it

s3 = set_mode((1920, 1080))  # <-- without OPENGL
print(s3.get_size())  # should print (1920, 1080)
assert s3.get_size() == (1920, 1080)  # no problem this time

** output error **

pygame 2.5.2 (SDL 2.28.3, Python 3.11.6)
Hello from the pygame community. https://www.pygame.org/contribute.html
(1280, 720)
(1920, 1080)
@illume
Copy link
Member

illume commented May 15, 2024

Thanks for the good reproducer.

Note, I can't reproduce on Ubuntu 22.04. Maybe it's specific to the Windows driver.

@TheDarkTiger
Copy link

TheDarkTiger commented May 17, 2024

I tested you script, and I can confirm, it breaks on my computer too (I uncommented the assert).
Both on:

  • Windows7
  • Python 3.10.7
  • SDL 2.28.3
  • Pygame 2.5.2

And:

  • Windows7
  • Python3.10.7
  • SDL 2.26.4
  • Pygame 2.4.0

But "funny" enough, I am using Pygame 2.4.0 because 2.5.x breaks the 'set_mode()' flags.
More precisely, the very useful pygame.SCALED is broken...

@illume
Copy link
Member

illume commented May 18, 2024

One thing is windows opengl has this quirk where you need to redo all of the textures and such when you get a new window. I'm not sure if it's related to that.

Probably you already know this, but as a work around you should be able to do:

pygame.display.quit()
pygame.display.init()
pygame.display.set_mode()

@illume
Copy link
Member

illume commented May 18, 2024

@TheDarkTiger do you know if there's already an issue about that SCALED thing? If so, can you please ping me on that issue?

@jairov4
Copy link

jairov4 commented May 18, 2024

@illume I imagine thats related, however afaik pygame is not storing textures in vram so it do not need to asumme an special behavior. However, thanks for your workaround it will work for me for now

@TheDarkTiger
Copy link

@illume I tried your patch, and it works.
I will keep it until pygame fix the regression.

Also, I looked a bit, but I will be honest, I didn't search for very long if the SCALED issue was opened somewhere else.
If I see it, I will forward it to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants