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
+7
View File
@@ -398,6 +398,12 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
blendFuncSeparate $= ((SrcAlphaSaturate, OneMinusSrcAlpha), (Zero,One))
renderTree pdata rot zoom (tranx,trany) (winx,winy) $ picToFTree 2 pic
-- reset uniforms (hacky for now)
idmat <- (newMatrix RowMajor [1,0,0,0
,0,1,0,0
,0,0,1,0
,0,0,0,1
]
) :: IO (GLmatrix GLfloat)
forM_ [_basicShader pdata
,_textShader pdata
,_circShader pdata
@@ -411,6 +417,7 @@ renderPicture' pdata rot zoom (tranx,trany) (winx,winy) wallPoints lightPoints p
uniform (snd shad !! 1) $= (1::Float)
uniform (snd shad !! 2) $= (0::Float)
uniform (snd shad !! 3) $= Vector2 (0::Float) 0
uniform (snd shad !! 4) $= idmat
bufferOffset :: Integral a => a -> Ptr b