glfw: fix crash when window size is <= 0

Windows sets the window size to (0,0) when minimizing the window. That leads to eventual division by zero errors and opengl does not want to attach a framebuffer with that size, resulting in it being incomplete. After maximizing again, it tries to unload that framebuffer, but it was never loaded. Minosoft crashes with an invalid framebuffer state: deleted
This commit is contained in:
Moritz Zwerger 2023-11-24 22:58:17 +01:00
parent e2f30887ff
commit a63b020e53
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -351,8 +351,10 @@ class GLFWWindow(
if (window != this.window) { if (window != this.window) {
return return
} }
val previousSize = Vec2i(_size)
val nextSize = unscalePosition(Vec2i(width, height)) val nextSize = unscalePosition(Vec2i(width, height))
if (nextSize.x <= 0 || nextSize.y <= 0) return // windows returns size (0,0) if minimized
val previousSize = Vec2i(_size)
if (previousSize == nextSize) return
_size = nextSize _size = nextSize
fireGLFWEvent(ResizeWindowEvent(context, previousSize = previousSize, size = _size)) fireGLFWEvent(ResizeWindowEvent(context, previousSize = previousSize, size = _size))
this.skipNextMouseEvent = true this.skipNextMouseEvent = true