Allow for parameters to be changed by io actions
This commit is contained in:
+5
-7
@@ -28,13 +28,12 @@ setupLoop :: String
|
||||
-> IO setupParams
|
||||
-> (setupParams -> IO ())
|
||||
-> world
|
||||
-> (setupParams -> world -> IO ())
|
||||
-> (setupParams -> world -> storableSideEffects -> IO storableSideEffects)
|
||||
-> (setupParams -> world -> IO setupParams)
|
||||
-> (world -> Event -> Maybe world)
|
||||
-> (world -> Maybe world)
|
||||
-> IO ()
|
||||
setupLoop wName xSize ySize
|
||||
customInit initCleanup startWorld sideEffects storableFn eventFn worldFn = do
|
||||
customInit initCleanup startWorld sideEffects eventFn worldFn = do
|
||||
initializeAll
|
||||
bracket (createWindow (T.pack wName) (winConfig xSize ySize)) destroyWindow
|
||||
(\window ->
|
||||
@@ -48,7 +47,7 @@ setupLoop wName xSize ySize
|
||||
GL.clearColor $= GL.Color4 0 0.5 0 1
|
||||
GL.clearDepth $= (200)
|
||||
doLoop setup window startWorld
|
||||
sideEffects storableFn eventFn worldFn
|
||||
sideEffects eventFn worldFn
|
||||
)
|
||||
)
|
||||
|
||||
@@ -60,12 +59,11 @@ setupLoop wName xSize ySize
|
||||
-- -> IO ()
|
||||
doLoop setup window startWorld
|
||||
worldSideEffects
|
||||
storableFn
|
||||
eventFn
|
||||
worldUpdate
|
||||
= do
|
||||
GL.clear [GL.ColorBuffer,GL.DepthBuffer]
|
||||
worldSideEffects setup startWorld
|
||||
newParams <- worldSideEffects setup startWorld
|
||||
glSwapWindow window
|
||||
--worldSideEffects setup updatedWorld
|
||||
startLoopTicks <- ticks
|
||||
@@ -83,7 +81,7 @@ doLoop setup window startWorld
|
||||
endLoopTicks <- ticks -- it might be better to use System.Clock (monotonic)
|
||||
let delay = max 0 (10 + fromIntegral startLoopTicks - fromIntegral endLoopTicks)
|
||||
threadDelay (delay * 1000)
|
||||
doLoop setup window updatedWorld worldSideEffects storableFn eventFn worldUpdate
|
||||
doLoop newParams window updatedWorld worldSideEffects eventFn worldUpdate
|
||||
Nothing -> return ()
|
||||
|
||||
applyEvents :: (world0 -> Event -> Maybe world0)
|
||||
|
||||
Reference in New Issue
Block a user