Add sound source files

This commit is contained in:
2021-02-23 14:48:00 +01:00
parent 5bdd646900
commit 058873af50
7 changed files with 59 additions and 28 deletions
+12 -6
View File
@@ -29,11 +29,12 @@ setupLoop :: String
-> (setupParams -> IO ())
-> world
-> (setupParams -> world -> IO ())
-> (setupParams -> world -> storableSideEffects -> IO storableSideEffects)
-> (world -> Event -> Maybe world)
-> (world -> Maybe world)
-> IO ()
setupLoop wName xSize ySize
customInit initCleanup startWorld sideEffects eventFn worldFn = do
customInit initCleanup startWorld sideEffects storableFn eventFn worldFn = do
initializeAll
bracket (createWindow (T.pack wName) (winConfig xSize ySize)) destroyWindow
(\window ->
@@ -47,7 +48,7 @@ setupLoop wName xSize ySize
GL.clearColor $= GL.Color4 0 0.5 0 1
GL.clearDepth $= (200)
doLoop setup window startWorld
sideEffects eventFn worldFn
sideEffects storableFn eventFn worldFn
)
)
@@ -59,9 +60,14 @@ setupLoop wName xSize ySize
-- -> IO ()
doLoop setup window startWorld
worldSideEffects
storableFn
eventFn
worldUpdate
= do
GL.clear [GL.ColorBuffer,GL.DepthBuffer]
worldSideEffects setup startWorld
glSwapWindow window
--worldSideEffects setup updatedWorld
startLoopTicks <- ticks
events <- pollEvents
--let-- maybeUpdatedWorld :: Maybe (WorldView world0)
@@ -69,15 +75,15 @@ doLoop setup window startWorld
maybeUpdatedWorld <- applyEventsIO eventFn startWorld events
case maybeUpdatedWorld >>= worldUpdate of
Just updatedWorld -> do
GL.clear [GL.ColorBuffer,GL.DepthBuffer]
worldSideEffects setup updatedWorld
glSwapWindow window
--GL.clear [GL.ColorBuffer,GL.DepthBuffer]
--worldSideEffects setup updatedWorld
--glSwapWindow window
--GL.flush
performGC
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 eventFn worldUpdate
doLoop setup window updatedWorld worldSideEffects storableFn eventFn worldUpdate
Nothing -> return ()
applyEvents :: (world0 -> Event -> Maybe world0)