pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
766 stars 120 forks source link

Update OpenGL Viewport when Window resizes #2915

Open damusss opened 3 weeks ago

damusss commented 3 weeks ago

Fixes https://github.com/pygame-community/pygame-ce/issues/2877 The documentation has been updated by MyreMylar already.

As stated in the issue, the newly functional OpenGL Windows, unlike the display windows, would not resize the OpenGL viewport causing bugs and inconsistencies.

With the addition of a function, used both in the event watch and in the set_size function, the OpenGl viewport is now correctly updated. I tested locally, it works for fullscreen/maximization/autoresize/manualresize.

If it works for you too (should, it's identical to the display's one), I think this should be added not later than 2.5.1

oddbookworm commented 3 weeks ago

I suspect the circleCI failure is unrelated to your changes, looks like it's unable to download the SDL2 dependency. I'm going to wait a while before rerunning it

damusss commented 3 weeks ago

@oddbookworm Alright, I managed to make glViewport static and I added exceptions to my new function. To note that the window is still resized even if there are problems with opengl, so you could do something like image On the event watch, I cleared the errors as I don't know how to stop the python execution with an exception from there. It also seems that another check (for the surface) is returning early without an exception aswell, so I followed the same trend. Tell me what you think :)