# HG changeset patch # User Sam # Date 1682422343 -25200 # Node ID 510c651cb27d64eff5fc4df2bb43e719b9dd8d83 # Parent fdd80220b5ff3b158610efc5396edccbbad3b586 add: window-resize check diff -r fdd80220b5ff -r 510c651cb27d src/semicongine/engine.nim --- a/src/semicongine/engine.nim Tue Apr 25 18:24:18 2023 +0700 +++ b/src/semicongine/engine.nim Tue Apr 25 18:32:23 2023 +0700 @@ -25,6 +25,7 @@ mouseWasReleased: set[MouseButton] mousePosition: Vec2f eventsProcessed: uint64 + windowWasResized: bool Engine* = object running*: bool device: Device @@ -106,9 +107,9 @@ engine.input.keyWasReleased = {} engine.input.mouseWasPressed = {} engine.input.mouseWasReleased = {} - var - killed = false - resized = false + engine.input.windowWasResized = false + + var killed = false for event in engine.window.pendingEvents(): inc engine.input.eventsProcessed if engine.eventHandler != nil: @@ -117,7 +118,7 @@ of Quit: killed = true of ResizedWindow: - resized = true + engine.input.windowWasResized = true of KeyPressed: engine.input.keyWasPressed.incl event.key engine.input.keyIsDown.incl event.key @@ -136,7 +137,7 @@ engine.running = false if engine.exitHandler != nil: engine.exitHandler(engine) - if resized and engine.resizeHandler != nil: + if engine.input.windowWasResized and engine.resizeHandler != nil: engine.resizeHandler(engine) func keyIsDown*(engine: Engine, key: Key): auto = key in engine.input.keyIsDown @@ -150,3 +151,4 @@ func framesRendered*(engine: Engine): auto = engine.renderer.framesRendered func gpuDevice*(engine: Engine): Device = engine.device func getWindow*(engine: Engine): auto = engine.window +func windowWasResized*(engine: Engine): auto = engine.input.windowWasResized