Cleanup. Start tweaking flares, glares and flashes

This commit is contained in:
2021-10-29 21:47:03 +01:00
parent 78f91e522b
commit 502be6f64f
18 changed files with 59 additions and 153 deletions
+10 -6
View File
@@ -19,17 +19,17 @@ import qualified Graphics.Rendering.OpenGL as GL
setupLoop
:: Int -- ^ Target seconds per frame
-> (Int,Int) -- ^ The window size.
-> (Int,Int) -- ^ The window position.
-> Maybe (Int,Int) -- ^ The window position.
-> (world -> IO ()) -- ^ Function for cleaning up parameters, applied when exiting loop.
-> IO world -- ^ Initial simulation state.
-> (world -> IO world) -- ^ update, called once per frame. Allows for side effects such as rendering.
-> (world -> Event -> Maybe world)
-- ^ SDL Event handling, once per frame. Evaluating 'Nothing' exits the loop.
-> IO ()
setupLoop spf (xSize,ySize) (xPos,yPos) paramCleanup ioStartWorld sideEffects eventFn = do
setupLoop spf (xSize,ySize) winpos paramCleanup ioStartWorld sideEffects eventFn = do
initializeAll
bracket
(createWindow (T.pack "Simple Game Loop") (winConfig xSize ySize xPos yPos))
(createWindow (T.pack "Simple Game Loop") (winConfig xSize ySize winpos))
destroyWindow
$ \window -> bracket
(glCreateContext window)
@@ -78,13 +78,17 @@ applyEventIO fn mw e = case eventPayload e of
-> GL.viewport $= (GL.Position 0 0,GL.Size x y) >> return (mw >>= \w -> fn w e)
_ -> return $ mw >>= flip fn e
-- | Create an OpenGL SDL window configuration with a given x and y size.
winConfig :: Int -> Int -> Int -> Int -> WindowConfig
winConfig x y px py = defaultWindow
winConfig :: Int -> Int -> Maybe (Int, Int) -> WindowConfig
winConfig x y winpos = defaultWindow
{ windowGraphicsContext = OpenGLContext $ defaultOpenGL
{ glProfile = Core Normal 4 3
, glColorPrecision = V4 8 8 8 8
}
, windowPosition = Absolute (P (V2 (fromIntegral px) (fromIntegral py)))
, windowPosition = theWinPos
, windowInitialSize = V2 (fromIntegral x) (fromIntegral y)
, windowResizable =True
}
where
theWinPos = case winpos of
Just (px,py) -> Absolute (P (V2 (fromIntegral px) (fromIntegral py)))
Nothing -> Wherever