# HG changeset patch # User Sam # Date 1682422343 -25200 # Node ID 01881f9296fa0a02558d1699da6880e1ffd5b369 # Parent 8ce634aa6ea6c0ea4c52e69338c2bc66f4ec5df1 add: window-resize check diff -r 8ce634aa6ea6 -r 01881f9296fa 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