File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ main = do
30
30
31
31
loop :: Window -> IORef Bool -> IO ()
32
32
loop w checked = do
33
- ev <- pollEventWithImGui
33
+ quit <- pollEvents
34
34
35
35
openGL2NewFrame
36
36
sdl2NewFrame w
@@ -85,11 +85,21 @@ loop w checked = do
85
85
86
86
glSwapWindow w
87
87
88
- case ev of
89
- Nothing -> loop w checked
90
- Just Event { eventPayload } -> case eventPayload of
91
- QuitEvent -> return ()
92
- _ -> loop w checked
88
+ if quit then return () else loop w checked
89
+
90
+ where
91
+
92
+ pollEvents = do
93
+ ev <- pollEventWithImGui
94
+
95
+ case ev of
96
+ Nothing -> return False
97
+ Just Event { eventPayload } -> do
98
+ let isQuit = case eventPayload of
99
+ QuitEvent -> True
100
+ _ -> False
101
+
102
+ (isQuit || ) <$> pollEvents
93
103
94
104
95
105
whenTrue :: IO () -> Bool -> IO ()
You can’t perform that action at this time.
0 commit comments