-
Notifications
You must be signed in to change notification settings - Fork 186
Open
Labels
Description
Hi,
I came across this overflow error when trying to do a simple change to fullscreen using pygame, opengl and the imgui integration. The attached file reproduces it.
If you perform this line:
pygame.display.set_mode((0,0), pygame.OPENGL | pygame.DOUBLEBUF | pygame.FULLSCREEN)
Then the pygame integration will fail with the error:
Traceback (most recent call last):
File "/path/to/reproducer.py", line 61, in <module>
impl.process_event(event)
File "/path/to/venv/lib/python3.11/site-packages/imgui/integrations/pygame.py", line 127, in process_event
pygame.display.set_mode(
OverflowError: signed integer is greater than maximum
This is produced because the surface.get_flags() function returns the value 2147483666. The workaround is to catch this and re-enter the flags.
117 if event.type == pygame.VIDEORESIZE:
118 surface = pygame.display.get_surface()
119 # note: pygame does not modify existing surface upon resize,
120 # we need to to it ourselves.
// BEGIN WORKAROUND
123 flags = surface.get_flags()
124 if flags == 2147483666:
125 flags=pygame.OPENGL | pygame.DOUBLEBUF | pygame.FULLSCREEN
// END WORKAROUND
126
127 pygame.display.set_mode(
128 (event.w, event.h),
129 flags=flags,
130 )
Packages are:
imgui==2.0.0
numpy==1.26.4
pillow==10.2.0
pygame==2.5.2
PyOpenGL==3.1.7
pygame 2.5.2 (SDL 2.28.2, Python 3.11.6)
The attachment includes both minimal reproducer and the output.