Couple loop with preload to allow for time "profiling"

This commit is contained in:
jgk
2021-02-26 00:05:27 +01:00
parent 9575eab230
commit 4fc6917741
4 changed files with 27 additions and 33 deletions
+19 -5
View File
@@ -12,6 +12,10 @@ import System.Mem
import Foreign.C
import Geometry
import Preload
import Control.Lens ((.~),(&))
winConfig x y = defaultWindow
{ windowGraphicsContext
= OpenGLContext (defaultOpenGL { glProfile = Core Normal 4 3
@@ -22,13 +26,23 @@ winConfig x y = defaultWindow
, windowResizable =True
}
--setupLoop :: String
-- -> CInt
-- -> CInt
-- -> IO setupParams
-- -> (setupParams -> IO ())
-- -> world
-- -> (setupParams -> world -> IO setupParams)
-- -> (world -> Event -> Maybe world)
-- -> (world -> Maybe world)
-- -> IO ()
setupLoop :: String
-> CInt
-> CInt
-> IO setupParams
-> (setupParams -> IO ())
-> IO (PreloadData a)
-> (PreloadData a -> IO ())
-> world
-> (setupParams -> world -> IO setupParams)
-> (PreloadData a -> world -> IO (PreloadData a))
-> (world -> Event -> Maybe world)
-> (world -> Maybe world)
-> IO ()
@@ -62,11 +76,11 @@ doLoop setup window startWorld
eventFn
worldUpdate
= do
startLoopTicks <- ticks
GL.clear [GL.ColorBuffer,GL.DepthBuffer]
newParams <- worldSideEffects setup startWorld
newParams <- worldSideEffects (setup & currentTime .~ startLoopTicks) startWorld
glSwapWindow window
--worldSideEffects setup updatedWorld
startLoopTicks <- ticks
events <- pollEvents
--let-- maybeUpdatedWorld :: Maybe (WorldView world0)
-- maybeUpdatedWorld = applyEvents eventFn startWorld events worldUpdate