moderngl / moderngl-window

A cross platform utility library for ModernGL making window creation and resource loading simple
MIT License
246 stars 61 forks source link

Implement size setter for Headless Window backend #188

Closed Tremeschin closed 9 months ago

Tremeschin commented 9 months ago

Most window backends implements a size setter that redirects to the proper window shared library, that manages the internal states accordingly. Except headless, which is purely managed by moderngl and moderngl-window

This PR implements this work on moderngl_window.context.headless.window.Window class, to release the old FBO+attachments and create new objects when a window.size = width, height is called

A practical use is one project of mine, where I initialize the window and context at a default resolution for modules to create or load textures, but the final render resolution might be changed by a CLI or module itself (eg. scaling)

Implementation should be safe, and avoids recreating the FBO when same resolution is set